コード例 #1
0
        public void RegisterCustomer_ShouldReturnNewCustomer()
        {
            // Fixture set-up
            ICustomerRepository customerRepo = new InMemoryCustomerRepository();
            ICompanyRepository  companyRepo  = new InMemoryCompanyRepository();

            CustomerService customerService = new CustomerService(customerRepo, companyRepo);

            Customer expected = new Customer
            {
                Id        = 1,
                Email     = "*****@*****.**",
                Franchise = true,
                Name      = "Customer X",
                Phone     = "1234 5678",
                CompanyId = 1
            };

            // Exercise the SUT (system under test)
            Customer actual = customerService.RegisterCustomer(
                companyId: expected.CompanyId,
                name: expected.Name,
                franchise: expected.Franchise,
                phone: expected.Phone,
                email: expected.Email);

            // State verification
            AreCustomerEqual(expected, actual);

            var addedCustomer = customerRepo.Get(expected.Id);

            AreCustomerEqual(expected, addedCustomer);
        }
コード例 #2
0
 public InMemoryCustomerRepositoryTests()
 {
     _dbContextCreator = new DbContextCreator();
     _repo             = new InMemoryCustomerRepository(_dbContextCreator.CreateDbContext());
 }