public void InvokeAsync_DelegatesToInstanceFactoryAndMethodInvoker()
        {
            // Arrange
            object expectedInstance = new object();

            object[] expectedArguments = new object[0];

            Mock <IFactory <object> > instanceFactoryMock = new Mock <IFactory <object> >(MockBehavior.Strict);

            instanceFactoryMock.Setup(f => f.Create())
            .Returns(expectedInstance)
            .Verifiable();
            IFactory <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;

            IFunctionInvoker product = CreateProductUnderTest(instanceFactory, methodInvoker);

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

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

            // Assert
            instanceFactoryMock.VerifyAll();
            methodInvokerMock.VerifyAll();
        }
Beispiel #2
0
 public object CreateInstance()
 {
     return(_functionInvoker.CreateInstance());
 }
 public object CreateInstance()
 {
     return(_inner.CreateInstance());
 }