public void Customer_Add_Delete_Test() { using (DataContext db = new DataContext()) { //Arrange Customer customer = new Customer { Id = 0, Name = Name.FullName(), Address = Address.StreetAddress(), PhoneNumber = Phone.Number() }; //Act - Create db.Customers.Add(customer); db.SaveChanges(); //Assert - Create Assert.NotEqual(0, customer.Id); customer.Id.ShouldBeGreaterThan(0); //Act - Delete db.Entry(customer).State = System.Data.Entity.EntityState.Deleted; var result = db.SaveChanges(); //Asset - Create Assert.NotEqual(0, result); result.ShouldBeGreaterThan(0); } }
public static List<Customer> MockCustomers(int number) { List<Customer> customers = new List<Customer>(); for (int i = 0; i < number; i++) { var count = 0; count += 1; //create Customer customer = new Customer { Id = count, Name = Name.FullName(), Address = Address.StreetAddress(), PhoneNumber = Phone.Number() }; customers.Add(customer); } return customers; }