コード例 #1
0
        public void DetailsValidId()
        {
            var actual = ((ViewResult)controller.Details(1)).Model;


            Assert.AreEqual(cities[0], actual);
        }
コード例 #2
0
        public async Task DetailsGetAction_GetModelFromService()
        {
            // Arrange

            // Act
            var result = await validController.Details(entity.Id);

            // Assert
            mock.Verify(a => a.GetAsync(entity.Id, false));
        }
コード例 #3
0
        public void Details_ReturnsNotEmptyView()
        {
            service.Get <CityView>(city.Id).Returns(city);

            Object expected = NotEmptyView(controller, city);
            Object actual   = controller.Details(city.Id);

            Assert.Same(expected, actual);
        }
コード例 #4
0
        public async Task Details_Invalid_Test()
        {
            _cityService.Setup(c => c.GetByIdAsync(It.IsAny <int>()))
            .ReturnsAsync(() => null);

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

            CitiesController citycon = CreateCityController;

            var result = await citycon.Details(GetFakeID());

            Assert.NotNull(result);
            Assert.IsInstanceOf <NotFoundResult>(result);
        }
コード例 #5
0
        public async Task CityDetailsAsync()
        {
            // Arrange
            CitiesController controller = new CitiesController();

            // Act
            ActionResult result = await controller.Details(1);

            var viewResult = (ViewResult)result;
            var objlist    = (City)viewResult.Model;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, objlist.CityId);
        }
コード例 #6
0
        public async Task Details_Valid_Test()
        {
            // Arrange
            _cityService
            .Setup(c => c.GetByIdAsync(It.IsAny <int>()))
            .ReturnsAsync(new CityDTO());
            _mapper
            .Setup(m => m.Map <CityDTO, CityViewModel>(It.IsAny <CityDTO>()))
            .Returns(new CityViewModel());
            CitiesController citycon = CreateCityController;

            // Act
            var result = await citycon.Details(GetFakeID());

            // Assert
            Assert.NotNull(result);
            Assert.IsInstanceOf <OkObjectResult>(result);
        }