0

I want to write a unit test to validate a certificate that has a fixed expiration date. So I'd like to put the call to DateTime.Now to always return the same date

Theare are some way to mock DateTime.Now in xUnit projetct???

[Fact]
public void Test1()
{
  Assert.Equal(DateTime.Now, new DateTime(2004,04,04));
}
Kirk Larkin
  • 73,173
  • 13
  • 183
  • 186
Luciano Castro
  • 411
  • 4
  • 11

0 Answers0