コード例 #1
0
        public DefaultFunctionInvokerTests()
        {
            _executor = new DefaultFunctionExecutor();

            var functionActivator    = new DefaultFunctionActivator();
            var methodInvokerFactory = new DefaultMethodInvokerFactory();

            _functionInvokerFactory = new DefaultFunctionInvokerFactory(methodInvokerFactory, functionActivator);
        }
コード例 #2
0
        public DefaultFunctionInvokerFactoryTests()
        {
            Mock <IMethodInfoLocator> invokerMock = new Mock <IMethodInfoLocator>(MockBehavior.Strict);

            invokerMock
            .Setup(p => p.GetMethod(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(() => _functionMethod);

            _methodInvokerFactory = CreateMethodInvokerFactory();
            _activator            = new DefaultFunctionActivator();
            _invokerFactory       = new DefaultFunctionInvokerFactory(_methodInvokerFactory, _activator, invokerMock.Object);
        }
コード例 #3
0
        public DefaultFunctionInvokerTests()
        {
            _mockLocator
            .Setup(m => m.GetMethod(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(() => _methodInfoToReturn);

            var functionActivator    = new DefaultFunctionActivator();
            var methodInvokerFactory = new DefaultMethodInvokerFactory();

            _functionInvokerFactory = new DefaultFunctionInvokerFactory(methodInvokerFactory, functionActivator, _mockLocator.Object);

            _executor = new DefaultFunctionExecutor(_functionInvokerFactory, NullLogger <DefaultFunctionExecutor> .Instance);
        }
        public void Create_IfInstanceAndMethodIsInherited_UsesReflectedType()
        {
            // Arrange
            MethodInfo method = GetMethodInfo(typeof(Subclass), nameof(Subclass.InheritedReturnVoid));

            IMethodInvokerFactory methodInvokerFactory = CreateMethodInvokerFactory();
            IFunctionActivator    activator            = new DefaultFunctionActivator();

            IFunctionInvokerFactory _invokerFactory = new DefaultFunctionInvokerFactory(methodInvokerFactory, activator);

            // Act
            IFunctionInvoker invoker = _invokerFactory.Create(method);

            // Assert
            Assert.IsType <DefaultFunctionInvoker <Subclass, object> >(invoker);
            var typedInvoker = (DefaultFunctionInvoker <Subclass, object>)invoker;

            Assert.IsType <DefaultFunctionActivator>(typedInvoker.FunctionActivator);
        }
        public void Create_IfInstance_UsesActivatorInstanceFactory()
        {
            // Arrange
            MethodInfo method = GetMethodInfo(nameof(DefaultFunctionInvokerFactoryTests.InstanceReturnVoid));

            IMethodInvokerFactory methodInvokerFactory = CreateMethodInvokerFactory();
            IFunctionActivator    activator            = new DefaultFunctionActivator();

            IFunctionInvokerFactory _invokerFactory = new DefaultFunctionInvokerFactory(methodInvokerFactory, activator);

            // Act
            IFunctionInvoker invoker = _invokerFactory.Create(method);

            // Assert
            Assert.IsType <DefaultFunctionInvoker <DefaultFunctionInvokerFactoryTests, object> >(invoker);
            var typedInvoker = (DefaultFunctionInvoker <DefaultFunctionInvokerFactoryTests, object>)invoker;

            Assert.IsType <DefaultFunctionActivator>(typedInvoker.FunctionActivator);
        }