public void Db_DeleteNoExistentCustomer() { // arrange var customerDb = new CustomerDb(_connectionString); var customer = new Customer.EF.Customer { Id = 0, FirstName = "John", LastName = "Doddle", Password = "******" }; // act var result = customerDb.DeleteCustomer(customer); // assert Assert.AreEqual(result, 0); }
public void Db_CreateCustomer() { // arrange var customerDb = new CustomerDb(_connectionString); var customer = new Customer.EF.Customer { Id = 0, FirstName = "John", LastName = "Doddle", Password = "******" }; // act customer = customerDb.AddCustomer(customer); // assert Assert.IsTrue(customer.Id > 0); }
public void Db_UpdateNonExistentCustomer() { // arrange var customerDb = new CustomerDb(_connectionString); var customer = new Customer.EF.Customer { Id = 0, FirstName = "Marli", LastName = "Smith", Password = "******" }; // act customer.FirstName = "Marlo"; customer = customerDb.UpdateCustomer(customer); // assert Assert.IsTrue(customer == null); }
public void Api_DeleteNonExistentCustomer_InMemory() { // arrange CustomerController customerController = new CustomerController(new InMemoryCustomerDb()); var customer = new Customer.EF.Customer { Id = 0, FirstName = "John", LastName = "Doddle", Password = "******" }; // act var result = customerController.Delete(customer.Id); var notFoundResult = (NotFoundResult)result; // assert Assert.AreEqual(StatusCodes.Status404NotFound, notFoundResult.StatusCode); }
public void Db_GetCustomerById() { // arrange var customerDb = new CustomerDb(_connectionString); var customer = new Customer.EF.Customer { Id = 0, FirstName = "John", LastName = "Doddle", Password = "******" }; // act customer = customerDb.AddCustomer(customer); customer = customerDb.Customers.SingleOrDefault(c => c.Id == customer.Id); // assert Assert.IsNotNull(customer); }
public void Db_UpdateCustomer() { // arrange var customerDb = new CustomerDb(_connectionString); var customer = new Customer.EF.Customer { Id = 0, FirstName = "Marli", LastName = "Smith", Password = "******" }; // act customer = customerDb.AddCustomer(customer); customer.FirstName = "Marlo"; customer = customerDb.UpdateCustomer(customer); // assert Assert.AreEqual(customer.FirstName, "Marlo"); }
public void Api_CreateCustomer_InMemory() { // arrange CustomerController customerController = new CustomerController(new InMemoryCustomerDb()); var customer = new Customer.EF.Customer { Id = 0, FirstName = "John", LastName = "Doddle", Password = "******" }; // act var result = customerController.Create(customer); customer = (Customer.EF.Customer)((OkObjectResult)result).Value; // assert Assert.IsTrue(customer.Id > 0); }
public void Api_UpdateNonExistentCustomer_InMemory() { // arrange CustomerController customerController = new CustomerController(new InMemoryCustomerDb()); var customer = new Customer.EF.Customer { Id = 0, FirstName = "Marli", LastName = "Smith", Password = "******" }; // act customer.FirstName = "Marlo"; var result = customerController.Update(customer); var notFoundResult = (NotFoundResult)result; // assert Assert.AreEqual(StatusCodes.Status404NotFound, notFoundResult.StatusCode); }
public void Api_DeleteCustomer() { // arrange CustomerController customerController = new CustomerController(new CustomerDb(_connectionString)); var customer = new Customer.EF.Customer { Id = 0, FirstName = "John", LastName = "Doddle", Password = "******" }; // act var result1 = customerController.Create(customer); customer = (Customer.EF.Customer)((OkObjectResult)result1).Value; var result2 = customerController.Delete(customer.Id); var result3 = (bool)((OkObjectResult)result2).Value; // assert Assert.IsTrue(result3); }
public void Api_GetCustomerById_InMemoryDb() { // arrange CustomerController customerController = new CustomerController(new InMemoryCustomerDb()); var customer = new Customer.EF.Customer { Id = 0, FirstName = "John", LastName = "Doddle", Password = "******" }; // act var result1 = customerController.Create(customer); customer = (Customer.EF.Customer)((OkObjectResult)result1).Value; var result2 = customerController.Get(customer.Id); customer = (Customer.EF.Customer)((OkObjectResult)result2).Value; // assert Assert.IsNotNull(customer); }
public void Api_UpdateCustomer_InMemory() { // arrange CustomerController customerController = new CustomerController(new InMemoryCustomerDb()); var customer = new Customer.EF.Customer { Id = 0, FirstName = "Marli", LastName = "Smith", Password = "******" }; // act var result1 = customerController.Create(customer); customer = (Customer.EF.Customer)((OkObjectResult)result1).Value; customer.FirstName = "Marlo"; var result2 = customerController.Update(customer); customer = (Customer.EF.Customer)((OkObjectResult)result2).Value; // assert Assert.AreEqual(customer.FirstName, "Marlo"); Assert.AreEqual(customer.LastName, "Smith"); }