<commit_before>﻿using System;
using Castle.DynamicProxy;
using Xunit;

namespace Autofac.Extras.DynamicProxy.Test
{
    public class InterfaceInterceptionWithPropertyInjectionFixture
    {
        [Fact]
        public void InterfaceInterceptorsSupportPropertyInjection()
        {
            var builder = new ContainerBuilder();
            builder.RegisterType<StringMethodInterceptor>();

            builder.RegisterType<OtherImpl>().As<IOtherService>();

            builder
                .RegisterType<InterceptableWithProperty>()
                .PropertiesAutowired()
                .EnableInterfaceInterceptors()
                .InterceptedBy(typeof(StringMethodInterceptor))
                .As<IPublicInterface>();
            var container = builder.Build();
            var obj = container.Resolve<IPublicInterface>();

            Assert.NotNull(obj.GetServiceProperty());
            Assert.Equal("intercepted-PublicMethod", obj.PublicMethod());
        }

        [Fact(Skip = "https://github.com/autofac/Autofac/issues/758")]
        public void InterfaceInterceptorsSupportCircularPropertyInjection()
        {
            var builder = new ContainerBuilder();
            builder.RegisterType<StringMethodInterceptor>();

            builder.RegisterType<OtherImpl>().As<IOtherService>();

            builder
                .RegisterType<InterceptableWithProperty>()
                .As<IPublicInterface>()
                .PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies)
                .EnableInterfaceInterceptors()
                .InterceptedBy(typeof(StringMethodInterceptor));
            var container = builder.Build();
            var obj = container.Resolve<IPublicInterface>();

            Assert.NotNull(obj.GetServiceProperty());
            Assert.Equal("intercepted-PublicMethod", obj.PublicMethod());
        }

        public interface IOtherService
        {
        }

        public class OtherImpl : IOtherService<commit_msg>v6 update fixed #40, unskipping test<commit_after>﻿using System;
using Castle.DynamicProxy;
using Xunit;

namespace Autofac.Extras.DynamicProxy.Test
{
    public class InterfaceInterceptionWithPropertyInjectionFixture
    {
        [Fact]
        public void InterfaceInterceptorsSupportPropertyInjection()
        {
            var builder = new ContainerBuilder();
            builder.RegisterType<StringMethodInterceptor>();

            builder.RegisterType<OtherImpl>().As<IOtherService>();

            builder
                .RegisterType<InterceptableWithProperty>()
                .PropertiesAutowired()
                .EnableInterfaceInterceptors()
                .InterceptedBy(typeof(StringMethodInterceptor))
                .As<IPublicInterface>();
            var container = builder.Build();
            var obj = container.Resolve<IPublicInterface>();

            Assert.NotNull(obj.GetServiceProperty());
            Assert.Equal("intercepted-PublicMethod", obj.PublicMethod());
        }

        [Fact]
        public void InterfaceInterceptorsSupportCircularPropertyInjection()
        {
            var builder = new ContainerBuilder();
            builder.RegisterType<StringMethodInterceptor>();

            builder.RegisterType<OtherImpl>().As<IOtherService>();

            builder
                .RegisterType<InterceptableWithProperty>()
                .As<IPublicInterface>()
                .PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies)
                .EnableInterfaceInterceptors()
                .InterceptedBy(typeof(StringMethodInterceptor));
            var container = builder.Build();
            var obj = container.Resolve<IPublicInterface>();

            Assert.NotNull(obj.GetServiceProperty());
            Assert.Equal("intercepted-PublicMethod", obj.PublicMethod());
        }

        public interface IOtherService
        {
        }

        public class OtherImpl : IOtherService
{'fraction_non_alphanumeric': 0.0921949987370548, 'fraction_numerical': 0.0015155342258145997, 'mean_word_length': 2.353090601185436, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '538617', 'n_tokens_mistral': 935, 'n_tokens_neox': 889, 'n_words': 141}