Esempio n. 1
0
        public void StandardLoan_Create_Succeeds()
        {
            var loan = new StandardLoan
            {
                CustomerId   = 1,
                InterestRate = 0.2,
                LoanAmount   = 10000,
                LoanStart    = DateTime.Now,
                LoanEnd      = DateTime.Now.AddYears(2)
            };

            var customer = new StandardCustomer
            {
                FirstName      = "Arnas",
                LastName       = "Danaitis",
                MonthlySalary  = 3000,
                PersonalNumber = "12345678101"
            };

            var customerLoans = new List <Loan>
            {
                new StandardLoan
                {
                    CustomerId   = 1,
                    InterestRate = 0.2,
                    LoanAmount   = 30000,
                    LoanStart    = DateTime.Now.AddYears(-1),
                    LoanEnd      = DateTime.Now.AddYears(1)
                }
            };

            Assert.True(_loanDomainService.CanCreateLoan(loan, customer, customerLoans));
        }
        public void StandardCustomer_Create_Fails()
        {
            var customer = new StandardCustomer
            {
                FirstName      = "Deividas",
                LastName       = "Brazenas",
                MonthlySalary  = 1000,
                PersonalNumber = "12345678901"
            };

            var existingCustomers = new List <Customer>
            {
                new VipCustomer
                {
                    FirstName      = "Tomas",
                    LastName       = "Drasutis",
                    MonthlySalary  = 1100,
                    PersonalNumber = "12345678101"
                },
                new StandardCustomer
                {
                    FirstName      = "Arnas",
                    LastName       = "Danaitis",
                    MonthlySalary  = 1000,
                    PersonalNumber = "12345678901"
                }
            };

            Assert.Throws <BusinessException>(() => _customerDomainService.CanCreateCustomer(customer, existingCustomers));
        }
Esempio n. 3
0
        public void StandardLoan_Create_TooManyLoans_Fails()
        {
            var loan = new StandardLoan
            {
                CustomerId   = 1,
                InterestRate = 0.2,
                LoanAmount   = 10000,
                LoanStart    = DateTime.Now,
                LoanEnd      = DateTime.Now.AddYears(1)
            };

            var customer = new StandardCustomer
            {
                FirstName      = "Arnas",
                LastName       = "Danaitis",
                MonthlySalary  = 1000,
                PersonalNumber = "12345678101"
            };

            var customerLoans = new List <Loan>
            {
                new StandardLoan
                {
                    CustomerId   = 1,
                    InterestRate = 0.2,
                    LoanAmount   = 30000,
                    LoanStart    = DateTime.Now.AddYears(-1),
                    LoanEnd      = DateTime.Now.AddYears(1)
                },
                new StandardLoan
                {
                    CustomerId   = 1,
                    InterestRate = 0.2,
                    LoanAmount   = 30000,
                    LoanStart    = DateTime.Now.AddYears(-1),
                    LoanEnd      = DateTime.Now.AddYears(1)
                }
            };

            Assert.Throws <BusinessException>(() => _loanDomainService.CanCreateLoan(loan, customer, customerLoans));
        }
Esempio n. 4
0
        public static Customer Create(string input)
        {
            Customer customer;

            if (input == "s")
            {
                customer = new StandardCustomer();
            }
            else if (input == "v")
            {
                customer = new VipCustomer();
            }
            else if (input == "x")
            {
                customer = new ExtraCustomer();
            }
            else
            {
                throw new NotSupportedException();
            }

            return(customer);
        }