コード例 #1
0
        public void WhenRequestingIndexWhileAuthenticated_ThenRedirectsToDashboard()
        {
            var controller = new HomeController(
                userServicesMock.Object,
                chartDataServiceMock.Object);

            controller.SetFakeControllerContext();
            controller.SetUserIdentity(new MileageStatsIdentity("TestName", "TestDisplayName", 1));
            Mock<HttpRequestBase> requestMock = Mock.Get(controller.Request);
            requestMock.Setup(r => r.IsAuthenticated).Returns(true);

            ActionResult result = controller.Index();

            Assert.IsType<RedirectToRouteResult>(result);
            var redirect = (RedirectToRouteResult) result;

            Assert.Equal("Dashboard", redirect.RouteName);
        }
コード例 #2
0
        public void WhenRequestingIndex_ThenReturnsView()
        {
            var controller = new HomeController(
                userServicesMock.Object,
                chartDataServiceMock.Object);
            controller.SetFakeControllerContext();

            ActionResult result = controller.Index();

            Assert.IsType<ViewResult>(result);
            Assert.Equal(String.Empty, ((ViewResult) result).ViewName);
        }