Exemple #1
0
        public async Task ReplaceValueTypeComponentWithSameValueDoesNotMakeItDirtyAsync()
        {
            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;

                    await(s.SaveAsync(p));
                    await(tx.CommitAsync());
                }

            InterceptorStub interceptor = new InterceptorStub();

            using (ISession s = OpenSession(interceptor))
                using (ITransaction tx = s.BeginTransaction())
                {
                    Person jimmy = await(s.GetAsync <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);

                    await(tx.CommitAsync());
                }
            Assert.IsFalse(interceptor.entityWasDeemedDirty);
        }
		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);
		}
Exemple #3
0
        public async Task EmptyValueTypeComponentAsync()
        {
            using (ISession s = OpenSession())
                using (ITransaction tx = s.BeginTransaction())
                {
                    Person p = new Person("Jimmy Hendrix");
                    await(s.SaveAsync(p));
                    await(tx.CommitAsync());
                }

            InterceptorStub interceptor = new InterceptorStub();

            using (ISession s = OpenSession(interceptor))
                using (ITransaction tx = s.BeginTransaction())
                {
                    Person jimmy = await(s.GetAsync <Person>("Jimmy Hendrix"));
                    interceptor.entityToCheck = jimmy;
                    await(tx.CommitAsync());
                }
            Assert.IsFalse(interceptor.entityWasDeemedDirty);

            InterceptorStub interceptor2 = new InterceptorStub();

            using (ISession s = OpenSession(interceptor2))
                using (ITransaction tx = s.BeginTransaction())
                {
                    Person jimmy = await(s.GetAsync <Person>("Jimmy Hendrix"));
                    jimmy.Address             = new Address();
                    interceptor.entityToCheck = jimmy;
                    await(tx.CommitAsync());
                }
            Assert.IsFalse(interceptor2.entityWasDeemedDirty);
        }
		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);
		}