public void DetectConflictTest() { using (new TransactionScope()) { Concurrency.NoCheck(); } using (new TransactionScope()) { try { Concurrency.ConcurrencyCheck(); Assert.Fail(); } catch (DbUpdateConcurrencyException exception) { Trace.WriteLine(exception); } } using (new TransactionScope()) { try { Concurrency.RowVersion(); Assert.Fail(); } catch (DbUpdateConcurrencyException exception) { Trace.WriteLine(exception); } } }
public void DetectConflictTest() { Rollback((adventureWorks1, adventureWorks2, adventureWorks3) => Concurrency.NoCheck(new DbReaderWriter(adventureWorks1), new DbReaderWriter(adventureWorks2), new DbReaderWriter(adventureWorks3))); Rollback((adventureWorks1, adventureWorks2) => { try { Concurrency.ConcurrencyCheck(new DbReaderWriter(adventureWorks1), new DbReaderWriter(adventureWorks2)); Assert.Fail(); } catch (DbUpdateConcurrencyException exception) { Trace.WriteLine(exception); } }); Rollback((adventureWorks1, adventureWorks2) => { try { Concurrency.RowVersion(new DbReaderWriter(adventureWorks1), new DbReaderWriter(adventureWorks2)); Assert.Fail(); } catch (DbUpdateConcurrencyException exception) { Trace.WriteLine(exception); } }); }
public void DetectConflictTest() { #if NETFX using (new TransactionHelper()) { Concurrency.NoCheck(new DbReaderWriter(new AdventureWorks()), new DbReaderWriter(new AdventureWorks()), new DbReaderWriter(new AdventureWorks())); } using (new TransactionHelper()) { try { Concurrency.ConcurrencyCheck(new DbReaderWriter(new AdventureWorks()), new DbReaderWriter(new AdventureWorks())); Assert.Fail(); } catch (DbUpdateConcurrencyException exception) { Trace.WriteLine(exception); } } using (new TransactionHelper()) { try { Concurrency.RowVersion(new DbReaderWriter(new AdventureWorks()), new DbReaderWriter(new AdventureWorks())); Assert.Fail(); } catch (DbUpdateConcurrencyException exception) { Trace.WriteLine(exception); } } #else Rollback((adventureWorks1, adventureWorks2, adventureWorks3) => Concurrency.NoCheck(new DbReaderWriter(adventureWorks1), new DbReaderWriter(adventureWorks2), new DbReaderWriter(adventureWorks3))); Rollback((adventureWorks1, adventureWorks2) => { try { Concurrency.ConcurrencyCheck(new DbReaderWriter(adventureWorks1), new DbReaderWriter(adventureWorks2)); Assert.Fail(); } catch (DbUpdateConcurrencyException exception) { Trace.WriteLine(exception); } }); Rollback((adventureWorks1, adventureWorks2) => { try { Concurrency.RowVersion(new DbReaderWriter(adventureWorks1), new DbReaderWriter(adventureWorks2)); Assert.Fail(); } catch (DbUpdateConcurrencyException exception) { Trace.WriteLine(exception); } }); #endif }