public void Pagination_ProvideSelectedCategoryAndPageNumber_ShouldReturnPagingInfo()
        {
            // Arrange:
            var expectedPagingInfo = new PagingInfo(currentPage: 3, pagesCount: 6, previousPage: 2, nextPage: 4, hasMoreThanOnePage: true, currentCategory: "SOME CATEGORY");

            var paginationServiceMock = new Mock <IPaginationService>();

            paginationServiceMock.Setup(service => service.GetCountOfPages(It.IsAny <string>())).Returns(expectedPagingInfo.PagesCount);
            paginationServiceMock.Setup(service => service.GetPreviousPage(It.IsAny <int>())).Returns(expectedPagingInfo.PreviousPage);
            paginationServiceMock.Setup(service => service.GetNextPage(It.IsAny <int>(), It.IsAny <int>())).Returns(expectedPagingInfo.NextPage);
            paginationServiceMock.Setup(service => service.GetHasMoreThanOnePage(It.IsAny <int>())).Returns(expectedPagingInfo.HasMoreThanOnePage);

            var controller = new PaginationController(paginationServiceMock.Object, new Mock <ILogger>().Object);

            // Act:
            var result = controller.PaginationOfList(expectedPagingInfo.CurrentCategory, expectedPagingInfo.CurrentPage).Model as PagingInfo;

            // Assert:
            Assert.AreEqual(expectedPagingInfo.CurrentPage, result.CurrentPage);
            Assert.AreEqual(expectedPagingInfo.PagesCount, result.PagesCount);
            Assert.AreEqual(expectedPagingInfo.CurrentCategory, result.CurrentCategory);
            Assert.AreEqual(expectedPagingInfo.PreviousPage, result.PreviousPage);
            Assert.AreEqual(expectedPagingInfo.NextPage, result.NextPage);
            Assert.AreEqual(expectedPagingInfo.HasMoreThanOnePage, result.HasMoreThanOnePage);
        }
Пример #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            long entriesCount           = App.DB.users_auth_tries.Count();
            PaginationControls controls = new PaginationControls(FirstPageButton, PreviousPageButton, NextPageButton, LastPageButton, SpecifyPageTextBox);

            paginationController            = new PaginationController(10, entriesCount, controls);
            paginationController.OnRefresh += RefreshEntries;
            paginationController.EntriesCountChanged(entriesCount);
        }
Пример #3
0
        private void InitializeResearchObjectsPagination()
        {
            ResearchObjectsUISetEnabledState(true);
            long count = (from ro in App.DB.research_objects
                          where ro.patient == CurrentPatient.id
                          select new object()).Count();

            ResearchObjectsPaginationController             = new PaginationController(20, count, ResearchObjectsPaginationControls);
            ResearchObjectsPaginationController.OnRefresh  += ResearchObjectsRefresh;
            ResearchObjectsPaginationController.CurrentPage = 0;
        }
Пример #4
0
        private void InitializePagination()
        {
            PatientsPaginationControls        = new PaginationControls(PatientsFirstPageButton, PatientsPreviousPageButton, PatientsNextPage, PatientsLastPage, PatientsCurrentPageTextBox);
            ResearchObjectsPaginationControls = new PaginationControls(ResearchObjectsFirstPageButton, ResearchObjectsPreviousPageButton, ResearchObjectsNextPage, ResearchObjectsLastPage, ResearchObjectsCurrentPageTextBox);
            ServicesPaginationControls        = new PaginationControls(ServicesFirstPageButton, ServicesPreviousPageButton, ServicesNextPage, ServicesLastPage, ServicesCurrentPageTextBox);

            long patientsCount = App.DB.patients.Count();
            long servicesCount = App.currentUserServices.Count();

            ServicesPaginationController             = new PaginationController(20, servicesCount, ServicesPaginationControls);
            ServicesPaginationController.OnRefresh  += ServicesRefresh;
            ServicesPaginationController.CurrentPage = 0;

            PatientsPaginationController             = new PaginationController(20, patientsCount, PatientsPaginationControls);
            PatientsPaginationController.OnRefresh  += PatientsRefresh;
            PatientsPaginationController.CurrentPage = 0;

            // ResearchOjects Pagination will be initialized on patient selected
        }
Пример #5
0
        private void PatientsRefresh(object sender, PaginationOnRefreshEventArgs e)
        {
            PaginationController    controller = sender as PaginationController;
            List <PatientsShrinked> patients;

            if (!string.IsNullOrWhiteSpace(e.SearchQuery))
            {
                patients = (from p in App.DB.patients
                            where p.full_name.Contains(e.SearchQuery)
                            orderby p.id ascending
                            select new PatientsShrinked
                {
                    id = p.id,
                    full_name = p.full_name,
                    birthdate = p.birthdate,
                    passport_number = p.passport_number,
                    passport_serial = p.passport_serial
                }).Skip(unchecked ((int)e.CurrentOffset)).Take(20).ToList();
            }
            else
            {
                patients = (from p in App.DB.patients
                            orderby p.id ascending
                            select new PatientsShrinked
                {
                    id = p.id,
                    full_name = p.full_name,
                    birthdate = p.birthdate,
                    passport_number = p.passport_number,
                    passport_serial = p.passport_serial
                }).Skip(unchecked ((int)e.CurrentOffset)).Take(20).ToList();
            }
            patientsDataGrid.Columns.Clear();
            patientsDataGrid.ItemsSource = patients;
            e.Controls.SetEnabledState(true);
        }
 private void Crear_PaginationController()
 {
     controlador = new PaginationController();
     controlador.Agregar_GridView(dataGridView1);
     controlador.Agregar_Label_NrosDePagina(labelNrosDePagina);
 }
Пример #7
0
 /*
  * private void button2_Click(object sender, EventArgs e)
  * {
  *  if (controlesHabilitados2 == false)
  *      return;
  *  controlador2.Boton_Apretado_Ultima_Pagina();
  * }
  *
  * private void button4_Click(object sender, EventArgs e)
  * {
  *  if (controlesHabilitados2 == false)
  *      return;
  *  controlador2.Boton_Apretado_Siguiente();
  * }
  *
  * private void button3_Click(object sender, EventArgs e)
  * {
  *  if (controlesHabilitados2 == false)
  *      return;
  *  controlador2.Boton_Apretado_Anterior();
  * }
  *
  * private void button1_Click(object sender, EventArgs e)
  * {
  *  if (controlesHabilitados2 == false)
  *      return;
  *  controlador2.Boton_Apretado_Primer_Pagina();
  * }
  */
 private void Historial_Load(object sender, EventArgs e)
 {
     controlador = new PaginationController();
     controlador.Agregar_GridView(dataGridView1);
     controlador.Agregar_Label_NrosDePagina(labelNrosDePagina);
 }