| | | 1 | | namespace Nabs.Tests; |
| | | 2 | | |
| | | 3 | | public sealed class TestCase<TInput, TOutput> |
| | | 4 | | { |
| | | 5 | | public required string Id { get; init; } |
| | | 6 | | public required string Name { get; init; } |
| | | 7 | | public required string WorkItemId { get; init; } |
| | | 8 | | public required string CallerTypeName { get; init; } |
| | | 9 | | public required string CallerMemberName { get; init; } |
| | | 10 | | public required string Description { get; init; } |
| | | 11 | | public required string ExpectedOutput { get; init; } |
| | | 12 | | public required TInput Input { get; init; } |
| | | 13 | | public required TOutput Output { get; init; } |
| | | 14 | | } |
| | | 15 | | |
| | | 16 | | public static class TestCaseFactory |
| | | 17 | | { |
| | | 18 | | public static TestCase<TInput, TOutput> Create<TInput, TOutput>( |
| | | 19 | | string id, |
| | | 20 | | string workItemId, |
| | | 21 | | string name, |
| | | 22 | | string description, |
| | | 23 | | string expectedOutput, |
| | | 24 | | TInput input, |
| | | 25 | | TOutput output, |
| | | 26 | | [CallerMemberName] string caller = "") |
| | | 27 | | { |
| | 0 | 28 | | var stackTrace = new System.Diagnostics.StackTrace(); |
| | 0 | 29 | | var callerFrame = stackTrace.GetFrame(1)!; |
| | 0 | 30 | | var callerType = callerFrame.GetMethod()!.DeclaringType; |
| | | 31 | | |
| | 0 | 32 | | return new TestCase<TInput, TOutput> |
| | 0 | 33 | | { |
| | 0 | 34 | | Id = id, |
| | 0 | 35 | | Name = name, |
| | 0 | 36 | | WorkItemId = workItemId, |
| | 0 | 37 | | Description = description, |
| | 0 | 38 | | CallerTypeName = callerType?.Name ?? string.Empty, |
| | 0 | 39 | | CallerMemberName = caller, |
| | 0 | 40 | | ExpectedOutput = expectedOutput, |
| | 0 | 41 | | Input = input, |
| | 0 | 42 | | Output = output |
| | 0 | 43 | | }; |
| | | 44 | | } |
| | | 45 | | } |