public void The_total_is_the_total_price_of_multiple_scanned_items()
        {
            var unit = new Checkout(_itemCatalogue, _discounts);

            _basket.TakeItem().Returns(_item1, _item2, null);
            _itemCatalogue.LookupPrice(_item1).Returns(_item1Price);
            _itemCatalogue.LookupPrice(_item2).Returns(_item2Price);
            _discounts.GetApplicable(Arg.Any <Collection <IPurchaseable> >()).Returns(new Discount(0));

            unit.Scan(_basket);

            var expected = _item1Price.AsCurrency() + _item2Price.AsCurrency();

            Assert.That(unit.GetTotal().AsCurrency(), Is.EqualTo(expected));
        }
Exemplo n.º 2
0
        public void It_can_add_a_discount()
        {
            var unit          = new Price(100);
            var discount      = new Discount(50);
            var expectedPrice = unit.AsCurrency() + discount.InCurrency();

            var actualPrice = unit.Add(discount);

            Assert.That(actualPrice.AsCurrency(), Is.EqualTo(expectedPrice));
        }
Exemplo n.º 3
0
        public void It_can_add_another_Price()
        {
            var unit          = new Price(100);
            var other         = new Price(200);
            var expectedPrice = unit.AsCurrency() + other.AsCurrency();

            var actualPrice = unit.Add(other);

            Assert.That(actualPrice.AsCurrency(), Is.EqualTo(expectedPrice));
        }
Exemplo n.º 4
0
        public void It_can_be_read_in_pounds_and_pence()
        {
            var unit = new Price(159);

            Assert.That(unit.AsCurrency(), Is.EqualTo(1.59));
        }
Exemplo n.º 5
0
        public void It_is_initially_zero()
        {
            var unit = new Price();

            Assert.That(unit.AsCurrency(), Is.EqualTo(0));
        }
 private void ThenTheTotalShouldBe(double expectedTotal)
 {
     Assert.That(_total.AsCurrency(), Is.EqualTo(expectedTotal));
 }