コード例 #1
0
        public void Should_calculate_mercedes_van()
        {
            var quote   = InsuranceQuote.CreateFrom("van", "Mercedes");
            var premium = QuotationEngine.Calculate(quote);

            premium.GetCost().ShouldBe(2000);
        }
コード例 #2
0
        public void Should_calcualate_audi_van()
        {
            var quote   = InsuranceQuote.CreateFrom("van", "Audi");
            var premium = QuotationEngine.Calculate(quote);

            premium.GetCost().ShouldBe(1500);
        }
コード例 #3
0
        public void Should_calulcate_low_risk_tier_one_group()
        {
            var quote   = InsuranceQuote.CreateFrom("van", "mercedes");
            var premium = QuotationEngine.Calculate(quote);

            quote.Age = 36;

            premium.GetCost().ShouldBe(2000);
        }
コード例 #4
0
        public void should_calculate_tier_4_group()
        {
            var quote = InsuranceQuote.CreateFrom("van", "mercedes");

            quote.Age = 17;
            var premium = QuotationEngine.Calculate(quote);

            premium.GetCost().ShouldBe(10000);
        }
コード例 #5
0
        public void Should_raise_error_when_no_modules_to_handle_quote()
        {
            GivenAnInsuranceModule();
            GivenACalculationEngine();

            _insuranceModule.CanHandle(Arg.Any <InsuranceQuote>()).Returns(false);

            InsuranceQuote quote = InsuranceQuote.CreateFrom("car", "audi");

            Assert.Throws <Exception>(() => _calculationEngine.CalculatePremium(quote));
        }
コード例 #6
0
        public void should_invoke_canHandle()
        {
            GivenAnInsuranceModule();
            GivenACalculationEngine();
            GivenNoErrorHandler();

            InsuranceQuote quote = InsuranceQuote.CreateFrom("car", "audi");

            _calculationEngine.CalculatePremium(quote);

            _insuranceModule.Received().CanHandle(quote);
        }
コード例 #7
0
        public void Should_invoke_module_handler_if_can_handle()
        {
            GivenAnInsuranceModule();
            GivenACalculationEngine();
            GivenNoErrorHandler();

            _insuranceModule.CanHandle(Arg.Any <InsuranceQuote>()).Returns(true);

            InsuranceQuote quote = InsuranceQuote.CreateFrom("car", "audi");

            _calculationEngine.CalculatePremium(quote);

            _insuranceModule.Received().Handle(Arg.Any <InsuranceQuote>());
        }
コード例 #8
0
        public void Should_not_invoke_handle_if_no_relevant_module()
        {
            GivenAnInsuranceModule();
            GivenACalculationEngine();
            GivenNoErrorHandler();

            _insuranceModule.CanHandle(Arg.Any <InsuranceQuote>()).Returns(false);

            InsuranceQuote quote = InsuranceQuote.CreateFrom("car", "audi");

            _calculationEngine.CalculatePremium(quote);

            _insuranceModule.DidNotReceive().Handle(Arg.Any <InsuranceQuote>());
        }