public async Task Edit_character_command_validator_should_pass() { // Arrange var episode = new EpisodeBuilder().Generate().SaveChanges(_testFixture.Context).Build().First(); var characterToUpdate = new CharacterBuilder().Generate().SaveChanges(_testFixture.Context).Build().First(); var command = new EditCharacterCommand { Id = characterToUpdate.Id, Name = characterToUpdate.Name, EpisodesIds = new[] { episode.Id }, FriendsIds = new int[] { } }; var validator = new EditCharacterCommandValidator(_testFixture.Context); // Act var validationResult = await validator.ValidateAsync(command); // Assert validationResult.Errors.ShouldBeEmpty(); }
public async Task Edit_character_command_validator_should_return_no_episodes_validation_error() { // Arrange var episode = new EpisodeBuilder().Generate().SaveChanges(_testFixture.Context).Build().First(); var characterToUpdate = new CharacterBuilder().Generate().SaveChanges(_testFixture.Context).Build().First(); var command = new EditCharacterCommand { Id = characterToUpdate.Id, Name = characterToUpdate.Name, EpisodesIds = new [] { episode.Id + 1 }, FriendsIds = new int[] {} }; var validator = new EditCharacterCommandValidator(_testFixture.Context); // Act var validationResult = await validator.ValidateAsync(command); // Assert validationResult.Errors.Count.ShouldBe(1); validationResult.Errors.First().ErrorCode.ShouldBe("PredicateValidator"); validationResult.Errors.First().ErrorMessage.ShouldBe("Character has to star in at least one episode"); }