コード例 #1
0
        public async Task GetMembers_Invalid_Test(int id)
        {
            _cityService.Setup(cs => cs.GetCityMembersAsync(It.IsAny <int>()))
            .ReturnsAsync(() => null);

            _mapper.Setup(m => m.Map <CityProfileDTO, CityViewModel>(It.IsAny <CityProfileDTO>()))
            .Returns(new CityViewModel());

            CitiesController cityController = CreateCityController;


            var result = await cityController.GetMembers(id);

            Assert.IsNotNull(result);
            Assert.IsInstanceOf <NotFoundResult>(result);
        }
コード例 #2
0
        public async Task GetMembers_Valid_Test(int id)
        {
            // Arrange
            _cityService
            .Setup(cs => cs.GetCityMembersAsync(It.IsAny <int>()))
            .ReturnsAsync(new CityProfileDTO());
            _mapper
            .Setup(m => m.Map <CityProfileDTO, CityViewModel>(It.IsAny <CityProfileDTO>()))
            .Returns(new CityViewModel());
            CitiesController cityController = CreateCityController;

            // Act
            var result = await cityController.GetMembers(id);

            // Assert
            _mapper.Verify(m => m.Map <CityProfileDTO, CityViewModel>(It.IsAny <CityProfileDTO>()));
            Assert.IsInstanceOf <OkObjectResult>(result);
            Assert.NotNull(result);
        }