public void IsApplication_Should_Return_False_For_Other_Product()
        {
            var rule    = new BookProductRule();
            var product = new Product {
                Type = ProductType.Membership
            };

            rule.IsApplicable(product).Should().BeFalse();
        }
        public void IsApplication_Should_Return_True_For_Book_Product()
        {
            var rule    = new BookProductRule();
            var product = new Product {
                Type = ProductType.Book
            };

            rule.IsApplicable(product).Should().BeTrue();
            rule.Apply().Should().Be("Creating a duplicate packing slip for the royalty department");
        }
Esempio n. 3
0
        public void Book_Product_Rule_Test()
        {
            IBussinessRuleEngine businessEngine = new BusinessRuleEngine();
            var rule = new BookProductRule();

            businessEngine.AddRule(rule);
            var agent = new Agent {
                Name = "Test"
            };
            var product = new Product
            {
                Attribute = ProductAttribute.PHYSICAL,
                Id        = 1,
                Type      = ProductType.Book,
                Name      = "Hitchhiker's Guide to the Galaxy"
            };

            var orderEngine = new OrderProcessor(businessEngine, agent);

            orderEngine.Add(new OrderLine(product, 1));
            orderEngine.Process().Single().Should().Be("Creating a duplicate packing slip for the royalty department");
        }