public static async Task Returns_stay_interrupted_status_when_no_user_requests_exist()
        {
            var activeDates = new[] { 12.July(2021) };

            var dateCalculator = CreateDateCalculator.WithActiveDates(activeDates);

            var requests = new[]
            {
                new Request("user2", 12.July(2021), RequestStatus.SoftInterrupted),
            };

            var users = new[]
            {
                CreateUser.With(userId: "user1", firstName: "Cathie", lastName: "Phoenix"),
            };

            var controller = new DailyDetailsController(
                dateCalculator,
                CreateRequestRepository.WithRequests(activeDates, requests),
                Mock.Of <ITriggerRepository>(),
                CreateUserRepository.WithUsers(users))
            {
                ControllerContext = CreateControllerContext.WithUsername("user1")
            };

            var result = await controller.GetAsync();

            var resultValue = GetResultValue <DailyDetailsResponse>(result);

            var actual = GetDailyData(resultValue.Details, 12.July(2021)).StayInterruptedStatus;

            Assert.False(actual.IsAllowed);
            Assert.False(actual.IsSet);
        }
        public static async Task Highlights_active_user()
        {
            var activeDates = new[] { 16.July(2021), 17.July(2021), 18.July(2021) };

            var dateCalculator = CreateDateCalculator.WithActiveDates(activeDates);

            var users = new[]
            {
                CreateUser.With(userId: "user1", firstName: "Cathie", lastName: "Phoenix"),
                CreateUser.With(userId: "user2", firstName: "Hynda", lastName: "Lindback"),
            };

            var requests = new[]
            {
                new Request("user1", 16.July(2021), RequestStatus.Allocated),
                new Request("user2", 16.July(2021), RequestStatus.SoftInterrupted),
                new Request("user1", 17.July(2021), RequestStatus.Interrupted),
                new Request("user2", 17.July(2021), RequestStatus.Allocated),
                new Request("user2", 18.July(2021), RequestStatus.Pending),
            };

            var controller = new DailyDetailsController(
                dateCalculator,
                CreateRequestRepository.WithRequests(activeDates, requests),
                Mock.Of <ITriggerRepository>(),
                CreateUserRepository.WithUsers(users))
            {
                ControllerContext = CreateControllerContext.WithUsername("user2")
            };

            var result = await controller.GetAsync();

            var resultValue = GetResultValue <DailyDetailsResponse>(result);

            var day1Data = GetDailyData(resultValue.Details, 16.July(2021));
            var day2Data = GetDailyData(resultValue.Details, 17.July(2021));
            var day3Data = GetDailyData(resultValue.Details, 18.July(2021));

            Assert.False(day1Data.AllocatedUsers.Single().IsHighlighted);
            Assert.True(day1Data.InterruptedUsers.Single().IsHighlighted);

            Assert.True(day2Data.AllocatedUsers.Single().IsHighlighted);
            Assert.False(day2Data.InterruptedUsers.Single().IsHighlighted);

            Assert.True(day3Data.PendingUsers.Single().IsHighlighted);
        }
        public static async Task Groups_allocated_and_interrupted_users_sorted_by_last_name()
        {
            var activeDates = new[] { 12.July(2021) };

            var dateCalculator = CreateDateCalculator.WithActiveDates(activeDates);

            var users = new[]
            {
                CreateUser.With(userId: "user1", firstName: "Cathie", lastName: "Phoenix"),
                CreateUser.With(userId: "user2", firstName: "Hynda", lastName: "Lindback"),
                CreateUser.With(userId: "user3", firstName: "Shannen", lastName: "Muddicliffe"),
                CreateUser.With(userId: "user4", firstName: "Marco", lastName: "Call"),
                CreateUser.With(userId: "user5", firstName: "Eugenio", lastName: "Veazey"),
                CreateUser.With(userId: "user6", firstName: "Evangelin", lastName: "Calway"),
            };

            var requests = new[]
            {
                new Request("user1", 12.July(2021), RequestStatus.Allocated),
                new Request("user2", 12.July(2021), RequestStatus.Allocated),
                new Request("user3", 12.July(2021), RequestStatus.Interrupted),
                new Request("user4", 12.July(2021), RequestStatus.SoftInterrupted),
                new Request("user5", 12.July(2021), RequestStatus.Pending),
                new Request("user6", 12.July(2021), RequestStatus.Pending),
            };

            var controller = new DailyDetailsController(
                dateCalculator,
                CreateRequestRepository.WithRequests(activeDates, requests),
                Mock.Of <ITriggerRepository>(),
                CreateUserRepository.WithUsers(users))
            {
                ControllerContext = CreateControllerContext.WithUsername("user1")
            };

            var result = await controller.GetAsync();

            var resultValue = GetResultValue <DailyDetailsResponse>(result);

            var data = GetDailyData(resultValue.Details, 12.July(2021));

            Assert.Equal(new[] { "Hynda Lindback", "Cathie Phoenix" }, data.AllocatedUsers.Select(u => u.Name));
            Assert.Equal(new[] { "Marco Call", "Shannen Muddicliffe" }, data.InterruptedUsers.Select(u => u.Name));
            Assert.Equal(new[] { "Evangelin Calway", "Eugenio Veazey" }, data.PendingUsers.Select(u => u.Name));
        }
        public static async Task Returns_details_data_for_each_active_date()
        {
            var activeDates = new[] { 12.July(2021), 13.July(2021), 16.July(2021) };

            var dateCalculator = CreateDateCalculator.WithActiveDates(activeDates);

            var controller = new DailyDetailsController(
                dateCalculator,
                CreateRequestRepository.WithRequests(activeDates, new List <Request>()),
                Mock.Of <ITriggerRepository>(),
                CreateUserRepository.WithUsers(new List <User>()))
            {
                ControllerContext = CreateControllerContext.WithUsername("user1")
            };

            var result = await controller.GetAsync();

            var resultValue = GetResultValue <DailyDetailsResponse>(result);

            Assert.Equal(activeDates, resultValue.Details.Select(d => d.LocalDate));
        }
        public static async Task Ignores_cancelled_requests()
        {
            var activeDates = new[] { 16.July(2021), 17.July(2021) };

            var dateCalculator = CreateDateCalculator.WithActiveDates(activeDates);

            var users = new[]
            {
                CreateUser.With(userId: "user1", firstName: "Cathie", lastName: "Phoenix"),
                CreateUser.With(userId: "user2", firstName: "Hynda", lastName: "Lindback"),
                CreateUser.With(userId: "user3", firstName: "Shannen", lastName: "Muddicliffe"),
            };

            var requests = new[]
            {
                new Request("user1", 16.July(2021), RequestStatus.Cancelled),
                new Request("user2", 16.July(2021), RequestStatus.Cancelled),
                new Request("user3", 17.July(2021), RequestStatus.Cancelled),
            };

            var controller = new DailyDetailsController(
                dateCalculator,
                CreateRequestRepository.WithRequests(activeDates, requests),
                Mock.Of <ITriggerRepository>(),
                CreateUserRepository.WithUsers(users))
            {
                ControllerContext = CreateControllerContext.WithUsername("user1")
            };

            var result = await controller.GetAsync();

            var resultValue = GetResultValue <DailyDetailsResponse>(result);

            var day1Data = GetDailyData(resultValue.Details, 16.July(2021));
            var day2Data = GetDailyData(resultValue.Details, 17.July(2021));

            Assert.Empty(day1Data.AllocatedUsers);
            Assert.Empty(day1Data.InterruptedUsers);
            Assert.Empty(day2Data.PendingUsers);
        }