public async Task CancelShift_Shift_GetShiftRepoHitCorrectly()
        {
            // Arrange
            DateTime now = DateTime.Now;
            IRepository <Library.Models.Shift> shiftRepository = Substitute.For <IRepository <Library.Models.Shift> >();

            shiftRepository.Get(Arg.Any <string>(), Arg.Any <IDictionary <string, object> >(), Arg.Any <string>()).Returns(new[]
            {
                new Library.Models.Shift {
                    StartDateTime = now, LocationId = "1", Allocated = true, EmployeeId = "abc"
                },
                new Library.Models.Shift {
                    StartDateTime = now.Add(new TimeSpan(1, 0, 0, 0)), LocationId = "1", Allocated = true, EmployeeId = "xyz"
                }
            });

            ILocationService locationService = Substitute.For <ILocationService>();

            locationService.GetByName("Contoso").Returns(new Library.Models.Location {
                id = "1", Name = "Contoso"
            });

            ShiftsController controller = this.GetController(shiftRepository: shiftRepository, locationService: locationService);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();
            controller.HttpContext.User = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim("http://schemas.microsoft.com/identity/claims/objectidentifier", "123") }));
            ShiftViewModel viewModel = new ShiftViewModel {
                LocationName = "Contoso", Start = now, End = now.AddHours(9), WorkType = "Till"
            };

            // Act
            await controller.CancelShift(viewModel);

            // Assert
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            shiftRepository.Received(1).Get(
                Arg.Is <string>("SELECT * FROM c WHERE c.LocationId = @locationId AND c.StartDateTime = @start AND c.EndDateTime = @end AND c.WorkType = @workType AND c.Allocated = true AND c.EmployeeId = @employeeId"),
                Arg.Any <Dictionary <string, object> >(),
                Arg.Any <string>());
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
        }
        public async Task CancelShift_NoIdClaim_Exception()
        {
            // Arrange
            DateTime         now        = DateTime.Now;
            ShiftsController controller = this.GetController();

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();
            controller.HttpContext.User = new ClaimsPrincipal(new ClaimsIdentity());
            ShiftViewModel viewModel = new ShiftViewModel {
                LocationName = "Contoso", Start = now, End = now.AddHours(9), WorkType = "Till"
            };

            // Assert
            ArgumentException exception = await Assert.ThrowsAsync <ArgumentException>(() => controller.CancelShift(viewModel));

            Assert.Equal("http://schemas.microsoft.com/identity/claims/objectidentifier claim is required", exception.Message);
        }