public void Execute_CalledSynchronously() {
            // Arrange
            HttpApplication app = new HttpApplication();
            Mock<ControllerContext> mockControllerContext = new Mock<ControllerContext>();
            mockControllerContext.Expect(o => o.HttpContext.ApplicationInstance).Returns(app);

            AsyncActionDescriptor actionDescriptor = new SynchronouslyCalledAsyncActionDescriptor();

            // Act
            object retVal;
            lock (app) {
                retVal = actionDescriptor.Execute(mockControllerContext.Object, null);
            }

            // Assert
            Assert.AreEqual(retVal, "sample value");
        }
Ejemplo n.º 2
0
        public void Execute_CalledSynchronously()
        {
            // Arrange
            HttpApplication          app = new HttpApplication();
            Mock <ControllerContext> mockControllerContext = new Mock <ControllerContext>();

            mockControllerContext.Setup(o => o.HttpContext.ApplicationInstance).Returns(app);

            AsyncActionDescriptor actionDescriptor = new SynchronouslyCalledAsyncActionDescriptor();

            // Act
            object retVal;

            lock (app) {
                retVal = actionDescriptor.Execute(mockControllerContext.Object, null);
            }

            // Assert
            Assert.AreEqual(retVal, "sample value");
        }