fixture.cs

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

CS
66
字号
using System;
using System.Collections;
using NUnit.Framework;

namespace NHibernate.Test.NHSpecificTest.Docs.Associations.BiM21
{
	[TestFixture]
	public class Fixture : TestCase
	{
		protected override string MappingsAssembly
		{
			get { return "NHibernate.Test"; }
		}

		protected override IList Mappings
		{
			get { return new string[] {"NHSpecificTest.Docs.Associations.BiM21.Mappings.hbm.xml"}; }
		}

		[Test]
		public void TestCorrectUse()
		{
			ISession session = OpenSession();

			Person fred = new Person();
			Person wilma = new Person();

			Address flinstoneWay = new Address();

			fred.Address = flinstoneWay;
			wilma.Address = flinstoneWay;

			session.Save(flinstoneWay);
			session.Save(fred);
			session.Save(wilma);

			session.Close();

			// clean up
			session = OpenSession();

			session.Delete("from Person");
			session.Delete("from Address");
			session.Flush();
			session.Close();
		}

		[Test]
		[ExpectedException(typeof(PropertyValueException))]
		public void TestErrorUsage()
		{
			using (ISession session = OpenSession())
			{
				Person fred = new Person();
				Person wilma = new Person();

				Address flinstoneWay = new Address();

				fred.Address = flinstoneWay;
				wilma.Address = flinstoneWay;

				session.Save(fred);
			}
		}
	}
}

⌨️ 快捷键说明

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