public void ShouldCallDatabaseToInsertCustomer() { var newCustomer = new Models.Customer(NewCustomerEmail, NewCustomerFirstName, NewCustomerSurname, NewCustomerPassword); var mockDatabase = new Mock <ICustomerDb>(); var sut = new Services.CustomerService(mockDatabase.Object); sut.Add(newCustomer); mockDatabase.Verify(db => db.Insert(newCustomer), Times.Once); }
public void ShouldReturnCustomerWithTheSameEmailPassedIntoIt() { var newCustomer = new Models.Customer(NewCustomerEmail, NewCustomerFirstName, NewCustomerSurname, NewCustomerPassword); var mockDatabase = new Mock <ICustomerDb>(); mockDatabase.Setup(db => db.Insert(newCustomer)).ReturnsAsync(newCustomer); var sut = new Services.CustomerService(mockDatabase.Object); var actualNewCustomer = sut.Add(newCustomer).Result; Assert.Equal(NewCustomerEmail, actualNewCustomer.Email); }