public void When_ImageIds_Are_Identical_Validator_ThrowsException(string imageId) { //Arrange var imageProvider = Mock.Of <IImageProvider>(); var validatorService = new BattleOutcomeDtoValidator(imageProvider); var battleOutcomDto = new BattleOutcomeDto { SelectedImageId = imageId, UnselectedImageId = imageId }; //Act and assert FluentActions.Invoking(() => validatorService.ValidateAndThrow(battleOutcomDto)) .Should() .Throw <ValidationException>(because: "selected and unselected image ids are identical"); }
public void When_BattleOutcomeIsValid_Validator_Does_Not_ThrowException( string selectedImageId, string unselectedImageId) { //Arrange var imageProvider = Mock.Of <IImageProvider>(imageProvider => imageProvider.DoesImageExist(selectedImageId) == Task.FromResult(true) && imageProvider.DoesImageExist(unselectedImageId) == Task.FromResult(true)); var validatorService = new BattleOutcomeDtoValidator(imageProvider); var battleOutcomDto = new BattleOutcomeDto { SelectedImageId = selectedImageId, UnselectedImageId = unselectedImageId }; //Act and assert FluentActions.Invoking(() => validatorService.ValidateAndThrow(battleOutcomDto)) .Should() .NotThrow <ValidationException>(because: "image ids are different and they both exist."); }
public void When_One_Of_ImageId_Is_Unknown_Validator_ThrowsException( bool selectedImageExists, bool unselectedImageExists, string selectedImageId, string unselectedImageId) { //Arrange var imageProvider = Mock.Of <IImageProvider>(imageProvider => imageProvider.DoesImageExist(selectedImageId) == Task.FromResult(selectedImageExists) && imageProvider.DoesImageExist(unselectedImageId) == Task.FromResult(unselectedImageExists)); var validatorService = new BattleOutcomeDtoValidator(imageProvider); var battleOutcomDto = new BattleOutcomeDto { SelectedImageId = selectedImageId, UnselectedImageId = unselectedImageId }; //Act and assert FluentActions.Invoking(() => validatorService.ValidateAndThrow(battleOutcomDto)) .Should() .Throw <ValidationException>(because: "one of the image id does not exist."); }