public void Should_Not_Validate_Product_Without_Id() { var command = new UpdateProductCommand() { Name = "TESTE", Price = 1, Stock = 0 }; var result = new UpdateProductCommandValidator(command).Validate(); result.Success.Should().BeFalse(); result.Messages.FirstOrDefault().Should().Be(ProductValidationMessages.ID); }
public void Should_Not_Validate_Product_Without_Name() { var command = new UpdateProductCommand() { Id = Guid.NewGuid(), Price = 1, Stock = 0 }; var result = new UpdateProductCommandValidator(command).Validate(); result.Success.Should().BeFalse(); result.Messages.FirstOrDefault().Should().Be(ProductValidationMessages.NAME); }
public void Should__Validate_Product() { var command = new UpdateProductCommand() { Id = Guid.NewGuid(), Name = "TESTE", Price = 1, Stock = 0 }; var result = new UpdateProductCommandValidator(command).Validate(); result.Success.Should().BeTrue(); result.Messages.Any().Should().BeFalse(); }
public void Update(string name, string?description, decimal price, decimal deliveryPrice) { var command = new UpdateProductCommand { Name = name, Description = description, Price = price, DeliveryPrice = deliveryPrice }; var validator = new UpdateProductCommandValidator(); validator.ValidateAndThrow(command); Name = command.Name; Description = command.Description; Price = command.Price; DeliveryPrice = command.DeliveryPrice; }
public void Setup() { _validator = new UpdateProductCommandValidator(UnitOfWork); }
public UpdateProductCommandValidatorTest() { validator = new UpdateProductCommandValidator(); }
/// <summary> /// Returns true if ... is valid. /// </summary> /// <returns><c>true</c> if this instance is valid; otherwise, <c>false</c>.</returns> public override bool IsValid() { ValidationResult = new UpdateProductCommandValidator().Validate(this); return(ValidationResult.IsValid); }