Inheritance: IProduct
Ejemplo n.º 1
0
        public void DifferentPartsOfTheListCanBeConstructedDifferently()
        {
            var basket1 = new ShoppingBasket();
            var product1 = new Product();
            const int quantity1 = 5;

            var basket2 = new ShoppingBasket();
            var product2 = new Product();
            const int quantity2 = 7;

            var items = Builder<BasketItem>
                .CreateListOfSize(4)
                .TheFirst(2)
                    .AreConstructedWith(basket1, product1, quantity1)
                .TheNext(2)
                    .AreConstructedWith(basket2, product2, quantity2)
                .Build();

            Assert.That(items[0].Basket, Is.EqualTo(basket1));
            Assert.That(items[0].Basket, Is.EqualTo(basket1));
            Assert.That(items[0].Basket, Is.EqualTo(basket1));
            Assert.That(items[0].Basket, Is.EqualTo(basket1));
            Assert.That(items[0].Basket, Is.EqualTo(basket1));
            Assert.That(items[0].Basket, Is.EqualTo(basket1));
        }
Ejemplo n.º 2
0
 public BasketItem(ShoppingBasket basket, Product product, int quantity)
     : this(basket)
 {
     Product = product;
     Quantity = quantity;
 }
Ejemplo n.º 3
0
 public void Add(Product product, int quantity)
 {
     var item = new BasketItem(this, product, quantity);
     Items.Add(item);
 }
Ejemplo n.º 4
0
        public void DifferentPartsOfTheListCanBeConstructedDifferently()
        {
            var builderSetup = new BuilderSettings();
            var basket1 = new ShoppingBasket();
            var product1 = new Product();
            const int quantity1 = 5;

            var basket2 = new ShoppingBasket();
            var product2 = new Product();
            const int quantity2 = 7;

            var items = new Builder(builderSetup)
                .CreateListOfSize<BasketItem>(4)
                .TheFirst(2)
                    .WithConstructor(() => new BasketItem(basket1, product1, quantity1))
                .TheNext(2)
                    .WithConstructor(() => new BasketItem(basket2, product2, quantity2))
                .Build();

            Assert.That(items[0].Basket, Is.EqualTo(basket1));
            Assert.That(items[0].Basket, Is.EqualTo(basket1));
            Assert.That(items[0].Basket, Is.EqualTo(basket1));
            Assert.That(items[0].Basket, Is.EqualTo(basket1));
            Assert.That(items[0].Basket, Is.EqualTo(basket1));
            Assert.That(items[0].Basket, Is.EqualTo(basket1));
        }