Exemple #1
0
		public void TestFailingRuleBailsWithoutRunningRemainingRules()
		{
			var passingRule1 = getPassingRule();
			var failingRule2 = getFailingRule();
			var passingRule3 = getPassingRule();
			var customer = new Mock<ICustomer>(MockBehavior.Strict);

			var rulesProvider = new Mock<IFinancingRulesProvider>(MockBehavior.Strict);
			rulesProvider.Setup(rp => rp.GetRules(customer.Object)).Returns(new List<IFinancingEligibilityRule> 
			{ 
				passingRule1.Object,
				failingRule2.Object,
				passingRule3.Object,
			});

			var runner = new FinancingEligibilityDetector(rulesProvider.Object);
			var eligibility = runner.GetEligibility(customer.Object);
			passingRule1.Verify();
			failingRule2.Verify();
			passingRule3.Verify(r => r.Eligibility(), Times.Exactly(0));

			Assert.IsFalse(eligibility.IsEligible);
		}
Exemple #2
0
		public void TestEligibleCustomerHitsAllRules()
		{
			var passingRule1 = getPassingRule();
			var passingRule2 = getPassingRule();
			var passingRule3 = getPassingRule();
			var customer = new Mock<ICustomer>(MockBehavior.Strict);

			var rulesProvider = new Mock<IFinancingRulesProvider>(MockBehavior.Strict);
			rulesProvider.Setup(rp => rp.GetRules(customer.Object)).Returns(new List<IFinancingEligibilityRule> 
			{ 
				passingRule1.Object,
				passingRule2.Object,
				passingRule3.Object,
			});

			var runner = new FinancingEligibilityDetector(rulesProvider.Object);
			var eligibility = runner.GetEligibility(customer.Object);
			passingRule1.Verify();
			passingRule2.Verify();
			passingRule3.Verify();

			Assert.IsTrue(eligibility.IsEligible);
		}