示例#1
0
        public void WhenOneConstructorNoArgs()
        {
            var p = AopTestExtensions.ConfigServiceCollectionWithAop(i => i.AddTransient <OneConstructorNoArgs>())
                    .GetRequiredService <OneConstructorNoArgs>();
            var pt = p.GetType();

            Assert.True(pt.IsProxyType());
            Assert.Null(pt.CreateInstanceGetter());
            Assert.NotNull(pt.CreateServiceProviderGetter()(p));
        }
示例#2
0
        public void WhenAbstractTwoConstructorOneArgs()
        {
            var v = AopTestExtensions.ConfigServiceCollectionWithAop(i => i.AddTransient <AbstractTwoConstructorOneArgs>().AddTransient <ConstructorTest>())
                    .GetRequiredService <AbstractTwoConstructorOneArgs>();
            var pt = v.GetType();

            Assert.True(pt.IsProxyType());
            Assert.Null(pt.CreateInstanceGetter());
            Assert.NotNull(pt.CreateServiceProviderGetter()(v));
            Assert.NotNull(v);
            Assert.NotNull(v.A);
        }
示例#3
0
        public void WhenOneConstructorOneStringArgs()
        {
            var v = AopTestExtensions.ConfigServiceCollectionWithAop(i => i.AddSingleton(i => new OneConstructorOneStringArgs("a")))
                    .GetRequiredService <OneConstructorOneStringArgs>();
            var pt = v.GetType();

            Assert.True(pt.IsProxyType());
            Assert.NotNull(pt.CreateInstanceGetter()(v));
            Assert.NotNull(pt.CreateServiceProviderGetter()(v));
            Assert.NotNull(v);
            Assert.NotNull(v.A);
            Assert.Equal("a", v.A);
        }
示例#4
0
        public void WhenTwoConstructorOneArgsAndCustomAttribute()
        {
            var v = AopTestExtensions.ConfigServiceCollectionWithAop(i => i.AddTransient <TwoConstructorOneArgs>().AddTransient <ConstructorTest>())
                    .GetRequiredService <TwoConstructorOneArgs>();
            var pt = v.GetType();

            Assert.True(pt.IsProxyType());
            Assert.Null(pt.CreateInstanceGetter());
            Assert.NotNull(pt.CreateServiceProviderGetter()(v));
            Assert.NotNull(v.A);
            Assert.Equal(2, pt.GetCustomAttribute <TestDataAttribute>().V);
            Assert.Equal(99, pt.GetConstructors()[0].GetCustomAttribute <TestDataAttribute>().V);
            Assert.Equal(4, pt.GetConstructors()[0].GetParameters()[0].GetCustomAttribute <TestDataAttribute>().V);
            Assert.NotNull(v.AAa);
            Assert.Null(v.Ba);
        }