public async Task ExpireDuty()
        {
            var locationId = await CreateLocation();

            var startDate = DateTimeOffset.UtcNow.AddYears(5);
            var addDuty   = new Duty
            {
                Id         = 1,
                StartDate  = startDate,
                EndDate    = startDate.AddDays(5),
                LocationId = locationId
            };
            await Db.Duty.AddAsync(addDuty);

            await Db.SaveChangesAsync();

            HttpResponseTest.CheckForNoContentResponse(await _controller.ExpireDuties(new List <int> {
                1
            }));

            var controllerResult = await _controller.GetDuties(locationId, startDate, startDate.AddDays(1));

            var getDuties = HttpResponseTest.CheckForValid200HttpResponseAndReturnValue(controllerResult);

            Assert.Empty(getDuties);
        }
        public async Task GetDuties()
        {
            var locationId = await CreateLocation();

            var startDate = DateTimeOffset.UtcNow;
            var addDuty   = new Duty
            {
                Id         = 1,
                StartDate  = startDate,
                EndDate    = startDate.AddDays(5),
                LocationId = locationId
            };

            var addDutyExpiryDate = new Duty
            {
                Id         = 2,
                StartDate  = startDate,
                EndDate    = startDate.AddDays(5),
                ExpiryDate = startDate,
                LocationId = locationId
            };

            await Db.Duty.AddAsync(addDuty);

            await Db.Duty.AddAsync(addDutyExpiryDate);

            await Db.SaveChangesAsync();

            var controllerResult = await _controller.GetDuties(locationId, startDate, startDate.AddDays(1));

            var response = HttpResponseTest.CheckForValid200HttpResponseAndReturnValue(controllerResult);

            Assert.Single(response);
            Assert.Equal(1, response.First().Id);
        }
        public async Task ImportWeeklyShifts()
        {
            var sheriffId = Guid.NewGuid();
            var shiftDto  = await CreateShift();

            await Db.Sheriff.AddAsync(new Sheriff { Id = sheriffId, IsEnabled = true, HomeLocationId = 1 });

            await Db.SaveChangesAsync();

            shiftDto.LocationId = 1;
            shiftDto.StartDate  = DateTime.Now.AddDays(-(int)DateTime.Now.DayOfWeek - 6).AddYears(5); //Last week monday
            shiftDto.EndDate    = DateTime.Now.AddDays(-(int)DateTime.Now.DayOfWeek - 5).AddYears(5); //Last week tuesday
            shiftDto.SheriffId  = sheriffId;

            var shiftDtos = new List <ShiftDto> {
                shiftDto
            };
            var shift = HttpResponseTest.CheckForValid200HttpResponseAndReturnValue(await ShiftController.AddShifts(shiftDtos.Adapt <List <AddShiftDto> >()));

            var importedShifts = HttpResponseTest.CheckForValid200HttpResponseAndReturnValue(
                await ShiftController.ImportWeeklyShifts(1, shiftDto.StartDate));

            Assert.NotNull(importedShifts);
            var importedShift = importedShifts.Shifts.First();

            Assert.Equal(shiftDto.StartDate.AddDays(7).DateTime, importedShift.StartDate.DateTime, TimeSpan.FromSeconds(10)); //This week monday
            Assert.Equal(shiftDto.EndDate.AddDays(7).DateTime, importedShift.EndDate.DateTime, TimeSpan.FromSeconds(10));     //This week monday
            Assert.Equal(shiftDto.SheriffId, importedShift.SheriffId);
        }
 public ManageTypesControllerTests() : base(true)
 {
     _controller = new ManageTypesController(new ManageTypesService(Db), Db)
     {
         ControllerContext = HttpResponseTest.SetupMockControllerContext()
     };
 }
        public async Task ExpireDuty()
        {
            var location = new Location {
                Id = 1, AgencyId = "5555", Name = "dfd"
            };
            await Db.Location.AddAsync(location);

            var startDate = DateTimeOffset.UtcNow.AddYears(5);
            var addDuty   = new Duty
            {
                Id         = 1,
                StartDate  = startDate,
                EndDate    = startDate.AddDays(5),
                LocationId = 1
            };
            await Db.Duty.AddAsync(addDuty);

            await Db.SaveChangesAsync();

            HttpResponseTest.CheckForNoContentResponse(await _controller.ExpireDuty(1));

            var controllerResult = await _controller.GetDuties(1, startDate, startDate.AddDays(1));

            var getDuties = HttpResponseTest.CheckForValid200HttpResponseAndReturnValue(controllerResult);

            Assert.Empty(getDuties);
        }
        public FilesControllerTests()
        {
            //TODO NInject or some other resolvers.
            var fileServices          = new EnvironmentBuilder("FileServicesClient:Username", "FileServicesClient:Password", "FileServicesClient:Url");
            var lookupServices        = new EnvironmentBuilder("LookupServicesClient:Username", "LookupServicesClient:Password", "LookupServicesClient:Url");
            var locationServices      = new EnvironmentBuilder("LocationServicesClient:Username", "LocationServicesClient:Password", "LocationServicesClient:Url");
            var lookupServiceClient   = new LookupCodeServicesClient(lookupServices.HttpClient);
            var locationServiceClient = new LocationServicesClient(locationServices.HttpClient);
            var fileServicesClient    = new FileServicesClient(fileServices.HttpClient);

            _fileServicesClient = fileServicesClient;
            var lookupService   = new LookupService(lookupServices.Configuration, lookupServiceClient, new CachingService());
            var locationService = new LocationService(locationServices.Configuration, locationServiceClient, new CachingService());

            _agencyIdentifierId = fileServices.Configuration.GetNonEmptyValue("Request:AgencyIdentifierId");
            _partId             = fileServices.Configuration.GetNonEmptyValue("Request:PartId");
            var claims = new[] {
                new Claim(CustomClaimTypes.JcParticipantId, _partId),
                new Claim(CustomClaimTypes.JcAgencyCode, _agencyIdentifierId),
            };
            var identity  = new ClaimsIdentity(claims, "Cookies");
            var principal = new ClaimsPrincipal(identity);

            var filesService = new FilesService(fileServices.Configuration, fileServicesClient, new Mapper(), lookupService, locationService, new CachingService(), principal);

            //TODO fake this.
            var vcCivilFileAccessHandler = new VcCivilFileAccessHandler(new ScvDbContext());

            _controller = new FilesController(fileServices.Configuration, fileServices.LogFactory.CreateLogger <FilesController>(), filesService, vcCivilFileAccessHandler);
            _controller.ControllerContext = HttpResponseTest.SetupMockControllerContext(fileServices.Configuration);
        }
Пример #7
0
 public RoleControllerTests() : base(false)
 {
     _controller = new RoleController(new RoleService(Db))
     {
         ControllerContext = HttpResponseTest.SetupMockControllerContext()
     };
 }
Пример #8
0
        public async Task AssignAndUnassignRoles()
        {
            var user = await CreateUser();

            var role = await CreateRole();

            var controllerResult = await _controller.AssignRoles(new List <AssignRoleDto> {
                new AssignRoleDto {
                    UserId = user.Id, RoleId = role.Id, EffectiveDate = DateTimeOffset.UtcNow
                }
            });

            HttpResponseTest.CheckForNoContentResponse(controllerResult);

            var entity = await Db.User.FindAsync(user.Id);

            Assert.True(entity.UserRoles.Count > 0);

            controllerResult = await _controller.UnassignRoles(new List <UnassignRoleDto> {
                new UnassignRoleDto {
                    UserId = user.Id, RoleId = role.Id
                }
            });

            HttpResponseTest.CheckForNoContentResponse(controllerResult);

            entity = await Db.User.FindAsync(user.Id);

            Assert.True(entity.UserRoles.Count > 0);
            Assert.NotNull(entity.UserRoles.FirstOrDefault().ExpiryDate);
        }
        public CourtListControllerTests()
        {
            var fileServices          = new EnvironmentBuilder("FileServicesClient:Username", "FileServicesClient:Password", "FileServicesClient:Url");
            var lookupServices        = new EnvironmentBuilder("LookupServicesClient:Username", "LookupServicesClient:Password", "LookupServicesClient:Url");
            var locationServices      = new EnvironmentBuilder("LocationServicesClient:Username", "LocationServicesClient:Password", "LocationServicesClient:Url");
            var lookupServiceClient   = new LookupCodeServicesClient(lookupServices.HttpClient);
            var locationServiceClient = new LocationServicesClient(locationServices.HttpClient);
            var fileServicesClient    = new FileServicesClient(fileServices.HttpClient);
            var lookupService         = new LookupService(lookupServices.Configuration, lookupServiceClient, new CachingService());
            var locationService       = new LocationService(locationServices.Configuration, locationServiceClient, new CachingService());

            var claims = new[] {
                new Claim(CustomClaimTypes.JcParticipantId, fileServices.Configuration.GetNonEmptyValue("Request:PartId")),
                new Claim(CustomClaimTypes.JcAgencyCode, fileServices.Configuration.GetNonEmptyValue("Request:AgencyIdentifierId")),
            };
            var identity  = new ClaimsIdentity(claims, "Cookies");
            var principal = new ClaimsPrincipal(identity);

            var courtListService = new CourtListService(fileServices.Configuration, fileServices.LogFactory.CreateLogger <CourtListService>(), fileServicesClient, new Mapper(), lookupService, locationService, new CachingService(), principal);

            _controller = new CourtListController(courtListService)
            {
                ControllerContext = HttpResponseTest.SetupMockControllerContext(fileServices.Configuration)
            };
        }
 public AssignmentControllerTests() : base(false)
 {
     _controller = new AssignmentController(new AssignmentService(Db), Db)
     {
         ControllerContext = HttpResponseTest.SetupMockControllerContext()
     };
 }
        public async void Criminal_File_Details_ByFileNumberText_One()
        {
            var actionResult = await _controller.GetCriminalFileIdsByAgencyIdCodeAndFileNumberText("83.0001", "98050101");

            var fileSearchResponse = HttpResponseTest.CheckForValidHttpResponseAndReturnValue(actionResult);

            Assert.Single(fileSearchResponse);
        }
        public async void Civil_File_Details_By_FileNumberText()
        {
            var actionResult = await _controller.GetCivilFileIdsByAgencyIdCodeAndFileNumberText("83.0001", "44459");

            var fileSearchResponse = HttpResponseTest.CheckForValidHttpResponseAndReturnValue(actionResult);

            Assert.Contains("3059", fileSearchResponse.First().PhysicalFileId);
        }
        public async void Civil_Appearance_Details_Party_CourtList_AttendanceMethod()
        {
            var actionResult = await _controller.GetCivilAppearanceDetails("100", "19");

            var civilAppearanceDetail = HttpResponseTest.CheckForValidHttpResponseAndReturnValue(actionResult);

            Assert.Contains(civilAppearanceDetail.Party, p => p.PartyId == "11" && p.AttendanceMethodCd == "TC");
        }
        public async void Criminal_File_Details_By_FileNumberText()
        {
            var actionResult = await _controller.GetCriminalFileIdsByAgencyIdCodeAndFileNumberText("83.0001", "58819-1");

            var fileSearchResponse = HttpResponseTest.CheckForValidHttpResponseAndReturnValue(actionResult);

            Assert.Contains("3779", fileSearchResponse.First().JustinNo);
        }
Пример #15
0
 public ManageTypesControllerTests()
 {
     _dbContext  = new SheriffDbContext(EnvironmentBuilder.SetupDbOptions(useMemoryDatabase: true));
     _controller = new ManageTypesController(new ManageTypesService(_dbContext))
     {
         ControllerContext = HttpResponseTest.SetupMockControllerContext()
     };
 }
        public ShiftControllerTests() : base(false)
        {
            var environment = new EnvironmentBuilder("LocationServicesClient:Username", "LocationServicesClient:Password", "LocationServicesClient:Url");

            ShiftController = new ShiftController(new ShiftService(Db, new SheriffService(Db), environment.Configuration), Db)
            {
                ControllerContext = HttpResponseTest.SetupMockControllerContext()
            };
        }
        public async void GetCourtList_Empty()
        {
            var actionResult = await _controller.GetCourtList("4801", "101", DateTime.Parse("1999-11-15"), null, null);

            var courtListResponse = HttpResponseTest.CheckForValidHttpResponseAndReturnValue(actionResult);

            Assert.Equal(0, courtListResponse.CriminalCourtList.Count);
            Assert.Equal(0, courtListResponse.CivilCourtList.Count);
        }
        public async void GetCourtList_Full_3()
        {
            var actionResult = await _controller.GetCourtList("4801", "007", DateTime.Parse("2020-05-06"), null, null);

            var courtListResponse = HttpResponseTest.CheckForValidHttpResponseAndReturnValue(actionResult);

            Assert.NotNull(courtListResponse.CivilCourtList.First().Document);
            Assert.Equal("PLEADINGS", courtListResponse.CivilCourtList.First().Document.First().Category);
        }
        public async void Criminal_File_Details_ByFileNumberText_Multiple()
        {
            var actionResult =
                await _controller.GetCriminalFileIdsByAgencyIdCodeAndFileNumberText("83.0001", "58819");

            var fileSearchResponse = HttpResponseTest.CheckForValidHttpResponseAndReturnValue(actionResult);

            Assert.Equal(2, fileSearchResponse.Count); // 1 is Provincial
        }
        public async void Civil_Appearances_by_PhysicalFileId()
        {
            var actionResult = await _controller.GetCivilFileDetailByFileId("2506");

            var civilFile = HttpResponseTest.CheckForValidHttpResponseAndReturnValue(actionResult);

            Assert.Equal("0", civilFile.Appearances.FutureRecCount);
            Assert.Equal("20", civilFile.Appearances.HistoryRecCount);
        }
        public async void Criminal_Appearances_by_JustinNo()
        {
            var actionResult = await _controller.GetCriminalFileDetailByFileId("35674");

            var criminalFileAppearancesResponse = HttpResponseTest.CheckForValidHttpResponseAndReturnValue(actionResult);

            Assert.Contains(criminalFileAppearancesResponse.Appearances.ApprDetail,
                            f => f.LastNm == "Young" && f.GivenNm == "Johnny");
        }
        public async void Criminal_File_Details_by_JustinNo()
        {
            var actionResult = await _controller.GetCriminalFileDetailByFileId("35674");

            var redactedCriminalFileDetailResponse = HttpResponseTest.CheckForValidHttpResponseAndReturnValue(actionResult);

            Assert.Equal("35674", redactedCriminalFileDetailResponse.JustinNo);
            Assert.True(redactedCriminalFileDetailResponse.Participant.Count > 0);
        }
Пример #23
0
        public async Task RemoveRole()
        {
            var role = await CreateRole();

            var controllerResult = await _controller.RemoveRole(role.Id);

            HttpResponseTest.CheckForNoContentResponse(controllerResult);

            Assert.Null((await Db.Role.FindAsync(role.Id)));
        }
Пример #24
0
        public async Task GetRoles()
        {
            var role = await CreateRole();

            var controllerResult = await _controller.Roles();

            var response = HttpResponseTest.CheckForValid200HttpResponseAndReturnValue(controllerResult);

            Assert.NotNull(response.FirstOrDefault(r => r.Id == role.Id));
        }
        public async void GetCourtList_Detained()
        {
            var actionResult = await _controller.GetCourtList("7999", "009", DateTime.Parse("1997-02-04"), null, null);

            var courtListResponse = HttpResponseTest.CheckForValidHttpResponseAndReturnValue(actionResult);
            var criminalCourtList = courtListResponse.CriminalCourtList.FirstOrDefault(ccl => ccl.AppearanceSequenceNumber == "2");

            Assert.NotNull(criminalCourtList);
            Assert.True(criminalCourtList.Detained);
        }
        public async void GetCourtList_Civil_CfcsaFile()
        {
            var actionResult = await _controller.GetCourtList("7999", "001", DateTime.Parse("2003-04-08"), null, null);

            var courtListResponse = HttpResponseTest.CheckForValidHttpResponseAndReturnValue(actionResult);
            var civilCourtList    = courtListResponse.CivilCourtList.FirstOrDefault(ccl => ccl.CourtListPrintSortNumber == "2");

            Assert.NotNull(civilCourtList);
            Assert.True(civilCourtList.CfcsaFile);
        }
        public async void GetCourtList_Criminal_Video()
        {
            var actionResult = await _controller.GetCourtList("4801", "003", DateTime.Parse("2016-02-01"), null, null);

            var courtListResponse = HttpResponseTest.CheckForValidHttpResponseAndReturnValue(actionResult);

            var hasVideo = courtListResponse.CriminalCourtList.Any(ccl => ccl.Video);

            Assert.True(hasVideo);
        }
        public async void Criminal_File_Content()
        {
            var actionResult = await _controller.GetCriminalFileContent("4801", "101", DateTime.Parse("2016-04-04"), "44150.0734");

            var criminalFileContent = HttpResponseTest.CheckForValidHttpResponseAndReturnValue(actionResult);

            Assert.Equal("4801", criminalFileContent.CourtLocaCd);
            Assert.Equal("101", criminalFileContent.CourtRoomCd);
            Assert.Equal("2016-04-04", criminalFileContent.CourtProceedingDate);
        }
        public async void GetCourtList()
        {
            var actionResult = await _controller.GetCourtList("4801", "101", DateTime.Parse("2016-04-04"), "CR", "4889-1");

            var courtListResponse = HttpResponseTest.CheckForValidHttpResponseAndReturnValue(actionResult);

            Assert.Equal("4801", courtListResponse.CourtLocationName);
            Assert.Equal("101", courtListResponse.CourtRoomCode);
            Assert.Equal("2016-04-04", courtListResponse.CourtProceedingsDate);
        }
        public async void Civil_Appearance_Details_Party_PreviousAppearance_PartyAppearanceMethod()
        {
            var actionResult = await _controller.GetCivilAppearanceDetails("100", "19");

            var civilAppearanceDetail = HttpResponseTest.CheckForValidHttpResponseAndReturnValue(actionResult);
            var party = civilAppearanceDetail.Party.FirstOrDefault(p => p.PartyId == "21");

            Assert.NotNull(party);
            Assert.Equal("P", party.PartyAppearanceMethod);
            Assert.Equal("Present", party.PartyAppearanceMethodDesc); //Doesn't seem to have any appearance methods
        }