fixture.cs

来自「NHibernate NET开发者所需的」· CS 代码 · 共 55 行

CS
55
字号
using System;
using NHibernate.Bytecode;
using NUnit.Framework;
using Environment=NHibernate.Cfg.Environment;

namespace NHibernate.Test.NHSpecificTest.NH496
{
	[TestFixture]
	public class Fixture : BugTestCase
	{
		public override string BugNumber
		{
			get { return "NH496"; }
		}

		[Test]
		[ExpectedException(typeof(PropertyAccessException))]
		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())
				{
					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();
				}
			}
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?