Пример #1
0
        public void CheckRunningTotalForBasketWithItems()
        {
            //Arrange
            var view = new MockedCheckOutView();
            var presenter = new CheckOutPresenter(view, new MockedCheckOutRepository());

            //Act
            presenter.GetRunningTotal();

            //Assert
            Assert.AreEqual(8.95m, view.RunningTotal);
        }
Пример #2
0
        public void CheckListContainsItems()
        {
            //Arrange
            var view = new MockedCheckOutView();
            var presenter = new CheckOutPresenter(view, new MockedCheckOutRepository());

            //Act
            presenter.GetItemsOrderedByPrice();

             //Assert
            Assert.IsTrue(view.CheckoutItems.Count > 0);
        }
Пример #3
0
        public void CheckListIsOrderedByPrice()
        {
            //Arrange
            var view = new MockedCheckOutView();
            var presenter = new CheckOutPresenter(view, new MockedCheckOutRepository());

            //Act
            presenter.GetItemsOrderedByPrice();

            //Assert
            Assert.IsTrue(view.CheckoutItems.Count > 0);
            Assert.AreEqual(0.50m, view.CheckoutItems[0].Price);
            Assert.AreEqual(1.50m, view.CheckoutItems[1].Price);
            Assert.AreEqual(2.75m, view.CheckoutItems[2].Price);
            Assert.AreEqual(4.20m, view.CheckoutItems[3].Price);
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Create the presenter and pass in the view (this) and our repository. (Fake DB layer)
            var presenter = new CheckOutPresenter(this, new CheckoutRepository());

            // Use Presenter to get the Ordered list.
            // This binds the results to the view property 'CheckoutItems'
            presenter.GetItemsOrderedByPrice();

            CheckoutList.DataSource = CheckoutItems;
            CheckoutList.DataTextField = "Description";
            CheckoutList.DataBind();

            // Use Presenter to get the running total.
            // This binds the results to the view property 'RunningTotal'
            presenter.GetRunningTotal();

            CheckoutTotal.Text = RunningTotal.ToString();
        }