public void AddOrderItemCommand_ValidCommand_ShouldPassWithoutErrors() { // Arrange var orderCommand = new AddOrderItemCommand(Guid.NewGuid(), Guid.NewGuid(), "Test Product", 2, 50); // Act var result = orderCommand.IsValid(); // Assert result.Should().BeTrue(); }
public void AddOrderItemCommand_ValidCommand_ShouldBeValid() { // Arrange var command = new AddOrderItemCommand(Guid.NewGuid(), Guid.NewGuid(), "order item x", 2, 100); // Act var result = command.IsValid(); // Assert Assert.True(result); }
public void AddOrderItemCommand_CommandWithQuantityAboveAllowed_ShouldShowValidationErrors() { // Arrange var orderCommand = new AddOrderItemCommand(Guid.NewGuid(), Guid.NewGuid(), "Test product", Order.MAX_PRODUCT_QUANTITY + 1, 100); // Act var result = orderCommand.IsValid(); // Assert result.Should().BeFalse(); orderCommand.ValidationResult.Errors.Any(e => e.ErrorMessage.Equals(AddOrderItemValidation.QuantityMaxErrorMessage)).Should().BeTrue(); }
public void AddOrderItemCommand_IsValidCommand_ShouldPass() { //Arrange var customerId = Guid.NewGuid(); var productId = Guid.NewGuid(); var orderCommand = new AddOrderItemCommand(customerId, productId, "Product A", 2, 100); //Act var result = orderCommand.IsValid(); //Assert Assert.True(result); }
public void AddOrderItemCommand_MaxQtyIsInvalidCommand_ShouldNotPass() { //Arrange var customerId = Guid.NewGuid(); var productId = Guid.NewGuid(); var orderCommand = new AddOrderItemCommand(customerId, productId, "Product A", Domain.Models.Order.MAX_QTY_PER_ITEM + 1, 100); //Act var result = orderCommand.IsValid(); //Assert Assert.False(result); Assert.Contains(AddOrderItemValidation.MaxQtyErrorMsg, orderCommand.ValidationResult.Errors.Select(s => s.ErrorMessage)); }
public void AddOrderItemCommand_IsInvalidCommand_ShouldNotPass() { //Arrange var orderCommand = new AddOrderItemCommand(Guid.Empty, Guid.Empty, string.Empty, 0, 0); //Act var result = orderCommand.IsValid(); //Assert Assert.False(result); Assert.Contains(AddOrderItemValidation.CustomerIdErrorMsg, orderCommand.ValidationResult.Errors.Select(s => s.ErrorMessage)); Assert.Contains(AddOrderItemValidation.ProductNameErrorMsg, orderCommand.ValidationResult.Errors.Select(s => s.ErrorMessage)); Assert.Contains(AddOrderItemValidation.ProductNameErrorMsg, orderCommand.ValidationResult.Errors.Select(s => s.ErrorMessage)); Assert.Contains(AddOrderItemValidation.MinQtyErrorMsg, orderCommand.ValidationResult.Errors.Select(s => s.ErrorMessage)); Assert.Contains(AddOrderItemValidation.PriceErrorMsg, orderCommand.ValidationResult.Errors.Select(s => s.ErrorMessage)); }
public void AddOrderItemCommand_InvalidCommand_ShouldShowValidationErrors() { // Arrange var orderCommand = new AddOrderItemCommand(Guid.Empty, Guid.Empty, "", 0, 0); // Act var result = orderCommand.IsValid(); // Assert result.Should().BeFalse(); orderCommand.ValidationResult.Errors.Any(e => e.ErrorMessage.Equals(AddOrderItemValidation.ClientIdErrorMessage)).Should().BeTrue(); orderCommand.ValidationResult.Errors.Any(e => e.ErrorMessage.Equals(AddOrderItemValidation.ProductIdErrorMessage)).Should().BeTrue(); orderCommand.ValidationResult.Errors.Any(e => e.ErrorMessage.Equals(AddOrderItemValidation.ProductNameErrorMessage)).Should().BeTrue(); orderCommand.ValidationResult.Errors.Any(e => e.ErrorMessage.Equals(AddOrderItemValidation.QuantityMinErrorMessage)).Should().BeTrue(); orderCommand.ValidationResult.Errors.Any(e => e.ErrorMessage.Equals(AddOrderItemValidation.ValueErrorMessage)).Should().BeTrue(); }
public void AddOrderItemCommand_InvalidCommand_ShouldBeValid() { // Arrange var command = new AddOrderItemCommand(Guid.Empty, Guid.Empty, "", 0, 0); // Act var result = command.IsValid(); // Assert Assert.False(result); Assert.Contains(AddOrderItemCommandValidation.IdClienteErroMsg, command.ValidationResult.Errors.Select(c => c.ErrorMessage)); Assert.Contains(AddOrderItemCommandValidation.IdProdutoErroMsg, command.ValidationResult.Errors.Select(c => c.ErrorMessage)); Assert.Contains(AddOrderItemCommandValidation.NomeErroMsg, command.ValidationResult.Errors.Select(c => c.ErrorMessage)); Assert.Contains(AddOrderItemCommandValidation.QtdMinErroMsg, command.ValidationResult.Errors.Select(c => c.ErrorMessage)); Assert.Contains(AddOrderItemCommandValidation.ValorErroMsg, command.ValidationResult.Errors.Select(c => c.ErrorMessage)); }