コード例 #1
0
        public void ShouldCreateAProductCsvWhitoutDeliveredIn()
        {
            _deliveredIn = string.Empty;
            var product = new ProductCsv(_key, _artikleCode, _colorCode, _description, _price, _discountPrice, _deliveredIn, _q1, _size, _color);

            Assert.Empty(product.DeliveredIn);
        }
コード例 #2
0
        public void ShouldCreateAProductCsvWhitoutDiscountPrice()
        {
            _discountPrice = 0m;
            var product = new ProductCsv(_key, _artikleCode, _colorCode, _description, _price, _discountPrice, _deliveredIn, _q1, _size, _color);

            Assert.Equal(0m, product.DiscountPrice);
        }
コード例 #3
0
        public void ShouldParseStringToProductCsv()
        {
            var productCsvLineExpected = new ProductCsv("2800104", "2", "broek", "Gaastra", 8m, 0m, "1-3 werkdagen", "baby", 104, "grijs");

            var result = _csvParser.Parse(@"Key,ArtikelCode,ColorCode,Description,Price,DiscountPrice,DeliveredIn,Q1,Size,Color
                            2800104,2,broek,Gaastra,8,0,1-3 werkdagen,baby,104,grijs");

            Assert.Equal(productCsvLineExpected, result.First());
        }
コード例 #4
0
        public void ShouldPreventNoIndexForCategoryAttribute()
        {
            var q1 = "NOINDEX";

            _productCsv = ProductCsvBuilder.AProductCsv().WithQ1(q1).Build();

            var product = _productFactory.Create(_productCsv);

            Assert.Empty(product.Category);
        }
コード例 #5
0
        public void ShouldPreventNoIndexForDeliveredInAttribute()
        {
            var deliveredIn = "NOINDEX";

            _productCsv = ProductCsvBuilder.AProductCsv().WithDeliveredIn(deliveredIn).Build();

            var product = _productFactory.Create(_productCsv);

            Assert.Empty(product.DeliveredIn);
        }
コード例 #6
0
        public void ShouldPreventNoIndexForColorCodeAttribute()
        {
            var colorCode = "NOINDEX";

            _productCsv = ProductCsvBuilder.AProductCsv().WithColorCode(colorCode).Build();

            var product = _productFactory.Create(_productCsv);

            Assert.Empty(product.ColorCode);
        }
コード例 #7
0
        public void ShouldPreventNoIndexForKeyAttribute()
        {
            var key = "NOINDEX";

            _productCsv = ProductCsvBuilder.AProductCsv().WithKey(key).Build();

            var product = _productFactory.Create(_productCsv);

            Assert.Empty(product.Key);
        }
コード例 #8
0
        private void InitializeMocks()
        {
            _productCsv = ProductCsvBuilder.AProductCsv().Build();
            var productsCsv = new List <ProductCsv>()
            {
                _productCsv
            };

            _csvParser.Setup(x => x.Parse(_csv)).Returns(productsCsv);
            _product = ProductBuilder.AProduct().Build();

            _productFactory.Setup(x => x.Create(_productCsv)).Returns(_product);
        }
コード例 #9
0
        public void ShouldCreateAProductCsv()
        {
            var productCsvExpected = new
            {
                Key           = _key,
                ArtikleCode   = _artikleCode,
                ColorCode     = _colorCode,
                Description   = _description,
                Price         = _price,
                DiscountPrice = _discountPrice,
                DeliveredIn   = _deliveredIn,
                Q1            = _q1,
                Size          = _size,
                Color         = _color,
            };

            var productCsv = new ProductCsv(_key, _artikleCode, _colorCode, _description, _price, _discountPrice, _deliveredIn, _q1, _size, _color);

            productCsvExpected.ToExpectedObject().Matches(productCsv);
        }
コード例 #10
0
        public Product Create(ProductCsv productCsv)
        {
            if (productCsv == null)
            {
                return(null);
            }

            var key           = PreventNoIndex(productCsv.Key);
            var articleCode   = PreventNoIndex(productCsv.ArtikleCode);
            var colorCode     = PreventNoIndex(productCsv.ColorCode);
            var description   = PreventNoIndex(productCsv.Description);
            var price         = productCsv.Price;
            var discountPrice = productCsv.DiscountPrice;
            var deliveredIn   = PreventNoIndex(productCsv.DeliveredIn);
            var category      = PreventNoIndex(productCsv.Q1);
            var size          = productCsv.Size;
            var color         = PreventNoIndex(productCsv.Color);

            return(new Product(key, articleCode, colorCode, description, price, discountPrice, deliveredIn, category, size, color));
        }
コード例 #11
0
        public ProductFactoryTest()
        {
            _productCsv = ProductCsvBuilder.AProductCsv().Build();

            _productFactory = new ProductFactory();
        }