< Summary

Information
Class: Nabs.NewValueService
Assembly: Nabs
File(s): /home/runner/work/Nabs/Nabs/src/Nabs/NewValueService.cs
Tag: 90_14636759620
Line coverage
66%
Covered lines: 10
Uncovered lines: 5
Coverable lines: 15
Total lines: 53
Line coverage: 66.6%
Branch coverage
33%
Covered branches: 2
Total branches: 6
Branch coverage: 33.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
SetTestGuid(...)100%11100%
SetTestDateTime(...)100%11100%
NewGuid()50%2266.66%
NewUtcNow()50%2266.66%
NewDateOnly()0%620%

File(s)

/home/runner/work/Nabs/Nabs/src/Nabs/NewValueService.cs

#LineLine coverage
 1namespace Nabs;
 2
 3public sealed class NewValueService
 4{
 5    private bool _isUnderTest;
 6    private Guid _testGuid;
 7    private DateTime _testDateTime;
 8
 9    public NewValueService(bool isUnderTest = false)
 10    {
 111        _isUnderTest = isUnderTest;
 112    }
 13
 14    public void SetTestGuid(Guid guidValue)
 15    {
 116        _testGuid = guidValue;
 117    }
 18
 19    public void SetTestDateTime(DateTime dateTimeValue)
 20    {
 121        _testDateTime = dateTimeValue;
 122    }
 23
 24    public Guid NewGuid()
 25    {
 126        if (!_isUnderTest)
 27        {
 028            return Guid.NewGuid();
 29        }
 30
 131        return _testGuid;
 32    }
 33
 34    public DateTime NewUtcNow()
 35    {
 136        if (!_isUnderTest)
 37        {
 038            return DateTime.UtcNow;
 39        }
 40
 141        return _testDateTime;
 42    }
 43
 44    public DateOnly NewDateOnly()
 45    {
 046        if (!_isUnderTest)
 47        {
 048            return DateOnly.FromDateTime(DateTime.UtcNow);
 49        }
 50
 051        return DateOnly.FromDateTime(_testDateTime);
 52    }
 53}