コード例 #1
0
        public void It_should_correctly_set_max_loan_amount(int scoringValue, int maxLoanAmountValue)
        {
            // Given
            var loanOffer = new LoanOfferBuilder().Build();
            var score     = new Score(scoringValue);
            var expectedMaxLoanAmountValue = new LoanAmount(maxLoanAmountValue);

            // When
            loanOffer.CalculateOffer(score);

            // Then
            loanOffer.MaxLoanAmount.Value.IsSameOrEqualTo(expectedMaxLoanAmountValue.Value);
        }
コード例 #2
0
        public void It_should_throw_exception_for_greater_value_than_max_amount()
        {
            // Given
            var maxLoanAmount       = new LoanAmount(MaxLoanAmountValue);
            var requestedLoanAmount = new LoanAmount(MaxLoanAmountValue + 100);
            var loanOffer           = new LoanOfferBuilder().WithMaxLoanAmount(maxLoanAmount).Build();

            // When
            var action = new Action(() => loanOffer.SetRequestedLoanAmount(requestedLoanAmount));

            // Then
            action.Should().Throw <RequestedLoanAmountIsGreaterThanMaxLoanAmountException>();
        }
コード例 #3
0
        public void It_should_correctly_set_for_not_greater_value_than_max_amount()
        {
            // Given
            var maxLoanAmount       = new LoanAmount(MaxLoanAmountValue);
            var requestedLoanAmount = new LoanAmount(MaxLoanAmountValue - 100);
            var loanOffer           = new LoanOfferBuilder().WithMaxLoanAmount(maxLoanAmount).Build();

            // When
            loanOffer.SetRequestedLoanAmount(requestedLoanAmount);

            // Then
            loanOffer.RequestedLoanAmount.Should().NotBeNull();
            loanOffer.RequestedLoanAmount.Value.IsSameOrEqualTo(requestedLoanAmount.Value);
        }
コード例 #4
0
        public void It_should_correctly_set_max_loan_amount_using_scoring_service(int scoringValue, int maxLoanAmountValue)
        {
            // Given
            var loanOffer                  = new LoanOfferBuilder().Build();
            var expectedScoring            = new Score(scoringValue);
            var expectedMaxLoanAmountValue = new LoanAmount(maxLoanAmountValue);
            var externalServiceMock        = new Mock <IScoringService>();

            externalServiceMock.Setup(service => service.GetScore(loanOffer.PeselNumber))
            .Returns(expectedScoring);

            // When
            loanOffer.CalculateOffer(externalServiceMock.Object);

            // Then
            externalServiceMock.Verify(service => service.GetScore(loanOffer.PeselNumber), Times.Once);
            loanOffer.MaxLoanAmount.Value.IsSameOrEqualTo(expectedMaxLoanAmountValue.Value);
        }