Esempio n. 1
0
        public void InvokeAsync_DelegatesToInstanceFactoryAndMethodInvoker()
        {
            // Arrange
            object expectedInstance = new object();

            object[] expectedArguments = new object[0];

            IFunctionInstanceEx functionInstance = new Mock <IFunctionInstanceEx>().Object;
            Mock <IJobInstanceFactory <object> > instanceFactoryMock = new Mock <IJobInstanceFactory <object> >(MockBehavior.Strict);

            instanceFactoryMock.Setup(f => f.Create(It.IsAny <IFunctionInstanceEx>()))
            .Returns(expectedInstance)
            .Verifiable();
            IJobInstanceFactory <object> instanceFactory = instanceFactoryMock.Object;

            Mock <IMethodInvoker <object, object> > methodInvokerMock = new Mock <IMethodInvoker <object, object> >(MockBehavior.Strict);

            methodInvokerMock.Setup(i => i.InvokeAsync(expectedInstance, expectedArguments))
            .Returns(Task.FromResult <object>(null))
            .Verifiable();
            IMethodInvoker <object, object> methodInvoker = methodInvokerMock.Object;

            IFunctionInvokerEx product = CreateProductUnderTest(instanceFactory, methodInvoker);

            // Act
            var instance = product.CreateInstance(functionInstance);

            product.InvokeAsync(instance, expectedArguments).GetAwaiter().GetResult();

            // Assert
            instanceFactoryMock.VerifyAll();
            methodInvokerMock.VerifyAll();
        }
 public TriggeredFunctionInstanceFactory(ITriggeredFunctionBinding <TTriggerValue> binding,
                                         IFunctionInvokerEx invoker, FunctionDescriptor descriptor)
 {
     _binding    = binding;
     _invoker    = invoker;
     _descriptor = descriptor;
 }
        private FunctionDefinition CreateTriggeredFunctionDefinition <TTriggerValue>(
            ITriggerBinding triggerBinding, string parameterName, FunctionDescriptor descriptor,
            IReadOnlyDictionary <string, IBinding> nonTriggerBindings, IFunctionInvokerEx invoker)
        {
            ITriggeredFunctionBinding <TTriggerValue>         functionBinding = new TriggeredFunctionBinding <TTriggerValue>(descriptor, parameterName, triggerBinding, nonTriggerBindings, _singletonManager);
            ITriggeredFunctionInstanceFactory <TTriggerValue> instanceFactory = new TriggeredFunctionInstanceFactory <TTriggerValue>(functionBinding, invoker, descriptor);
            ITriggeredFunctionExecutor triggerExecutor = new TriggeredFunctionExecutor <TTriggerValue>(descriptor, _executor, instanceFactory);
            IListenerFactory           listenerFactory = new ListenerFactory(descriptor, triggerExecutor, triggerBinding, _sharedQueue);

            return(new FunctionDefinition(descriptor, instanceFactory, listenerFactory));
        }
 public InvokeWrapper(IFunctionInvokerEx inner, Func <Func <Task <object> >, Task <object> > handler)
 {
     _inner   = inner;
     _handler = handler;
 }