Example #1
0
        public void GetAsyncManagerThrowsIfControllerIsNotAsyncManagerContainer()
        {
            // Arrange
            ControllerBase controller = new MyController();

            // Act & assert
            ExceptionHelper.ExpectInvalidOperationException(
                delegate {
                AsyncActionDescriptor.GetAsyncManager(controller);
            },
                @"The controller of type 'Microsoft.Web.Mvc.Test.AsyncActionDescriptorTest+MyController' must subclass AsyncController or implement the IAsyncManagerContainer interface.");
        }
Example #2
0
        public void GetAsyncManager()
        {
            // Arrange
            AsyncManager asyncHelper = new AsyncManager();

            Mock <Controller> mockController = new Mock <Controller>();

            mockController.As <IAsyncManagerContainer>().Expect(c => c.AsyncManager).Returns(asyncHelper);
            Controller controller = mockController.Object;

            // Act
            AsyncManager returned = AsyncActionDescriptor.GetAsyncManager(controller);

            // Assert
            Assert.AreEqual(asyncHelper, returned);
        }