示例#1
0
        public async Task SubmitLoanApplication_ValidApplication_GetsSubmitted()
        {
            var operators = new InMemoryOperatorRepository(new List <Operator>
            {
                new OperatorBuilder().WithLogin("admin").Build()
            });

            var existingApplications = new InMemoryLoanApplicationRepository(new List <DomainModel.LoanApplication>());

            var handler = new SubmitLoanApplication.Handler
                          (
                new UnitOfWorkMock(),
                existingApplications,
                operators
                          );

            var validApplication = new LoanApplicationDto
            {
                CustomerNationalIdentifier = "11111111119",
                CustomerFirstName          = "Frank",
                CustomerLastName           = "Oz",
                CustomerBirthdate          = SysTime.Now().AddYears(-25),
                CustomerMonthlyIncome      = 10_000M,
                CustomerAddress            = new AddressDto
                {
                    Country = "PL",
                    City    = "Warsaw",
                    Street  = "Chłodna 52",
                    ZipCode = "00-121"
                },
                PropertyValue   = 320_000M,
                PropertyAddress = new AddressDto
                {
                    Country = "PL",
                    City    = "Warsaw",
                    Street  = "Wilcza 10",
                    ZipCode = "00-421"
                },
                LoanAmount        = 100_000M,
                LoanNumberOfYears = 25,
                InterestRate      = 1.1M
            };

            var newApplicationNumber = await handler.Handle
                                       (
                new SubmitLoanApplication.Command
            {
                LoanApplication = validApplication,
                CurrentUser     = OperatorIdentity("admin")
            },
                CancellationToken.None
                                       );

            Assert.False(string.IsNullOrWhiteSpace(newApplicationNumber));
            var createdLoanApplication = existingApplications.WithNumber(newApplicationNumber);

            Assert.NotNull(createdLoanApplication);
        }
示例#2
0
        public async Task SubmitLoanApplication_InvalidApplication_IsNotSaved()
        {
            var operators = new InMemoryOperatorRepository(new List <Operator>
            {
                new OperatorBuilder().WithLogin("admin").Build()
            });

            var existingApplications = new InMemoryLoanApplicationRepository(new List <DomainModel.LoanApplication>());

            var handler = new SubmitLoanApplication.Handler
                          (
                new UnitOfWorkMock(),
                existingApplications,
                operators
                          );

            var validApplication = new LoanApplicationDto
            {
                CustomerNationalIdentifier = "11111111119111",
                CustomerFirstName          = "Frank",
                CustomerLastName           = "Oz",
                CustomerBirthdate          = SysTime.Now().AddYears(-25),
                CustomerMonthlyIncome      = 10_000M,
                CustomerAddress            = new AddressDto
                {
                    Country = "PL",
                    City    = "Warsaw",
                    Street  = "Chłodna 52",
                    ZipCode = "00-121"
                },
                PropertyValue   = 320_000M,
                PropertyAddress = new AddressDto
                {
                    Country = "PL",
                    City    = "Warsaw",
                    Street  = "Wilcza 10",
                    ZipCode = "00-421"
                },
                LoanAmount        = 100_000M,
                LoanNumberOfYears = 25,
                InterestRate      = 1.1M
            };

            var ex = await Assert.ThrowsAsync <ArgumentException>(() => handler.Handle
                                                                  (
                                                                      new SubmitLoanApplication.Command
            {
                LoanApplication = validApplication,
                CurrentUser     = OperatorIdentity("admin")
            },
                                                                      CancellationToken.None
                                                                  ));

            Assert.Equal("National Identifier must be 11 chars long", ex.Message);
        }
示例#3
0
        public void LoanApplicationSubmissionService_InvalidApplication_IsNotSaved()
        {
            var operators = new InMemoryOperatorRepository(new List <Operator>
            {
                new OperatorBuilder().WithLogin("admin").Build()
            });

            var existingApplications = new InMemoryLoanApplicationRepository(new List <LoanApplication>());

            var loanApplicationSubmissionService = new LoanApplicationSubmissionService
                                                   (
                new UnitOfWorkMock(),
                existingApplications,
                operators
                                                   );

            var validApplication = new LoanApplicationDto
            {
                CustomerNationalIdentifier = "11111111119111",
                CustomerFirstName          = "Frank",
                CustomerLastName           = "Oz",
                CustomerBirthdate          = SysTime.Now().AddYears(-25),
                CustomerMonthlyIncome      = 10_000M,
                CustomerAddress            = new AddressDto
                {
                    Country = "PL",
                    City    = "Warsaw",
                    Street  = "Chłodna 52",
                    ZipCode = "00-121"
                },
                PropertyValue   = 320_000M,
                PropertyAddress = new AddressDto
                {
                    Country = "PL",
                    City    = "Warsaw",
                    Street  = "Wilcza 10",
                    ZipCode = "00-421"
                },
                LoanAmount        = 100_000M,
                LoanNumberOfYears = 25,
                InterestRate      = 1.1M
            };

            var ex = Assert.Throws <ArgumentException>(() => loanApplicationSubmissionService
                                                       .SubmitLoanApplication(validApplication, OperatorIdentity("admin")));

            Assert.Equal("National Identifier must be 11 chars long", ex.Message);
        }