fixture.cs

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

CS
49
字号
using System;
using NUnit.Framework;

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

		// We pass an Int32 id to Load and expect an exception, since the class
		// uses Int64 ids.
		[Test, ExpectedException(typeof(TypeMismatchException))]
		public void Loading()
		{
			object parentId;
			using (ISession session = OpenSession())
			{
				SecurityDomain parent = new SecurityDomain();
				parent.Name = "Name";
				parent.ChildDomains.Add(new SecurityDomain());

				parentId = session.Save(parent);
				session.Flush();
			}

			try
			{
				using (ISession session = OpenSession())
				{
					SecurityDomain aDomain = (SecurityDomain) session.Load(typeof(SecurityDomain), 1);
					Assert.AreEqual("Name", aDomain.Name);
					Assert.IsTrue(aDomain.ChildDomains.Count > 0);
				}
			}
			finally
			{
				using (ISession session = OpenSession())
				{
					session.Delete("from SecurityDomain");
					session.Flush();
				}
			}
		}
	}
}

⌨️ 快捷键说明

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