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); }
public void GetAllShouldReturnEmptyList() { var sut = new InMemoryCompanyRepository(); var list = sut.GetAll(); Assert.Empty(list); }
public void DeleteAfterAddingShouldRemoveItem() { var sut = new InMemoryCompanyRepository(); Company company = new Company() { CreatedDate = new DateTime(), FoundedDate = new DateTime(), Name = "My Company" }; sut.Add(company); sut.Delete(company.CompanyId); var list = sut.GetAll(); Assert.Empty(list); }
public void AddShouldAddOneItem() { var sut = new InMemoryCompanyRepository(); Company company = new Company() { CreatedDate = new DateTime(), FoundedDate = new DateTime(), Name = "My Company" }; sut.Add(company); var list = sut.GetAll(); Assert.Single(list); Assert.Equal(company.Name, list.First().Name); }
public void UpdateShouldChangeItemInList() { var sut = new InMemoryCompanyRepository(); Company company = new Company() { CreatedDate = new DateTime(), FoundedDate = new DateTime(), Name = "My Company" }; int id = sut.Add(company); Company anotherCompany = new Company() { CreatedDate = company.CreatedDate, FoundedDate = company.FoundedDate, Name = "Not my company", CompanyId = id }; sut.Update(anotherCompany); var list = sut.GetAll(); Assert.Equal("Not my company", list.First().Name); }