public void DatabaseRepositoryAddingIncorrentCustomerTest() { Repository = new DatabaseRepository( new DatabaseRepositorySettings(ConnectionString, DatabaseConnectionAction.Create)); Customer incorrectCustomer = new Customer(); Repository.AddCustomer(incorrectCustomer); Repository.SaveChanges(); Assert.IsTrue(Repository.ErrorHappened); }
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()); }