public async Task ExportsController_GetSectionsPartialTest() { AuthenticationHelper.HttpContext = AuthenticationHelper.CreateHttpContext(true); ExportsController controller = new ExportsController(); SetupController(controller); ExportsViewModel defaultExportViewModel = await GetDefaultExportsViewModel(); var defaultResult = await controller.Index(); Assert.IsNotNull(defaultResult, "invalid result"); Assert.IsInstanceOfType(defaultResult, typeof(ViewResult), "Unexpected result type"); ViewResult defaultViewResult = defaultResult as ViewResult; Assert.IsNotNull(defaultViewResult.Model, "Invalid model result"); Assert.IsInstanceOfType(defaultViewResult.Model, typeof(ExportsViewModel), "Unexpected model type"); ExportsViewModel modelResult = defaultViewResult.Model as ExportsViewModel; var schoolIds = modelResult.SchoolsCriteriaSection.FilterCheckboxes.Select(p => p.SchoolId).ToList(); var partialResult = await controller.GetSectionsPartial(schoolIds : schoolIds, boxesAlreadyChecked : null, getMore : false); Assert.IsNotNull(partialResult, "Invalid result"); Assert.IsInstanceOfType(partialResult, typeof(PartialViewResult), "Unexpected result type"); PartialViewResult partialViewResult = partialResult as PartialViewResult; Assert.IsNotNull(partialViewResult.Model, "Invalid model"); Assert.IsInstanceOfType(partialViewResult.Model, typeof(ApiCriteriaSection), "Unexpected model type"); ApiCriteriaSection apiCriteriaResult = partialViewResult.Model as ApiCriteriaSection; Assert.IsTrue(apiCriteriaResult.FilterCheckboxes.Count > 0, "No data found"); }
public async Task ExportsController_GetCoursesPartialTest() { AuthenticationHelper.HttpContext = AuthenticationHelper.CreateHttpContext(true); ExportsController controller = new ExportsController(); SetupController(controller); ExportsViewModel defaultExportViewModel = await GetDefaultExportsViewModel(); var defaultResult = await controller.Index(); Assert.IsNotNull(defaultResult, "invalid result"); Assert.IsInstanceOfType(defaultResult, typeof(ViewResult), "Unexpected result type"); ViewResult defaultViewResult = defaultResult as ViewResult; Assert.IsNotNull(defaultViewResult.Model, "Invalid model result"); Assert.IsInstanceOfType(defaultViewResult.Model, typeof(ExportsViewModel), "Unexpected model type"); ExportsViewModel modelResult = defaultViewResult.Model as ExportsViewModel; var schoolIds = modelResult.SchoolsCriteriaSection.FilterCheckboxes.Select(p => p.SchoolId).ToList(); var partialResult = await controller.GetPreviewCoursesJsonString(0); Assert.IsNotNull(partialResult, "Invalid result"); Assert.IsInstanceOfType(partialResult, typeof(JsonResult), "Unexpected result type"); JsonResult partialViewResult = partialResult as JsonResult; Assert.IsNotNull(partialViewResult.Data, "Invalid model"); Assert.IsInstanceOfType(partialViewResult.Data, typeof(ViewModels.DataPreviewPagedJsonModel), "Unexpected model type"); ViewModels.DataPreviewPagedJsonModel apiCriteriaResult = partialViewResult.Data as ViewModels.DataPreviewPagedJsonModel; Assert.IsTrue(apiCriteriaResult.TotalPages > 0, "No data found"); }
public async Task ExportsController_IndexTest() { AuthenticationHelper.HttpContext = AuthenticationHelper.CreateHttpContext(true); ExportsController controller = new ExportsController(); SetupController(controller); ExportsViewModel defaultExportViewModel = await GetDefaultExportsViewModel(); var defaultResult = await controller.Index(); Assert.IsNotNull(defaultResult, "invalid result"); Assert.IsInstanceOfType(defaultResult, typeof(ViewResult), "Unexpected result type"); ViewResult defaultViewResult = defaultResult as ViewResult; Assert.IsNotNull(defaultViewResult.Model, "Invalid model result"); Assert.IsInstanceOfType(defaultViewResult.Model, typeof(ExportsViewModel), "Unexpected model type"); ExportsViewModel modelResult = defaultViewResult.Model as ExportsViewModel; Assert.IsTrue(modelResult.SchoolsCriteriaSection.FilterCheckboxes != null && modelResult.SchoolsCriteriaSection.FilterCheckboxes.Count > 0, "No data for Schools Criteria"); }