public void Order_With_Composite_Of_Boxes_Should_Return_50() { //Arrange var order = new Order(); var boxhead = new BoxContainer(); // head / Container var boxLeaf = aBoxLeaf() .WithBookOfPrice(10) .Build(); var boxLeafTwo = new BoxLeaf(); boxLeafTwo.Book = new Book(price: 40);; boxhead.AddBox(boxLeaf); boxhead.AddBox(boxLeafTwo); order.BoxeHead = boxhead; //Act var result = order.Price; //Assert Assert.AreEqual(50, result); }
public void Order_With_Two_Book_And_Two_Phone_Return_130() { //Arrange var order = new Order(); var boxhead = new BoxContainer(); // head //Book Branch var boxOfBook = new BoxContainer(); var boxLeafBookOne = aBoxLeaf() .WithBookOfPrice(10) .Build(); var boxLeafBookTwo = aBoxLeaf() .WithBookOfPrice(40) .Build(); boxOfBook.AddBox(boxLeafBookOne); boxOfBook.AddBox(boxLeafBookTwo); //Phone branch var boxOfPhone = new BoxContainer(); var boxLeafPhoneOne = aBoxLeaf() .WithPhoneOfPrice(100) .Build(); var boxLeafPhoneTwo = aBoxLeaf() .WithPhoneOfPrice(400) .Build(); boxOfPhone.AddBox(boxLeafPhoneOne); boxOfPhone.AddBox(boxLeafPhoneTwo); boxhead.AddBox(boxOfBook); boxhead.AddBox(boxOfPhone); order.BoxeHead = boxhead; //Act var result = order.Price; //Assert Assert.AreEqual(550, result); }