public void ISQLExceptionConverter_gets_called_if_batch_size_enabled() { long oneId; using (var s = OpenSession()) using (var tx = s.BeginTransaction()) { var one = new One(); s.Save(one); var many = new Many { One = one }; s.Save(many); tx.Commit(); oneId = one.Id; } using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { var one = s.Load <One>(oneId); s.Delete(one); Assert.That(() => tx.Commit(), Throws.TypeOf <ConstraintViolationException>()); } }
public void ISQLExceptionConverter_gets_called_if_batch_size_enabled() { long oneId; using(var s = OpenSession()) using(var tx = s.BeginTransaction()) { var one = new One(); s.Save(one); var many = new Many { One = one }; s.Save(many); tx.Commit(); oneId = one.Id; } using(ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { var one = s.Load<One>(oneId); s.Delete(one); Assert.That(() => tx.Commit(), Throws.TypeOf<ConstraintViolationException>()); } }
public void ISQLExceptionConverter_gets_called_if_batch_size_enabled() { long oneId; using(var s = OpenSession()) using(var tx = s.BeginTransaction()) { var one = new One(); s.Save(one); var many = new Many { One = one }; s.Save(many); tx.Commit(); oneId = one.Id; } using(ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { var one = s.Load<One>(oneId); try { s.Delete(one); tx.Commit(); Assert.Fail("DELETE should have failed"); } catch (Exception ex) { Assert.IsInstanceOf<ConstraintViolationException>(ex); } } }
public async Task ISQLExceptionConverter_gets_called_if_batch_size_enabledAsync() { long oneId; using (var s = OpenSession()) using (var tx = s.BeginTransaction()) { var one = new One(); await(s.SaveAsync(one)); var many = new Many { One = one }; await(s.SaveAsync(many)); await(tx.CommitAsync()); oneId = one.Id; } using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { var one = await(s.LoadAsync <One>(oneId)); await(s.DeleteAsync(one)); Assert.That(() => tx.CommitAsync(), Throws.TypeOf <ConstraintViolationException>()); } }
public void ISQLExceptionConverter_gets_called_if_batch_size_enabled() { long oneId; using (var s = OpenSession()) using (var tx = s.BeginTransaction()) { var one = new One(); s.Save(one); var many = new Many { One = one }; s.Save(many); tx.Commit(); oneId = one.Id; } using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { var one = s.Load <One>(oneId); try { s.Delete(one); tx.Commit(); Assert.Fail("DELETE should have failed"); } catch (Exception ex) { Assert.IsInstanceOf <ConstraintViolationException>(ex); } } }