public void WhenLoadInheritedClassUsingInterfaceThenNotThrowsAsync()
 {
     using (var scenario = new ScenarioWithB(Sfi))
     {
         using (var s = OpenSession())
         {
             Assert.That(() => s.LoadAsync <INamed>(scenario.B.Id), Throws.Nothing);
         }
     }
 }
示例#2
0
 public void WhenLoadInheritedClassUsingInterfaceThenNotThrows()
 {
     using (var scenario = new ScenarioWithB(Sfi))
     {
         using (var s = OpenSession())
         {
             Executing.This(() => s.Load <INamed>(scenario.B.Id)).Should().NotThrow();
         }
     }
 }
示例#3
0
 public void WhenGetInheritedClassUsingInterfaceFromSessionCacheThenNotThrows()
 {
     using (var scenario = new ScenarioWithB(Sfi))
     {
         using (var s = OpenSession())
         {
             var id = scenario.B.Id;
             s.Get <B>(id);
             s.Executing(session => session.Get <INamed>(id)).NotThrows();
         }
     }
 }
示例#4
0
 public void WhenGetInheritedClassUsingInterfaceThenNotThrows()
 {
     using (var scenario = new ScenarioWithB(Sfi))
     {
         using (var s = OpenSession())
         {
             INamed loadedEntity = null;
             Executing.This(() => loadedEntity = s.Get <INamed>(scenario.B.Id)).Should().NotThrow();
             loadedEntity.Should().Be.OfType <B>();
         }
     }
 }
 public async Task WhenGetInheritedClassUsingInterfaceFromSessionCacheThenNotThrowsAsync()
 {
     using (var scenario = new ScenarioWithB(Sfi))
     {
         using (var s = OpenSession())
         {
             var id = scenario.B.Id;
             await(s.GetAsync <B>(id));
             Assert.That(() => s.GetAsync <INamed>(id), Throws.Nothing);
         }
     }
 }
 public void WhenGetInheritedClassUsingInterfaceFromSessionCacheThenNotThrows()
 {
     using (var scenario = new ScenarioWithB(Sfi))
     {
         using (var s = OpenSession())
         {
             var id = scenario.B.Id;
             s.Get <B>(id);
             Assert.That(() => s.Get <INamed>(id), Throws.Nothing);
         }
     }
 }
 public void WhenGetInheritedClassUsingInterfaceThenNotThrowsAsync()
 {
     using (var scenario = new ScenarioWithB(Sfi))
     {
         using (var s = OpenSession())
         {
             INamed loadedEntity = null;
             Assert.That(async() => loadedEntity = await(s.GetAsync <INamed>(scenario.B.Id)), Throws.Nothing);
             Assert.That(loadedEntity, Is.TypeOf <B>());
         }
     }
 }
        public async Task WhenLoadInterfaceThenShouldAllowNarrowingProxyAsync()
        {
            using (var scenario = new ScenarioWithB(Sfi))
            {
                using (var s = OpenSession())
                {
                    INamed loadedEntity = null;
                    Assert.That(async() => loadedEntity = await(s.LoadAsync <INamed>(scenario.B.Id)), Throws.Nothing);
                    Assert.That(NHibernateProxyHelper.GetClassWithoutInitializingProxy(loadedEntity), Is.EqualTo(typeof(A)));

                    var narrowedProxy = await(s.LoadAsync <IOccuped>(scenario.B.Id));

                    Assert.That(NHibernateProxyHelper.GetClassWithoutInitializingProxy(narrowedProxy), Is.EqualTo(typeof(B)));

                    var firstLoadedImpl  = ((INHibernateProxy)loadedEntity).HibernateLazyInitializer.GetImplementation((ISessionImplementor)s);
                    var secondLoadedImpl = ((INHibernateProxy)narrowedProxy).HibernateLazyInitializer.GetImplementation((ISessionImplementor)s);
                    Assert.That(firstLoadedImpl, Is.SameAs(secondLoadedImpl));
                }
            }
        }
示例#9
0
        public void WhenLoadInterfaceThenShouldAllowNarrowingProxy()
        {
            using (var scenario = new ScenarioWithB(Sfi))
            {
                using (var s = OpenSession())
                {
                    INamed loadedEntity = null;
                    Executing.This(() => loadedEntity = s.Load <INamed>(scenario.B.Id)).Should().NotThrow();
                    NHibernateProxyHelper.GetClassWithoutInitializingProxy(loadedEntity).Should().Be(typeof(A));

                    var narrowedProxy = s.Load <IOccuped>(scenario.B.Id);

                    NHibernateProxyHelper.GetClassWithoutInitializingProxy(narrowedProxy).Should().Be(typeof(B));

                    var firstLoadedImpl  = ((INHibernateProxy)loadedEntity).HibernateLazyInitializer.GetImplementation((ISessionImplementor)s);
                    var secondLoadedImpl = ((INHibernateProxy)narrowedProxy).HibernateLazyInitializer.GetImplementation((ISessionImplementor)s);
                    firstLoadedImpl.Should().Be.SameInstanceAs(secondLoadedImpl);
                }
            }
        }
		public void WhenLoadInheritedClassUsingInterfaceThenNotThrows()
		{
			using (var scenario = new ScenarioWithB(Sfi))
			{
				using (var s = OpenSession())
				{
					Executing.This(()=> s.Load<INamed>(scenario.B.Id) ).Should().NotThrow();
				}
			}
		}
		public void WhenLoadInheritedClassUsingInterfaceThenNotThrows()
		{
			using (var scenario = new ScenarioWithB(Sfi))
			{
				using (var s = OpenSession())
				{
					Assert.That(() => s.Load<INamed>(scenario.B.Id), Throws.Nothing);
				}
			}
		}
		public void WhenGetInheritedClassUsingInterfaceFromSessionCacheThenNotThrows()
		{
			using (var scenario = new ScenarioWithB(Sfi))
			{
				using (var s = OpenSession())
				{
					var id = scenario.B.Id;
					s.Get<B>(id);
					s.Executing(session => session.Get<INamed>(id)).NotThrows();
				}
			}
		}
		public void WhenGetInheritedClassUsingInterfaceThenNotThrows()
		{
			using (var scenario = new ScenarioWithB(Sfi))
			{
				using (var s = OpenSession())
				{
					INamed loadedEntity = null;
					Executing.This(() => loadedEntity = s.Get<INamed>(scenario.B.Id)).Should().NotThrow();
					loadedEntity.Should().Be.OfType<B>();
				}
			}
		}
		public void WhenLoadInterfaceThenShouldAllowNarrowingProxy()
		{
			using (var scenario = new ScenarioWithB(Sfi))
			{
				using (var s = OpenSession())
				{
					INamed loadedEntity = null;
					Executing.This(() => loadedEntity = s.Load<INamed>(scenario.B.Id)).Should().NotThrow();
					NHibernateProxyHelper.GetClassWithoutInitializingProxy(loadedEntity).Should().Be(typeof(A));

					var narrowedProxy = s.Load<IOccuped>(scenario.B.Id);

					NHibernateProxyHelper.GetClassWithoutInitializingProxy(narrowedProxy).Should().Be(typeof(B));

					var firstLoadedImpl = ((INHibernateProxy)loadedEntity).HibernateLazyInitializer.GetImplementation((ISessionImplementor)s);
					var secondLoadedImpl = ((INHibernateProxy)narrowedProxy).HibernateLazyInitializer.GetImplementation((ISessionImplementor)s);
					firstLoadedImpl.Should().Be.SameInstanceAs(secondLoadedImpl);
				}
			}
		}
		public void WhenGetInheritedClassUsingInterfaceFromSessionCacheThenNotThrows()
		{
			using (var scenario = new ScenarioWithB(Sfi))
			{
				using (var s = OpenSession())
				{
					var id = scenario.B.Id;
					s.Get<B>(id);
					Assert.That(() => s.Get<INamed>(id), Throws.Nothing);
				}
			}
		}
		public void WhenGetInheritedClassUsingInterfaceThenNotThrows()
		{
			using (var scenario = new ScenarioWithB(Sfi))
			{
				using (var s = OpenSession())
				{
					INamed loadedEntity = null;
					Assert.That(() => loadedEntity = s.Get<INamed>(scenario.B.Id), Throws.Nothing);
					Assert.That(loadedEntity, Is.TypeOf<B>());
				}
			}
		}
		public void WhenLoadInterfaceThenShouldAllowNarrowingProxy()
		{
			using (var scenario = new ScenarioWithB(Sfi))
			{
				using (var s = OpenSession())
				{
					INamed loadedEntity = null;
					Assert.That(() => loadedEntity = s.Load<INamed>(scenario.B.Id), Throws.Nothing);
					Assert.That(NHibernateProxyHelper.GetClassWithoutInitializingProxy(loadedEntity), Is.EqualTo(typeof(A)));

					var narrowedProxy = s.Load<IOccuped>(scenario.B.Id);

					Assert.That(NHibernateProxyHelper.GetClassWithoutInitializingProxy(narrowedProxy), Is.EqualTo(typeof(B)));

					var firstLoadedImpl = ((INHibernateProxy)loadedEntity).HibernateLazyInitializer.GetImplementation((ISessionImplementor)s);
					var secondLoadedImpl = ((INHibernateProxy)narrowedProxy).HibernateLazyInitializer.GetImplementation((ISessionImplementor)s);
					Assert.That(firstLoadedImpl, Is.SameAs(secondLoadedImpl));
				}
			}
		}