< Summary

Information
Class: Nabs.Tests.TestCaseFactory
Assembly: Nabs.Tests
File(s): /home/runner/work/Nabs/Nabs/src/Nabs.Tests/TestCase.cs
Tag: 90_14636759620
Line coverage
0%
Covered lines: 0
Uncovered lines: 15
Coverable lines: 15
Total lines: 45
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Create(...)0%2040%

File(s)

/home/runner/work/Nabs/Nabs/src/Nabs.Tests/TestCase.cs

#LineLine coverage
 1namespace Nabs.Tests;
 2
 3public 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
 16public 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    {
 028        var stackTrace = new System.Diagnostics.StackTrace();
 029        var callerFrame = stackTrace.GetFrame(1)!;
 030        var callerType = callerFrame.GetMethod()!.DeclaringType;
 31
 032        return new TestCase<TInput, TOutput>
 033        {
 034            Id = id,
 035            Name = name,
 036            WorkItemId = workItemId,
 037            Description = description,
 038            CallerTypeName = callerType?.Name ?? string.Empty,
 039            CallerMemberName = caller,
 040            ExpectedOutput = expectedOutput,
 041            Input = input,
 042            Output = output
 043        };
 44    }
 45}