Ejemplo n.º 1
0
        public void ShouldApplyHigherDiscount()
        {
            // Arrage
            var chain = new RuleChain <ApplyDiscountContext>()
                        .Use <FakeBirthdayDiscountRule>()
                        .Use <MyNameIsLuttiDiscount>()
                        .Build();

            var context = new ApplyDiscountContext
            {
                Context = new ShoppingCart
                {
                    CilentName = "Lutti Coelho",
                    Items      = new List <ShopItem>()
                    {
                        { new ShopItem()
                          {
                              Name = "Item 1", Price = 100
                          } },
                        { new ShopItem()
                          {
                              Name = "Item 2", Price = 900
                          } }
                    },
                    ClientBirthday = new DateTime(1986, 8, 16)
                }
            };

            // Act
            context = chain.Invoke(context);

            // Assert
            context.DiscountApplied.Should().Be(500);
        }