示例#1
0
		public void ReplaceValueTypeComponentWithSameValueDoesNotMakeItDirty()
		{
			using (ISession s = OpenSession())
			using (ITransaction tx = s.BeginTransaction())
			{
				Person p = new Person("Jimmy Hendrix");
				Address a = new Address();
				a.Street = "Some Street";
				a.City = "Some City";
				p.Address = a;

				s.Save(p);
				tx.Commit();
			}

			InterceptorStub interceptor = new InterceptorStub();
			using (ISession s = OpenSession(interceptor))
			using (ITransaction tx = s.BeginTransaction())
			{
				Person jimmy = s.Get<Person>("Jimmy Hendrix");
				interceptor.entityToCheck = jimmy;

				Address a = new Address();
				a.Street = "Some Street";
				a.City = "Some City";
				jimmy.Address = a;
				Assert.AreNotSame(jimmy.Address, a);

				tx.Commit();
			}
			Assert.IsFalse(interceptor.entityWasDeemedDirty);
		}
示例#2
0
		public void EmptyValueTypeComponent()
		{
			using (ISession s = OpenSession())
			using (ITransaction tx = s.BeginTransaction())
			{
				Person p = new Person("Jimmy Hendrix");
				s.Save(p);
				tx.Commit();
			}

			InterceptorStub interceptor = new InterceptorStub();
			using (ISession s = OpenSession(interceptor))
			using (ITransaction tx = s.BeginTransaction())
			{
				Person jimmy = s.Get<Person>("Jimmy Hendrix");
				interceptor.entityToCheck = jimmy;
				tx.Commit();
			}
			Assert.IsFalse(interceptor.entityWasDeemedDirty);

			InterceptorStub interceptor2 = new InterceptorStub();
			using (ISession s = OpenSession(interceptor2))
			using (ITransaction tx = s.BeginTransaction())
			{
				Person jimmy = s.Get<Person>("Jimmy Hendrix");
				jimmy.Address = new Address();
				interceptor.entityToCheck = jimmy;
				tx.Commit();
			}
			Assert.IsFalse(interceptor2.entityWasDeemedDirty);
		}