Skip to content

Commit

Permalink
NLog#3181 TimeSource ToString() tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenaw committed Oct 12, 2019
1 parent 0bfdad5 commit e3fa4d7
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/NLog.UnitTests/TimeSourceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,31 @@ public void CustomTimeSourceTest()
{
TestTimeSource(new CustomTimeSource(), DateTime.UtcNow.AddHours(1), DateTimeKind.Unspecified);
}

[Theory]
[InlineData("FastUTC", typeof(FastUtcTimeSource))]
[InlineData("FastLocal", typeof(FastLocalTimeSource))]
[InlineData("AccurateUTC", typeof(AccurateUtcTimeSource))]
[InlineData("AccurateLocal", typeof(AccurateLocalTimeSource))]
public void ToStringDefaultImplementationsTest(string expectedName, Type timeSourceType)
{
var instance = Activator.CreateInstance(timeSourceType) as TimeSource;
var actual = instance.ToString();

Assert.Equal(expectedName + " (time source)", actual);
}

[Theory]
[InlineData(typeof(CustomTimeSource))]
public void ToStringNoImplementationTest(Type timeSourceType)
{
var instance = Activator.CreateInstance(timeSourceType) as TimeSource;

var expected = timeSourceType.Name;
var actual = instance.ToString();

Assert.Equal(expected, actual);
}

class CustomTimeSource : TimeSource
{
Expand Down

0 comments on commit e3fa4d7

Please sign in to comment.