public async Task <IActionResult> CreateShoppingList([FromBody] CreateShoppingListCommand cmd) { var result = await createShoppingListHandler.HandleAsync(cmd); if (result.IsSuccess) { return(CreatedAtAction(nameof(GetShoppingList), new { id = result.SuccessResult !.Id }, result.SuccessResult));
public static void Should_allow_valid_command() { var testCmd = new CreateShoppingListCommand() { Title = "Minha lista de compras" }; Assert.True(testCmd.Validate(out var errors)); Assert.Null(errors); }
public static void Should_not_allow_blank_title(string?title) { var testCmd = new CreateShoppingListCommand() { Title = title }; Assert.False(testCmd.Validate(out var errors)); Assert.Single(errors, new Error(ShoppingListErrors.BlankTitle)); }