public void WhenJsonGetFleetStatisticSeries_ThenReturnsJsonData()
        {
            var user = new User {UserId = 1, AuthorizationId = "AuthorizationId", DisplayName = "DisplayName"};

            userServicesMock.Setup(r => r.GetUserByClaimedIdentifier(It.IsAny<string>())).Returns(user);

            var target = new HomeController(
                userServicesMock.Object,
                chartDataServiceMock.Object);

            target.SetFakeControllerContext();
            target.SetUserIdentity(new MileageStatsIdentity(this.user.AuthorizationId,
                                                            this.user.DisplayName,
                                                            this.user.UserId));

            var series = new StatisticSeries();

            chartDataServiceMock.Setup(x => x.CalculateSeriesForUser(user.UserId, null, null)).Returns(
                series);

            ActionResult actual = target.JsonGetFleetStatisticSeries();

            var actualJsonResult = actual as JsonResult;
            Assert.NotNull(actualJsonResult);
            Assert.Same(series, actualJsonResult.Data);
        }
        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);
        }