public void LogsToWeekendFileOnWeekend(int year, int month, int day) { DateTime weekendDate = new DateTime(year, month, day); var fakeDateTime = new FakeDateTime(); var logger = new FileLogger(fakeDateTime, new DefaultFileNameStrategy()); fakeDateTime.Now = weekendDate; logger.Log("foo"); // firstDate string expectedFileName = "weekend.txt"; Assert.True(File.Exists(expectedFileName)); }
public void CreateNewFileOnNewDay() { DateTime firstDate = new DateTime(2021, 03, 19, 23, 59, 59); DateTime secondDate = firstDate.AddMinutes(1); string expectedFileName = "log2021-03-20.txt"; var fakeDateTime = new FakeDateTime(); var logger = new FileLogger(fakeDateTime, new DefaultFileNameStrategy()); fakeDateTime.Now = firstDate; logger.Log("foo"); // firstDate fakeDateTime.Now = secondDate; logger.Log(_testMessage); // secondDate Assert.True(File.Exists(expectedFileName)); }