Esempio 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));
        }
Esempio n. 2
0
 public BasketItem(ShoppingBasket basket)
 {
     Basket = basket;
 }
Esempio n. 3
0
 public BasketItem(ShoppingBasket basket, Product product, int quantity)
     : this(basket)
 {
     Product = product;
     Quantity = quantity;
 }
Esempio 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));
        }
Esempio n. 5
0
 public BasketItem(ShoppingBasket basket, Product product, int quantity)
     : this(basket)
 {
     Product  = product;
     Quantity = quantity;
 }
Esempio n. 6
0
 public BasketItem(ShoppingBasket basket)
 {
     Basket = basket;
 }