Test environment: in Autofac. Extras. DynamicProxy. Test. AttributedInterfaceInterceptionFixture, Test to fail.
A:
[Fact]
public void FindsInterceptionAttributeOnReflectionComponentWithClass()
{
var builder = new ContainerBuilder();
builder.RegisterType<C>().EnableClassInterceptors().InterceptedBy(typeof(AddOneInterceptor));
builder.RegisterType<AddOneInterceptor>();
var cpt = builder.Build().Resolve<C>();
Assert.Equal(11, cpt.GetI());
}
B:
[Fact]
public void FindsInterceptionAttributeOnReflectionComponentWithClass2()
{
var builder = new ContainerBuilder();
builder.RegisterType<C2>().EnableClassInterceptors();
builder.RegisterType<AddOneInterceptor>();
var cpt = builder.Build().Resolve<C2>();
Assert.Equal(11, cpt.GetI());
}
[Intercept(typeof(AddOneInterceptor))]
public class C2 : IHasI
{
public C2()
{
I = 10;
}
public int I { get; private set; }
public int GetI()
{
return I;
}
Test environment: in Autofac. Extras. DynamicProxy. Test. AttributedInterfaceInterceptionFixture, Test to fail. A: [Fact] public void FindsInterceptionAttributeOnReflectionComponentWithClass() { var builder = new ContainerBuilder(); builder.RegisterType<C>().EnableClassInterceptors().InterceptedBy(typeof(AddOneInterceptor)); builder.RegisterType<AddOneInterceptor>(); var cpt = builder.Build().Resolve<C>(); Assert.Equal(11, cpt.GetI()); } B: [Fact] public void FindsInterceptionAttributeOnReflectionComponentWithClass2() { var builder = new ContainerBuilder(); builder.RegisterType<C2>().EnableClassInterceptors(); builder.RegisterType<AddOneInterceptor>(); var cpt = builder.Build().Resolve<C2>(); Assert.Equal(11, cpt.GetI()); } [Intercept(typeof(AddOneInterceptor))] public class C2 : IHasI { public C2() { I = 10; }
}