Ejemplo n.º 1
0
        public void WhenAddingNullRuleThenExceptionIsThrown()
        {
            var pipeline = new TestPromotionPipeline();

            Assert.Throws <ArgumentNullException>(() =>
            {
                pipeline.AddRule(null);
            });
        }
Ejemplo n.º 2
0
        public void RulesAreExecutedInOrder()
        {
            var testContext = new TestContext();

            var pipeline = new TestPromotionPipeline();
            var ruleA    = new PromotionRuleA();
            var ruleB    = new PromotionRuleB();

            pipeline.AddRule(ruleA);
            pipeline.AddRule(ruleB);

            pipeline.Apply(testContext.CartFactory.Create());

            Assert.True(pipeline.RunHistory.Any());
            Assert.Equal(2, pipeline.RunHistory.Count);
            Assert.True((object)pipeline.RunHistory[0] == (object)ruleA);
            Assert.True((object)pipeline.RunHistory[1] == (object)ruleB);
        }