Add unit tests for DatetimeNotInThePast annotation.
This commit is contained in:
parent
3da48bb65f
commit
e8166dc5f8
1 changed files with 32 additions and 0 deletions
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using Retroactiune.DataAnnotations;
|
||||
using Xunit;
|
||||
|
||||
namespace Retroactiune.Tests.Retroactiune.WebAPI.DataAnnotations
|
||||
{
|
||||
public class TestDatetimeNotInThePast
|
||||
{
|
||||
[Fact]
|
||||
public void Test_DatetimeNotInThePast_NullDate()
|
||||
{
|
||||
var test = new DatetimeNotInThePast();
|
||||
Assert.True(test.IsValid(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Test_DatetimeNotInThePast_FutureDate()
|
||||
{
|
||||
var test = new DatetimeNotInThePast();
|
||||
var futureDate = DateTime.UtcNow.AddDays(1);
|
||||
Assert.True(test.IsValid(futureDate));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Test_DatetimeNotInThePast_PastDate()
|
||||
{
|
||||
var test = new DatetimeNotInThePast();
|
||||
var pastDate = DateTime.UtcNow.Subtract(new TimeSpan(1));
|
||||
Assert.False(test.IsValid(pastDate));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue