Example #1
0
        public async Task GetSpotsByRegionAsync_CallingTheService_Success()
        {
            // Arrange
            paginatedSpots.Data   = expectedSpots;
            paginatedSpots.Counts = new PaginatedCountModel(paging, expectedSpots.Count());
            moqService.Setup(x =>
                             x.GetSpotsByRegionAsync(It.IsAny <int>(), It.IsAny <PagingModel>())).ReturnsAsync(paginatedSpots);

            // Act
            var response = await controller.GetSpotsByRegionAsync(regionId, paging) as ObjectResult;

            var actualPaginatedSpots = response.Value as PaginatedModel <Spot>;

            // Assert
            moqService.VerifyAll();
            Assert.IsInstanceOfType(response, typeof(OkObjectResult));
            Assert.IsInstanceOfType(actualPaginatedSpots, typeof(PaginatedModel <Spot>));
            Assert.AreEqual(expectedSpots, actualPaginatedSpots.Data);
            Assert.IsNotNull(actualPaginatedSpots.Counts);
            Assert.AreEqual(paging, actualPaginatedSpots.Counts.Paging);
            Assert.AreEqual(expectedSpots.Count(), actualPaginatedSpots.Counts.Total);
        }