public void ReturnsNoErrorForWhenDatesIsBetweenStartAndEndOfParentEvent() { var sut = new ItineraryEditModelValidator(); var model = new ItineraryEditViewModel { EventId = 1, Date = eventStartDate.AddDays(1).DateTime }; var errors = sut.Validate(model, TestEvent); Assert.True(errors.Count == 0); }
//this test case needs renaming, ESL alert :| public void ReturnsNoErrorForWhenDatesIsBetweenStartAndEndOfParentEventAndDateIsNotEarlierThanCurrentDateIfEventsDateIsInThePast() { var sut = new ItineraryEditModelValidator(); var model = new ItineraryEditViewModel { EventId = 1, Date = DateTimeOffset.Now.DateTime.Date }; var errors = sut.Validate(model, TestEvent); Assert.True(errors.Count == 0); }
public void ReturnsCorrectErrorWhenModelsDateIsGreaterThanParentEventEndDate() { var sut = new ItineraryEditModelValidator(); var model = new ItineraryEditViewModel { EventId = 1, Date = eventEndDate.AddDays(1).DateTime }; var errors = sut.Validate(model, TestEvent); Assert.True(errors.Exists(x => x.Key.Equals("Date"))); Assert.Equal(errors.Find(x => x.Key == "Date").Value, "Date cannot be later than the event end date " + eventEndDate.Date.ToString("d")); }
public void ReturnsCorrectErrorWhenEventStartDateIsEarlierThanTodayAndModelsDateIsEarlierThenCurrentDate() { var sut = new ItineraryEditModelValidator(); var model = new ItineraryEditViewModel { EventId = 1, Date = DateTimeOffset.Now.DateTime.AddDays(-1) }; var errors = sut.Validate(model, TestEvent); Assert.True(errors.Exists(x => x.Key.Equals("Date"))); Assert.Equal(errors.Find(x => x.Key == "Date").Value, "Date cannot be earlier than the current date if the event start date is in the past " + eventEndDate.Date.ToString("d")); }