Example #1
0
        public async Task NotifyCustomer(CustomerLoanQuote customerLoanQuote)
        {
            if (customerLoanQuote == null)
            {
                throw new ArgumentNullException($"{nameof(customerLoanQuote)} is null!");
            }

            if (customerLoanQuote?.Quotes == null)
            {
                throw new ArgumentNullException($"{nameof(CustomerLoanQuote.Quotes)} is null!");
            }

            logger.Information("Retrieving customer information from the database...");
            var customerInfo = await customerRepository.CustomerByBSN(customerLoanQuote.BSN);

            await notificationService.Notify(customerInfo.Email, JsonConvert.SerializeObject(customerLoanQuote.Quotes));
        }
        public async void When_Valid_CustomerLoanQuote_Is_Sent_Notifier_Sends_Message_To_Customer()
        {
            ICustomerNotifierFilter notifier = new CustomerNotifierFilter(
                new MockNotificationService(),
                new MockCustomerRepository2(),
                MockLogger());
            var quotesFromBanks = new LoanQuote[]
            {
                new LoanQuote
                {
                    ApprovableAmount = 90.0m,
                    Bank             = "ABN Amro"
                },
                new LoanQuote
                {
                    ApprovableAmount = 40.0m,
                    Bank             = "ING Vysya"
                }
            };

            var loanQuote = new CustomerLoanQuote
            {
                BSN = "12345",
                OriginalAmountRequested = 100.0m,
                Quotes = quotesFromBanks
            };

            await notifier.NotifyCustomer(loanQuote);

            MockNotificationService
            .SENT_MESSAGE
            .Should()
            .NotBeNull();
            MockNotificationService
            .SENT_MESSAGE
            .Should()
            .Be(
                JsonConvert
                .SerializeObject(
                    quotesFromBanks));
        }