Пример #1
0
        public async Task GetListOfPatients_PopulatedList()
        {
            // Arrange
            await this.Authorize().ConfigureAwait(false);

            // Act
            HttpResponseMessage response = await this.CallGetPatientList(0, 23).ConfigureAwait(false);

            response.EnsureSuccessStatusCode();

            ExtendedPagedList <PatientViewModel> patientList =
                JsonConvert.DeserializeObject <ExtendedPagedList <PatientViewModel> >(
                    await response.Content.ReadAsStringAsync().ConfigureAwait(false));

            // Assert
            Assert.NotEmpty(patientList.Content);
            Assert.Equal(this.KnownPatients, patientList.Content, new JsonEqualityComparer());
        }
Пример #2
0
        public async Task GetListOfPatients_PopulatedList()
        {
            // Arrange
            await this.Authorize().ConfigureAwait(false);

            // Act
            HttpResponseMessage response = await this.CallGetPatientList(0, 23).ConfigureAwait(false);

            response.EnsureSuccessStatusCode();

            ExtendedPagedList <PatientViewModel> patientList =
                JsonConvert.DeserializeObject <ExtendedPagedList <PatientViewModel> >(
                    await response.Content.ReadAsStringAsync().ConfigureAwait(false));

            // Assert
            patientList.Content.Should().NotBeEmpty();
            patientList.Content.Should().BeEquivalentTo(KnownPatients);
        }
Пример #3
0
        public async Task GetListOfPatients_EmptyList()
        {
            // Arrange
            await this.Authorize().ConfigureAwait(false);

            this.ClearPatientData();

            // Act
            HttpResponseMessage response = await this.CallGetPatientList(0, 23).ConfigureAwait(false);

            response.EnsureSuccessStatusCode();
            ExtendedPagedList <PatientViewModel> patientList =
                JsonConvert.DeserializeObject <ExtendedPagedList <PatientViewModel> >(
                    await response.Content.ReadAsStringAsync().ConfigureAwait(false));

            // Assert
            Assert.Empty(patientList.Content);
        }
Пример #4
0
        private async Task GetPagedPatient(int page, int totalElements, int elementsPerPage)
        {
            IActionResult        result = null;
            PatientController    sut    = null;
            IQueryable <Patient> list   = GetPatientList(totalElements);

            AllureLifecycle.Instance.WrapInStep(() =>
            {
                // Arrange
                this.mockPatientRepository
                .Setup(repo => repo.GetAllWithPaginationPatients(It.IsAny <int>(), It.IsAny <int>()))
                .ReturnsAsync(
                    new PagedList <Patient>(list, page + 1, elementsPerPage));
                sut = this.sutBuilder.WithRepository(this.mockRepositories.Object);
            }, "Action: Step 1: Arrange");

            await AllureLifecycle.Instance.WrapInStep(async() =>
            {
                // Act
                result = await sut.GetAllPatients(page, 18);
            }, $"Action: Step 2: Act. Get all the patients of page {page}, just {elementsPerPage} items");

            AllureLifecycle.Instance.WrapInStep(() =>
            {
                // Assert
                ExtendedPagedList <PatientViewModel> model =
                    AssertAndGetModel <ExtendedPagedList <PatientViewModel> >(result);
                Assert.AreEqual(elementsPerPage, model.NumberOfElements);
                Assert.AreEqual(page, model.Number);
                Assert.AreEqual(totalElements, model.TotalElements);

                // compare the Ids of the patient and patientVM
                CollectionAssert.AreEqual(
                    list.Skip(page * elementsPerPage).Take(elementsPerPage).Select(p => p.Id).ToArray(),
                    model.Content.Select(p => p.Id).ToArray());
            }, "Step 3: Assert. Check if the number the patients returned is correct");
        }
Пример #5
0
        public async Task GetAllPatients_Paged_Should_Return_List_Of_Patients_After_Last_Page()
        {
            int           totalElements   = 90;
            int           page            = 5;
            int           elementsPerPage = 18;
            IActionResult result          = null;

            IQueryable <Patient> list = GetPatientList(totalElements);
            PatientController    sut  = null;

            AllureLifecycle.Instance.WrapInStep(() =>
            {
                // Arrange
                this.mockPatientRepository
                .Setup(repo => repo.GetAllWithPaginationPatients(It.IsAny <int>(), It.IsAny <int>())).ReturnsAsync(
                    new PagedList <Patient>(list, page + 1, elementsPerPage));
                sut = this.sutBuilder.WithRepository(this.mockRepositories.Object);
            }, "Action: Create a Patient List");

            await AllureLifecycle.Instance.WrapInStep(async() =>
            {
                // Act
                result = await sut.GetAllPatients(page, 18);
            }, $"Action: Get all the patients of page {page}, just {elementsPerPage} items");

            AllureLifecycle.Instance.WrapInStep(() =>
            {
                ExtendedPagedList <PatientViewModel> model =
                    AssertAndGetModel <ExtendedPagedList <PatientViewModel> >(result);
                Assert.AreEqual(0, model.NumberOfElements);
                Assert.AreEqual(page, model.Number);
                Assert.AreEqual(totalElements, model.TotalElements);

                // the list shall be empty
                Assert.False(model.Content.Any());
            }, "Check if the number the patients returned is correct");
        }