Ejemplo n.º 1
0
        public void should_add_a_variety_to_a_color_with_its_images_and_price()
        {
            var product             = _productBuilder.Build();
            var productColorOptions = new ProductColorVarietyOptions
            {
                ColorType = ColorType.Black,
                ProductDiscountPercent = 10,
                ColorImageName         = Guid.NewGuid().ToString(),
                Images = new List <string> {
                    Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString()
                },
                ProductAmount    = 1500000,
                ProductImageType = ProductImageType.Product
            };
            var productVariety = new ProductColorVariety(productColorOptions);

            product.AddProductColorVariety(productVariety);

            product.ProductColorVarieties.Should().HaveCount(1);
            product.ProductColorVarieties.Should().SatisfyRespectively(first =>
            {
                first.ProductImageType.Should().Be(productColorOptions.ProductImageType);
                first.Images.Should().Equal(productColorOptions.Images, (actual, expected) => actual.Name == expected);
                first.ColorImage.Name.Should().Be(productColorOptions.ColorImageName);
                first.ColorType.Should().Be(productColorOptions.ColorType);
                first.ProductPrice.Amount.Value.Should().Be(productColorOptions.ProductAmount);
                first.ProductPrice.DiscountAmount.Value.Should().Be(150000);
                first.ProductPrice.DiscountPercent.Should().Be(productColorOptions.ProductDiscountPercent);
                first.ProductPrice.DueAmount.Value.Should().Be(1350000);
            });
        }
        public Product BuildWithAProductVariety(ProductColorVarietyOptions productColorVarietyOptions)
        {
            var product        = new Product(ProductOptions);
            var productVariety = new ProductColorVariety(productColorVarietyOptions);

            product.AddProductColorVariety(productVariety);

            return(product);
        }
Ejemplo n.º 3
0
        public async Task Handle(CreateProductVarietyCommand command)
        {
            var product = await _repository.GetByIdAsync(command.ProductId);

            var options = new ProductColorVarietyOptions()
            {
                ColorImageName         = command.ColorImageName,
                ColorType              = (ColorType)command.ColorType,
                Images                 = command.Images,
                ProductAmount          = command.ProductAmount,
                ProductDiscountPercent = command.ProductDiscountPercent,
                ProductImageType       = (ProductImageType)command.ProductImageType
            };
            var productVariety = new ProductColorVariety(options);

            product.AddProductColorVariety(productVariety);

            _repository.Update(product);
        }
Ejemplo n.º 4
0
        public void should_throw_when_a_color_already_existed()
        {
            var productColorOptions = new ProductColorVarietyOptions
            {
                ColorType = ColorType.Black,
                ProductDiscountPercent = 10,
                ColorImageName         = Guid.NewGuid().ToString(),
                Images = new List <string> {
                    Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString()
                },
                ProductAmount    = 1500000,
                ProductImageType = ProductImageType.Product
            };

            var product        = _productBuilder.Build();
            var productVariety = new ProductColorVariety(productColorOptions);

            product.AddProductColorVariety(productVariety);

            Action addProductColor = () => product.AddProductColorVariety(productVariety);

            addProductColor.Should().Throw <DuplicateProductColorException>();
        }
Ejemplo n.º 5
0
        public void AddProductColorVariety(ProductColorVariety productColorVariety)
        {
            GuardAgainstDuplicateVariety(productColorVariety.ColorType);

            _productColorVarieties.Add(productColorVariety);
        }