当前位置: 首页>>代码示例>>C#>>正文


C# EmptyController类代码示例

本文整理汇总了C#中EmptyController的典型用法代码示例。如果您正苦于以下问题:C# EmptyController类的具体用法?C# EmptyController怎么用?C# EmptyController使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EmptyController类属于命名空间,在下文中一共展示了EmptyController类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExecuteCoreWithAsynchronousInvokerAndActionCompletesSuccessfully

        public void ExecuteCoreWithAsynchronousInvokerAndActionCompletesSuccessfully() {
            // Arrange
            ControllerContext controllerContext = GetControllerContext();
            MockAsyncResult asyncResult = new MockAsyncResult();

            Mock<ITempDataProvider> mockTempDataProvider = new Mock<ITempDataProvider>();
            mockTempDataProvider.Expect(p => p.LoadTempData(controllerContext)).Returns(new Dictionary<string, object>()).Verifiable();
            mockTempDataProvider.Expect(p => p.SaveTempData(controllerContext, It.IsAny<IDictionary<string, object>>())).AtMostOnce().Verifiable();

            Mock<IAsyncActionInvoker> mockInvoker = new Mock<IAsyncActionInvoker>();
            mockInvoker.Expect(i => i.BeginInvokeAction(controllerContext, "SomeAction", It.IsAny<AsyncCallback>(), It.IsAny<object>())).Returns(asyncResult).Verifiable();
            mockInvoker.Expect(i => i.EndInvokeAction(asyncResult)).Returns(true).Verifiable();

            EmptyController controller = new EmptyController() {
                ControllerContext = controllerContext,
                TempDataProvider = mockTempDataProvider.Object,
                ActionInvoker = mockInvoker.Object
            };

            // Act
            IAsyncResult returnedAsyncResult = controller.BeginExecuteCore(null, null);
            controller.TempData["key"] = "value";
            controller.EndExecuteCore(returnedAsyncResult);

            // Assert
            mockInvoker.Verify();
            mockTempDataProvider.Verify();
        }
开发者ID:Marceli,项目名称:JQueryGridTest,代码行数:28,代码来源:AsyncControllerTest.cs

示例2: ActionInvokerProperty

        public void ActionInvokerProperty() {
            // Arrange
            Controller controller = new EmptyController();

            // Act & Assert
            MemberHelper.TestPropertyWithDefaultInstance(controller, "ActionInvoker", new ControllerActionInvoker());
        }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:7,代码来源:ControllerTest.cs

示例3: Execute_ThrowsIfRequestContextIsNull

        public void Execute_ThrowsIfRequestContextIsNull()
        {
            // Arrange
            IAsyncController controller = new EmptyController();

            // Act & assert
            Assert.ThrowsArgumentNull(
                delegate { controller.BeginExecute(null, null, null); }, "requestContext");
        }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:9,代码来源:AsyncControllerTest.cs

示例4: ActionInvokerIsAsyncInvokerByDefault

        public void ActionInvokerIsAsyncInvokerByDefault() {
            // Arrange
            EmptyController controller = new EmptyController();

            // Act
            IActionInvoker invoker = controller.ActionInvoker;

            // Assert
            Assert.IsInstanceOfType(invoker, typeof(AsyncControllerActionInvoker));
        }
开发者ID:Marceli,项目名称:JQueryGridTest,代码行数:10,代码来源:AsyncControllerTest.cs

示例5: Execute_ThrowsIfRequestContextIsNull

        public void Execute_ThrowsIfRequestContextIsNull() {
            // Arrange
            IAsyncController controller = new EmptyController();

            // Act & assert
            ExceptionHelper.ExpectArgumentNullException(
                delegate {
                    controller.BeginExecute(null, null, null);
                }, "requestContext");
        }
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:10,代码来源:AsyncControllerTest.cs

示例6: AsyncManagerProperty

        public void AsyncManagerProperty() {
            // Arrange
            EmptyController controller = new EmptyController();

            // Act
            AsyncManager asyncManager = controller.AsyncManager;

            // Assert
            Assert.IsNotNull(asyncManager);
        }
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:10,代码来源:AsyncControllerTest.cs

示例7: ActionInvokerProperty

        public void ActionInvokerProperty() {
            // Arrange
            EmptyController controller = new EmptyController();

            // Act
            IActionInvoker invoker = controller.ActionInvoker;

            // Assert
            Assert.AreEqual(typeof(AsyncControllerActionInvoker), invoker.GetType());
        }
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:10,代码来源:AsyncControllerTest.cs

示例8: ActionInvokerProperty

        public void ActionInvokerProperty()
        {
            // Arrange
            EmptyController controller = new EmptyController();

            // Act
            IActionInvoker invoker = controller.ActionInvoker;

            // Assert
            Assert.IsType<AsyncControllerActionInvoker>(invoker);
        }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:11,代码来源:AsyncControllerTest.cs

示例9: ContentWithContentString

        public void ContentWithContentString() {
            // Arrange
            Controller controller = new EmptyController();
            string content = "Some content";

            // Act
            ContentResult result = controller.Content(content);

            // Assert
            Assert.AreEqual(content, result.Content);
        }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:11,代码来源:ControllerTest.cs

示例10: Execute_ThrowsIfCalledMoreThanOnce

        public void Execute_ThrowsIfCalledMoreThanOnce()
        {
            // Arrange
            IAsyncController controller = new EmptyController();
            RequestContext requestContext = GetRequestContext("SomeAction");

            // Act & assert
            controller.BeginExecute(requestContext, null, null);
            Assert.Throws<InvalidOperationException>(
                delegate { controller.BeginExecute(requestContext, null, null); },
                @"A single instance of controller 'System.Web.Mvc.Test.AsyncControllerTest+EmptyController' cannot be used to handle multiple requests. If a custom controller factory is in use, make sure that it creates a new instance of the controller for each request.");
        }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:12,代码来源:AsyncControllerTest.cs

示例11: OnAuthorizationSetsControllerValidateRequestToTrue

        public void OnAuthorizationSetsControllerValidateRequestToTrue() {
            // Arrange
            Controller controller = new EmptyController() { ValidateRequest = false };
            ValidateInputAttribute attr = new ValidateInputAttribute(enableValidation: true);
            AuthorizationContext authContext = GetAuthorizationContext(controller);

            // Act
            attr.OnAuthorization(authContext);

            // Assert
            Assert.IsTrue(controller.ValidateRequest);
        }
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:12,代码来源:ValidateInputAttributeTest.cs

示例12: HttpContextProperty

        public void HttpContextProperty() {
            var c = new EmptyController();
            Assert.IsNull(c.HttpContext, "Property should be null before Context is set");

            Mock<HttpContextBase> mockHttpContext = new Mock<HttpContextBase>();

            Mock<ControllerContext> mockControllerContext = new Mock<ControllerContext>();
            mockControllerContext.Setup(cc => cc.Controller).Returns(c);
            mockControllerContext.Setup(cc => cc.HttpContext).Returns(mockHttpContext.Object);

            c.ControllerContext = mockControllerContext.Object;
            Assert.AreEqual<HttpContextBase>(mockHttpContext.Object, c.HttpContext, "Property should equal the value on the Context.");
        }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:13,代码来源:ControllerTest.cs

示例13: ContentWithContentStringAndContentType

        public void ContentWithContentStringAndContentType()
        {
            // Arrange
            Controller controller = new EmptyController();
            string content = "Some content";
            string contentType = "Some content type";

            // Act
            ContentResult result = controller.Content(content, contentType);

            // Assert
            Assert.Equal(content, result.Content);
            Assert.Equal(contentType, result.ContentType);
        }
开发者ID:marojeri,项目名称:aspnetwebstack,代码行数:14,代码来源:ControllerTest.cs

示例14: ContentWithContentStringAndContentTypeAndEncoding

        public void ContentWithContentStringAndContentTypeAndEncoding() {
            // Arrange
            Controller controller = new EmptyController();
            string content = "Some content";
            string contentType = "Some content type";
            Encoding contentEncoding = Encoding.UTF8;

            // Act
            ContentResult result = controller.Content(content, contentType, contentEncoding);

            // Assert
            Assert.AreEqual(content, result.Content);
            Assert.AreEqual(contentType, result.ContentType);
            Assert.AreSame(contentEncoding, result.ContentEncoding);
        }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:15,代码来源:ControllerTest.cs

示例15: CreateCachedController_UnderlyingFactoryReturnsController

        public void CreateCachedController_UnderlyingFactoryReturnsController() {
            // Arrange
            RequestContext requestContext = GetRequestContext();
            EmptyController controller = new EmptyController();

            Mock<IControllerFactory> mockUnderlyingFactory = new Mock<IControllerFactory>();
            mockUnderlyingFactory.Expect(o => o.CreateController(requestContext, "home")).Returns(controller).AtMostOnce();
            MvcDynamicSessionControllerFactory factory = new MvcDynamicSessionControllerFactory(mockUnderlyingFactory.Object);

            // Act
            IController controller1 = factory.CreateCachedController(requestContext, "home");
            IController controller2 = factory.CreateController(requestContext, "home");

            // Assert
            Assert.AreEqual(controller, controller1);
            Assert.AreSame(controller1, controller2);
            mockUnderlyingFactory.Verify();
        }
开发者ID:consumentor,项目名称:Server,代码行数:18,代码来源:MvcDynamicSessionControllerFactoryTest.cs


注:本文中的EmptyController类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。