예제 #1
0
        public void IsApplication_Should_Return_False_For_Other_Product()
        {
            var rule    = new MembershipProductRule();
            var product = new Product {
                Type = ProductType.Upgrade
            };

            rule.IsApplicable(product).Should().BeFalse();
        }
예제 #2
0
        public void IsApplication_Should_Return_True_For_Membership_Product()
        {
            var rule    = new MembershipProductRule();
            var product = new Product {
                Type = ProductType.Membership
            };

            rule.IsApplicable(product).Should().BeTrue();
            rule.Apply().Should().Be("Activating membership");
        }
예제 #3
0
        public void Membership_Product_Rule_Test()
        {
            IBussinessRuleEngine businessEngine = new BusinessRuleEngine();
            var rule = new MembershipProductRule();

            businessEngine.AddRule(rule);
            var agent = new Agent {
                Name = "Test"
            };
            var product = new Product
            {
                Attribute = ProductAttribute.NONPHYSICAL,
                Id        = 1,
                Type      = ProductType.Membership,
                Name      = "5 months subscription"
            };

            var orderEngine = new OrderProcessor(businessEngine, agent);

            orderEngine.Add(new OrderLine(product, 1));
            orderEngine.Process().Single().Should().Be("Activating membership");
        }