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)); }
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); }
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); }
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); }