public void If_To_property_is_null_it_is_invalid() { var sut = new TimeRange { From = new Time { Hour = new Hour(20), Minute = new Minute(6) } }; Assert.False(sut.IsValid()); Assert.Equal(sut.BrokenRules.Count(), 1); Assert.Contains("both From and To has to be configured", sut.BrokenRules.ElementAt(0)); }
public void Fullfill_returns_true_if_currentTime_is_within_the_configured_TimeRange() { var currrentTime = DateTime.Now; TimeRange timeRange = new TimeRange { From = new Time() { Hour = new Hour(currrentTime.Hour - 1), Minute = new Minute(3) }, To = new Time() { Hour = new Hour(currrentTime.Hour + 1), Minute = new Minute(4) } }; var sut = new TimeRangeQuota(timeRange); Assert.True(sut.Fullfills(1)); }
public void InRange_If_a_date_is_not_between_timeRange_returns_false() { var sut = new TimeRange { From = new Time { Hour = new Hour(20), Minute = new Minute(5) }, To = new Time { Hour = new Hour(20), Minute = new Minute(6) } }; Assert.False(sut.InRange(DateTime.Parse("2000-02-02 20:04:00"))); Assert.False(sut.InRange(DateTime.Parse("2000-02-02 20:07:00"))); }
public TimeRangeQuota(NotNullable<TimeRange> timeRange) { _timeRange = timeRange.Value; }
public void If_From_is_equal_than_To_it_is_invalid() { var sut = new TimeRange { To = new Time { Hour = new Hour(20), Minute = new Minute(6) }, From = new Time { Hour = new Hour(20), Minute = new Minute(6) } }; Assert.False(sut.IsValid()); Assert.Equal(sut.BrokenRules.Count(), 1); Assert.Contains("From has to be lower than To", sut.BrokenRules.ElementAt(0)); }