コード例 #1
0
        public async Task GetRegionsAsync_NoRestrictions_Success()
        {
            //Arrange
            paginatedRegions.Data   = expectedRegions;
            paginatedRegions.Counts = new PaginatedCountModel(paging, expectedRegions.Count());
            moqService.Setup(x => x.GetRegionsAsync(It.IsAny <PagingModel>()))
            .ReturnsAsync(paginatedRegions);

            //Act
            var response = await controller.GetRegionsAsync(paging) as ObjectResult;

            var actualPaginatedRegions = response?.Value as PaginatedModel <Region>;

            //Assert
            moqService.Verify();
            Assert.IsInstanceOfType(response, typeof(OkObjectResult));
            Assert.IsInstanceOfType(actualPaginatedRegions, typeof(PaginatedModel <Region>));
            Assert.AreEqual(expectedRegions, actualPaginatedRegions.Data);
            Assert.IsNotNull(actualPaginatedRegions.Counts);
            Assert.AreEqual(paging, actualPaginatedRegions.Counts.Paging);
            Assert.AreEqual(expectedRegions.Count(), actualPaginatedRegions.Counts.Total);
        }