Example #1
0
        public void Insert_and_delete_TEST_record_succesfully_via_Find()
        {
            // Arrange
            var db2 = new MyDbContext();
            var db3 = new MyDbContext();
            var customersRepository1 = new CustomersRepository(_db);
            var customersRepository2 = new CustomersRepository(db2);
            var customersRepository3 = new CustomersRepository(db3);
            var customer             = new Customer
            {
                CustomerId  = "TEST.",
                CompanyName = "Integration testing"
            };

            // Act
            customersRepository1.AddCustomer(customer);
            var customer2 = customersRepository2.Find(customer.CustomerId);

            customersRepository2.DeleteCustomer(customer2);
            var customer3 = customersRepository3.Find(customer.CustomerId); // Should not be found

            // Assert
            Assert.IsNotNull(customer2);
            Assert.AreEqual(customer.CustomerId, customer2.CustomerId);
            Assert.AreEqual(customer.CompanyName, customer2.CompanyName);
            Assert.IsNull(customer3);
        }
 public static void AddCustomer(LocalDBExample.DTO.Customer customer)
 {
     try
     {
         CustomersRepository.AddCustomer(customer);
     }
     catch (Exception)
     {
         // Log it or do w/e
         throw;
     }
 }