Esempio n. 1
0
        public void GivenCustomerWhenCustomerIsPresentThenReturnCreditCharge()
        {
            // Arrange
            var mockPremiumCalculator = new Mock <IPremiumCalculator>();

            mockPremiumCalculator.Setup(c => c.CalculateCreditCharge(It.IsAny <decimal>())).Returns(2.5M);
            var mockCustomer             = this.GetCustomerMock();
            var premiumCalculatorBuilder = new PremiumCalculatorBuilder(mockPremiumCalculator.Object);

            premiumCalculatorBuilder.SetCustomer(mockCustomer);

            // Act
            premiumCalculatorBuilder.CalculateCreditCharge();

            // Assert
            mockPremiumCalculator.Verify(c => c.CalculateCreditCharge(It.IsAny <decimal>()), Times.Once);
            Assert.AreEqual(2.5M, mockCustomer.CreditCharge);
        }