コード例 #1
0
        public void DatabaseRepositoryAddingIncorrentCustomerTest()
        {
            Repository = new DatabaseRepository(
                new DatabaseRepositorySettings(ConnectionString, DatabaseConnectionAction.Create));
            Customer incorrectCustomer = new Customer();

            Repository.AddCustomer(incorrectCustomer);
            Repository.SaveChanges();
            Assert.IsTrue(Repository.ErrorHappened);
        }
コード例 #2
0
        public void DatabaseRepositoryStashClearingWhenErrorTest()
        {
            DatabaseRepository dbRepository = new DatabaseRepository(
                new DatabaseRepositorySettings(ConnectionString, DatabaseConnectionAction.Create));
            Customer incorrectCustomer = new Customer();
            Order    incorrectOrder    = new Order();

            dbRepository.AddCustomer(incorrectCustomer);
            dbRepository.AddOrder(incorrectOrder);
            try
            {
                dbRepository.SaveChanges();
            }
            catch
            {
                // ignored
            }
            Assert.IsFalse(dbRepository.CustomersStash.Any());
            Assert.IsFalse(dbRepository.OrdersStash.Any());
            Assert.IsFalse(dbRepository.CarsStash.Any());
        }