public async Task And_All_Fields_Valid_Then_Valid() { var validator = new CacheReservationStartDateCommandValidator(); var command = new CacheReservationStartDateCommand { Id = Guid.NewGuid(), TrainingDate = new TrainingDateModel { StartDate = DateTime.Now } }; var result = await validator.ValidateAsync(command); result.IsValid().Should().BeTrue(); }
public async Task And_No_Training_Date_Then_Invalid() { var validator = new CacheReservationStartDateCommandValidator(); var command = new CacheReservationStartDateCommand { Id = Guid.NewGuid() }; var result = await validator.ValidateAsync(command); result.IsValid().Should().BeFalse(); result.ValidationDictionary.Count.Should().Be(1); result.ValidationDictionary .Should().ContainKey(nameof(CacheReservationStartDateCommand.TrainingDate)) .WhichValue.Should().Be($"{nameof(CacheReservationStartDateCommand.TrainingDate)} has not been supplied"); }
public async Task And_No_Id_Then_Invalid() { var validator = new CacheReservationStartDateCommandValidator(); var command = new CacheReservationStartDateCommand { TrainingDate = new TrainingDateModel { StartDate = DateTime.Now } }; var result = await validator.ValidateAsync(command); result.IsValid().Should().BeFalse(); result.ValidationDictionary.Count.Should().Be(1); result.ValidationDictionary .Should().ContainKey(nameof(CacheReservationStartDateCommand.Id)) .WhichValue.Should().Be($"{nameof(CacheReservationStartDateCommand.Id)} has not been supplied"); }