コード例 #1
0
        public void Rate_WhenBMWWithDeductibleLessThan500_SetRatingTo1000()
        {
            var policy = new Policy {
                Type = PolicyType.Auto, Make = "BMW", Deductible = 250
            };
            var autoPolicyRater = new AutoPolicyRater(new Mock <ILogger>().Object);

            var result = autoPolicyRater.Rate(policy);

            Assert.That(result, Is.EqualTo(1000));
        }
コード例 #2
0
        public void Rate_WhenGivenPolicyWithoutMake_LogMakeRequiredMessage()
        {
            var policy = new Policy {
                Type = PolicyType.Auto
            };
            var logger          = new Mock <ILogger>();
            var autoPolicyRater = new AutoPolicyRater(logger.Object);

            autoPolicyRater.Rate(policy);

            logger.Verify(l => l.Log("Auto policy must specify Make"));
        }
コード例 #3
0
        public void LogsMakeRequiredMessageGivenPolicyWithoutMake()
        {
            var policy = new Policy()
            {
                Type = "Auto"
            };
            var logger = new FakeLogger();
            var rater  = new AutoPolicyRater(null);

            rater.Logger = logger;
            rater.Rate(policy);
            Assert.Equal("Auto policy must specify Make", logger.LoggedMessages.Last());
        }
コード例 #4
0
        public void SetsRatingTo1000forBMWWith250Deductible()
        {
            var policy = new Policy()
            {
                Type       = PolicyType.Auto,
                Make       = "BMW",
                Deductible = 250m
            };
            var ratingUpdater = new FakeRatingUpdater();
            var rater         = new AutoPolicyRater(ratingUpdater);

            rater.Rate(policy);
            Assert.Equal(1000m, ratingUpdater.NewRating.Value);
        }
コード例 #5
0
        public void SetRatingTo1000ForBMWWith250Deductible()
        {
            var policy = new Policy()
            {
                Type       = PolicyType.Auto,
                Make       = "BMW",
                Deductible = 250m
            };
            var rater = new AutoPolicyRater(_logger);

            decimal rating = rater.Rate(policy);

            Assert.Equal(1000m, rating);
        }
コード例 #6
0
        public void LogMakeRequiredMessageGivenPolicyWithoutMake()
        {
            var policy = new Policy {
                Type = PolicyType.Auto
            };
            var logger = new FakeLogger();//use Moq instead of dummy implementations
            var rater  = new AutoPolicyRater(null);

            rater.Logger = logger;

            rater.Rate(policy);

            Assert.Equal("Auto policy must specify Make", logger.LoggedMessages.Last());
        }
コード例 #7
0
        public void SetsRatingTo900ForBMWWith500Deductible()
        {
            var policy = new Policy()
            {
                Type       = "Auto",
                Make       = "BMW",
                Deductible = 500m
            };
            var ratingUpdater = new FakeRatingUpdater();
            var rater         = new AutoPolicyRater(ratingUpdater);

            rater.Rate(policy);

            Assert.Equal(900m, ratingUpdater.NewRating.Value);
        }
コード例 #8
0
        public void LogsMakeRequiredMessageGivenPolicyWithoutMakeMoq()
        {
            var mock = new Mock <ILogger>();

            var policy = new Policy()
            {
                Type = "Auto"
            };
            //var logger = new FakeLogger();
            var rater = new AutoPolicyRater(null);

            rater.Logger = mock.Object;
            rater.Rate(policy);
            mock.Verify(m => m.Log("Auto policy must specify Make"), Times.Once());
        }
コード例 #9
0
        public void SetsRatingTo900ForBMWWith500Deductible()
        {
            var policy = new Policy()
            {
                Type       = "Auto",
                Make       = "BMW",
                Deductible = 500m
            };
            var logger = new FakeLogger();
            var rater  = new AutoPolicyRater(logger);

            var result = rater.Rate(policy);

            Assert.Equal(900m, result);
        }
コード例 #10
0
        public void SetsRatingTo1000ForBMWWith250Deductible()
        {
            var policy = new Policy()
            {
                Type       = "Auto",
                Make       = "BMW",
                Deductible = 250m
            };

            var logger = new FakeLogger();
            var rater  = new AutoPolicyRater(logger);

            rater.Rate(policy);

            Assert.Equal(1000m, );
        }
コード例 #11
0
        public void SetRatingTo1000ForBMWWith250DeductibleMoq()
        {
            var policy = new Policy()
            {
                Type       = "Auto",
                Make       = "BMW",
                Deductible = 250m
            };

            var moq   = new Mock <IRatingUpdater>();
            var rater = new AutoPolicyRater(moq.Object);

            rater.Rate(policy);

            moq.Verify(moq => moq.UpdateRating(1000m), Times.Once());
        }
コード例 #12
0
        public void SetsRatingTo1000ForBMWWith250Deductible()
        {
            //Given
            var policy = new Policy()
            {
                Type       = "Auto",
                Make       = "BMW",
                Deductible = 250m
            };
            var logger = new FakeLogger();
            var rater  = new AutoPolicyRater(logger);

            //When
            var result = rater.Rate(policy);

            //Then
            Assert.Equal(1000m, result);
        }