Example #1
0
        public void ShouldCombineSpecialInstructions()
        {
            var e = new MockEntree(0, 0);

            e.AddInstruction("Entree instruction");
            var s = new MockSide(0, 0);

            s.AddInstruction("Side instruction");
            var d = new MockDrink(0, 0);

            d.AddInstruction("Drink instruction");
            var c = new Combo()
            {
                Entree = e,
                Side   = s,
                Drink  = d
            };

            Assert.Equal(6, c.SpecialInstructions.Count);
            Assert.Collection(c.SpecialInstructions,
                              item => Assert.Equal("Mock Entree", item),
                              item => Assert.Equal(" - Entree instruction", item),
                              item => Assert.Equal("Mock Side", item),
                              item => Assert.Equal(" - Side instruction", item),
                              item => Assert.Equal("Mock Drink", item),
                              item => Assert.Equal(" - Drink instruction", item)
                              );
        }
Example #2
0
        public void CanSetDrink()
        {
            var d = new MockDrink(0, 0);
            var c = new Combo();

            c.Drink = d;
            Assert.Equal(d, c.Drink);
        }
Example #3
0
        public void ShouldNotifySpecialInstructionsChangedWhenDrinkSpecialInstructionsChanged()
        {
            var c = new Combo();
            var d = new MockDrink(0, 0);

            c.Drink = d;
            Assert.PropertyChanged(c, nameof(Combo.SpecialInstructions), () =>
            {
                d.AddInstruction("Test");
            });
        }
Example #4
0
        public void ShouldNotifyCaloriesChangedWhenDrinkCaloriesChanged()
        {
            var c = new Combo();
            var d = new MockDrink(0, 0);

            c.Drink = d;
            Assert.PropertyChanged(c, nameof(Combo.Calories), () =>
            {
                d.SetCalories(100);
            });
        }
Example #5
0
        public void ShouldNotifyPriceChangedWhenDrinkPriceChanged()
        {
            var c = new Combo();
            var d = new MockDrink(0, 0);

            c.Drink = d;
            Assert.PropertyChanged(c, nameof(Combo.Price), () =>
            {
                d.SetPrice(1.00);
            });
        }
Example #6
0
        public void RemovingItemTriggersPropertyChanged(string property)
        {
            Order o = new Order();
            MockDrink md = new MockDrink();
            o.Add(md);

            Assert.PropertyChanged(o, property, () =>
            {
                o.Remove(md);
            });
        }//end test
Example #7
0
        public void AddingItemToOrderAddsItem()
        {
            Order o = new Order();

            MockEntree me = new MockEntree();
            MockSide ms = new MockSide();
            MockDrink md = new MockDrink();

            o.Add(me);
            o.Add(ms);
            o.Add(md);

            Assert.Contains(me, o);
            Assert.Contains(ms, o);
            Assert.Contains(md, o);
        }//end test
Example #8
0
        public void RemovingItemFromOrderRemovesItem()
        {
            Order o = new Order();

            MockEntree me = new MockEntree();
            MockSide ms = new MockSide();
            MockDrink md = new MockDrink();

            o.Add(me);
            o.Add(ms);
            o.Add(md);

            o.Remove(me);
            o.Remove(ms);
            o.Remove(md);

            Assert.DoesNotContain(me, o);
            Assert.DoesNotContain(ms, o);
            Assert.DoesNotContain(md, o);
        }//end test
        public void ShouldCorrectlyGenerateReciept()
        {
            var order  = new Order();
            var entree = new MockEntree(5.00, 100);
            var drink  = new MockDrink(1.00, 600);

            drink.AddInstruction("Hold ice");
            order.Add(entree);
            order.Add(drink);

            // Card paid reciept
            var reciept = RecieptGenerator.GenerateReciept(order, false);

            Assert.Collection(reciept,
                              item => Assert.Contains("Order ", item),
                              item => Assert.Contains("Submitted at ", item),
                              item => Assert.Equal("Mock Entree - $5.00", item),
                              item => Assert.Equal("Mock Drink - $1.00", item),
                              item => Assert.Equal("Hold ice", item),
                              item => Assert.Equal("Subtotal: $6.00", item),
                              item => Assert.Equal("Tax: $0.72", item),
                              item => Assert.Equal("Total: $6.72", item),
                              item => Assert.Equal("Paid with card", item)
                              );

            // Cash paid reciept
            reciept = RecieptGenerator.GenerateReciept(order, true, 2.00);
            Assert.Collection(reciept,
                              item => Assert.Contains("Order ", item),
                              item => Assert.Contains("Submitted at ", item),
                              item => Assert.Equal("Mock Entree - $5.00", item),
                              item => Assert.Equal("Mock Drink - $1.00", item),
                              item => Assert.Equal("Hold ice", item),
                              item => Assert.Equal("Subtotal: $6.00", item),
                              item => Assert.Equal("Tax: $0.72", item),
                              item => Assert.Equal("Total: $6.72", item),
                              item => Assert.Equal("Paid with cash", item),
                              item => Assert.Equal("Change owed: $2.00", item)
                              );
        }