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); }
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); }