Exemplo n.º 1
0
        public void CreateProxy_works_for_owned_but_not_weak_entity_types()
        {
            using var context = new NeweyContext();

            Assert.Same(typeof(IsOwnedButNotWeak), context.CreateProxy <IsOwnedButNotWeak>().GetType().BaseType);
            Assert.Same(typeof(IsOwnedButNotWeak), context.CreateProxy <IsOwnedButNotWeak>(_ => { }).GetType().BaseType);
            Assert.Same(typeof(IsOwnedButNotWeak), context.CreateProxy(typeof(IsOwnedButNotWeak)).GetType().BaseType);
        }
Exemplo n.º 2
0
 public void CreateProxy_uses_parameterless_constructor()
 {
     using (var context = new NeweyContext())
     {
         Assert.Same(typeof(March82GGtp), context.CreateProxy <March82GGtp>().GetType().BaseType);
     }
 }
Exemplo n.º 3
0
 public void CreateProxy_throws_if_wrong_number_of_constructor_args()
 {
     using (var context = new NeweyContext())
     {
         Assert.Throws <InvalidProxyConstructorArgumentsException>(() => context.CreateProxy <March881>(77, 88, 99));
     }
 }
Exemplo n.º 4
0
 public void CreateProxy_throws_if_constructor_args_do_not_match()
 {
     using (var context = new NeweyContext())
     {
         Assert.Throws <InvalidProxyConstructorArgumentsException>(() => context.CreateProxy <March881>(77, 88));
     }
 }
Exemplo n.º 5
0
        public void CreateProxy_throws_for_shared_type_entity_types_when_entity_type_name_not_known()
        {
            using var context = new NeweyContext();

            Assert.Equal(
                ProxiesStrings.EntityTypeNotFoundShared(nameof(SharedTypeEntityType)),
                Assert.Throws <InvalidOperationException>(() => context.CreateProxy <SharedTypeEntityType>()).Message);

            Assert.Equal(
                ProxiesStrings.EntityTypeNotFoundShared(nameof(SharedTypeEntityType)),
                Assert.Throws <InvalidOperationException>(() => context.CreateProxy <SharedTypeEntityType>(_ => { })).Message);

            Assert.Equal(
                ProxiesStrings.EntityTypeNotFoundShared(nameof(SharedTypeEntityType)),
                Assert.Throws <InvalidOperationException>(() => context.CreateProxy(typeof(SharedTypeEntityType))).Message);
        }
        [ConditionalFact] // Issue #22407
        public void CreateProxy_throws_for_weak_entity_types()
        {
            using var context = new NeweyContext();

            Assert.Equal(
                ProxiesStrings.EntityTypeNotFoundWeak(nameof(IsWeak)),
                Assert.Throws <InvalidOperationException>(() => context.CreateProxy <IsWeak>()).Message);

            Assert.Equal(
                ProxiesStrings.EntityTypeNotFoundWeak(nameof(IsWeak)),
                Assert.Throws <InvalidOperationException>(() => context.CreateProxy <IsWeak>(_ => { })).Message);

            Assert.Equal(
                ProxiesStrings.EntityTypeNotFoundWeak(nameof(IsWeak)),
                Assert.Throws <InvalidOperationException>(() => context.CreateProxy(typeof(IsWeak))).Message);
        }
Exemplo n.º 7
0
        public void CreateProxy_uses_parameterized_constructor()
        {
            using var context = new NeweyContext();
            var proxy = context.CreateProxy <March881>(77, "Leyton House");

            Assert.Same(typeof(March881), proxy.GetType().BaseType);
            Assert.Equal(77, proxy.Id);
            Assert.Equal("Leyton House", proxy.Sponsor);
        }
Exemplo n.º 8
0
        public void CreateProxy_uses_parameterized_constructor_taking_context()
        {
            using var context = new NeweyContext();
            var proxy = context.CreateProxy <WilliamsFw14>(context, 6, "Canon");

            Assert.Same(typeof(WilliamsFw14), proxy.GetType().BaseType);
            Assert.Same(context, proxy.Context);
            Assert.Equal(6, proxy.Id);
            Assert.Equal("Canon", proxy.Sponsor);
        }