public void ReturnsCorrectErrorWhenEndDateTimeIsLessThanStartDateTime() { var validator = new EventEditModelValidator(); var parentCampaign = new CampaignSummaryViewModel { EndDate = new DateTimeOffset(new DateTime(1999, 2, 1)) }; var model = new EventEditViewModel { StartDateTime = new DateTimeOffset(new DateTime(2000, 1, 1)), EndDateTime = new DateTimeOffset(new DateTime(1999, 1, 1)) }; var errors = validator.Validate(model, parentCampaign); Assert.True(errors.Exists(x => x.Key.Equals("EndDateTime"))); Assert.Equal(errors.Find(x => x.Key == "EndDateTime").Value, "End date cannot be earlier than the start date"); }
public void RetrunsCorrectErrorWhenModelsEndDateTimeIsGreaterThanParentCampaignsEndDate() { var validator = new EventEditModelValidator(); var parentCampaign = new CampaignSummaryViewModel { StartDate = new DateTimeOffset(new DateTime(2000, 1, 1)), EndDate = new DateTimeOffset(new DateTime(2001, 1, 1)) }; var model = new EventEditViewModel { StartDateTime = new DateTimeOffset(new DateTime(2001, 1, 1)), EndDateTime = new DateTimeOffset(new DateTime(2001, 2, 1)), }; var errors = validator.Validate(model, parentCampaign); Assert.True(errors.Exists(x => x.Key.Equals("EndDateTime"))); Assert.Equal(errors.Find(x => x.Key == "EndDateTime").Value, "End date cannot be later than the campaign end date " + parentCampaign.EndDate.ToString("d")); }