public void CRUD() { WronglyMappedClass obj = new WronglyMappedClass(); obj.SomeInt = 10; using( ISession s = OpenSession() ) using( ITransaction t = s.BeginTransaction() ) { s.Save( obj ); t.Commit(); } try { using( ISession s = OpenSession() ) using( ITransaction t = s.BeginTransaction() ) { obj = ( WronglyMappedClass ) s.Get( typeof( WronglyMappedClass ), obj.Id ); Assert.AreEqual( 10, obj.SomeInt ); t.Commit(); } } finally { using( ISession s = OpenSession() ) using( ITransaction t = s.BeginTransaction() ) { s.Delete( obj ); t.Commit(); } } }
public void CRUD() { if (Environment.BytecodeProvider is NullBytecodeProvider) { Assert.Ignore("This test only runs with a non-null bytecode provider"); } WronglyMappedClass obj = new WronglyMappedClass(); obj.SomeInt = 10; using (ISession s = OpenSession()) using (ITransaction t = s.BeginTransaction()) { s.Save(obj); t.Commit(); } try { using (ISession s = OpenSession()) using (ITransaction t = s.BeginTransaction()) { Assert.Throws<PropertyAccessException>(() => s.Get(typeof(WronglyMappedClass), obj.Id)); t.Commit(); } } finally { using (ISession s = OpenSession()) using (ITransaction t = s.BeginTransaction()) { s.Delete(obj); t.Commit(); } } }
public async Task CRUDAsync() { if (Environment.BytecodeProvider is NullBytecodeProvider) { Assert.Ignore("This test only runs with a non-null bytecode provider"); } WronglyMappedClass obj = new WronglyMappedClass(); obj.SomeInt = 10; using (ISession s = OpenSession()) using (ITransaction t = s.BeginTransaction()) { await(s.SaveAsync(obj)); await(t.CommitAsync()); } try { using (ISession s = OpenSession()) using (ITransaction t = s.BeginTransaction()) { Assert.ThrowsAsync <PropertyAccessException>(() => s.GetAsync(typeof(WronglyMappedClass), obj.Id)); await(t.CommitAsync()); } } finally { using (ISession s = OpenSession()) using (ITransaction t = s.BeginTransaction()) { await(s.DeleteAsync(obj)); await(t.CommitAsync()); } } }