예제 #1
0
        private bool IsValidCreditLimit(Customer customer)
        {
            var creditLimit = creditService.GetCreditLimit(customer.Firstname, customer.Surname, customer.DateOfBirth);

            var company = customer.Company;

            if (company.IsVeryImportantClient())
            {
                // Skip credit check
                customer.HasCreditLimit = false;
            }
            else
            {
                customer.HasCreditLimit = true;
                if (company.IsImportantClient())
                {
                    customer.CreditLimit = creditLimit * 2;
                }
                else
                {
                    customer.CreditLimit = creditLimit;
                }
            }

            return(customer.HasValidCreditLimit());
        }
예제 #2
0
        public void ShouldReturnFalseIfCompanyIsNeitherVeryImportantNorImportantAndLimitIs100()
        {
            var companyId   = 4;
            var firstName   = "Joe";
            var surname     = "Bloggs";
            var email       = "*****@*****.**";
            var dateOfBirth = new DateTime(1980, 3, 27);

            var company = new Company {
                Id = 1, Name = "SomeCompany", Classification = Classification.Bronze
            };

            companyRepository.GetById(companyId).Returns(company);
            creditService.GetCreditLimit(firstName, surname, dateOfBirth).Returns(100);


            CustomerService customerService = new CustomerService(companyRepository, creditService, customerRepository);
            var             result          = customerService.AddCustomer(firstName, surname, email, dateOfBirth, companyId);

            Assert.False(result);
        }