public void MustBeInvalidGameByDescriptionError() { //Given var game = new InsertGameCommand("Super Bomberman 4", string.Empty); //Then game.IsValid().Should().BeFalse(); }
public void MustBeInvalidGameByNameError() { //Given var game = new InsertGameCommand(string.Empty, "Joguinho danado de bom."); //Then game.IsValid().Should().BeFalse(); }
public void MustBeValidGame() { //Given var game = new InsertGameCommand("Super Bomberman 4", "Joguinho danado de bom."); //Then game.IsValid().Should().BeTrue(); }
public void MustGameDescriptionExceedMaxLength() { //Given string description = string.Empty; for (int i = 0; i < 256; i++) { description += "a"; } //When var game = new InsertGameCommand("Super Bomberman 4", description); //Then game.IsValid().Should().BeFalse(); Assert.Contains("A descrição do jogo deve conter no maximo 255 caracteres.", game.ValidationResult.Errors.Select(x => x.ErrorMessage)); }
public void MustGameNameExceedMaxLength() { //Given string name = string.Empty; for (int i = 0; i < 102; i++) { name += "a"; } //When var game = new InsertGameCommand(name, "Um jogo muito bom"); //Then game.IsValid().Should().BeFalse(); Assert.Contains("O nome do jogo deve conter entre 2 a 100 caracteres.", game.ValidationResult.Errors.Select(x => x.ErrorMessage)); }
public Task <bool> Handle(InsertGameCommand command, CancellationToken cancellationToken) { if (!command.IsValid()) { NotifyValidationErrors(command); return(Task.FromResult(false)); } var game = new Game(command.Name, command.Description); gameWriteRepository.Insert(game); if (Commit()) { command.SetId(game.Id); mediator.RaiseEventAsync(new InsertGameEvent(game.Name, game.Description)); } return(Task.FromResult(true)); }