Пример #1
0
		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();

		}
Пример #2
0
		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 );
			}
		}
		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;

				Assert.Throws<PropertyValueException>(() => session.Save(fred));
			}
		}