using System;
using System.Collections.Generic;
using System.Reflection;
using Xunit;

namespace VCommon.Ioc.Tests
{
    public class InterceptorTest
    {
        private class Interceptor : IInterceptor, ITransientIocClass
        {
            public void BeforeInvoke(Type svcClass, MethodBase svcMethod, IReadOnlyDictionary<string, object> paramDic)
            {
            }

            public void AfterInvoke(Type svcClass, MethodBase svcMethod, IReadOnlyDictionary<string, object> paramDic, object resultReturnValue, Exception resultException)
            {
            }
        }

        public interface ITestInterface
        {
            int TestMethod(int value);
        }

        private class TestClass : ITestInterface, ITransientIocClass<IInterceptor>
        {
            public int TestMethod(int value)
            {
                return value + 1;
            }
        }

        [Fact]
        public void Test()
        {
            var container = new IocManager();
            var child = container.CreateChildren();
            child.RegisterInstanceToContainer(child);

            var svc = container.Resolve<ITestInterface>();

            var ret = svc.TestMethod(1);
        }
    }
}
