Esempio n. 1
0
        public void Edit_ReturnsNotEmptyView()
        {
            service.Get <CityView>(city.Id).Returns(city);

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

            Assert.Same(expected, actual);
        }
        public async Task EditGetAction_UpdateModelFromService()
        {
            // Arrange

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

            // Assert
            mock.Verify(a => a.GetAsync(entity.Id, true));
        }
        public async Task EditPostAction_ModelError_ReturnsSameModel()
        {
            // Arrange

            // Act
            var result = await notValidController.Edit(entity.Id, entity) as ViewResult;

            // Assert
            Assert.Equal(entity, result.Model);
        }
Esempio n. 4
0
        public async Task CityEditAsync()
        {
            // Arrange
            CitiesController controller = new CitiesController();
            City             item       = new City()
            {
                CityId = 999,
                Name   = "ciudad editada"
            };

            // Act
            ActionResult result = await controller.Edit(item);

            // Assert
            Assert.IsNotNull(result);
        }
Esempio n. 5
0
        public async Task Edit_Valid_Test()
        {
            CityViewModel TestVM = new CityViewModel();

            _cityService.Setup(c => c.EditAsync(It.IsAny <CityDTO>()));

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

            _logger.Setup(l => l.LogInformation(It.IsAny <string>()));

            CitiesController citycon = CreateCityController;

            var result = await citycon.Edit(TestVM);

            Assert.NotNull(result);
            Assert.IsInstanceOf <OkResult>(result);
        }
Esempio n. 6
0
        public async Task Edit_InvalidModelState_Valid_Test()
        {
            CityViewModel TestVM = new CityViewModel();

            _cityService.Setup(c => c.EditAsync(It.IsAny <CityDTO>()));

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

            _logger.Setup(l => l.LogInformation(It.IsAny <string>()));

            CitiesController citycon = CreateCityController;

            citycon.ModelState.AddModelError("NameError", "Required");


            var result = await citycon.Edit(TestVM);

            Assert.NotNull(result);
            Assert.IsInstanceOf <BadRequestObjectResult>(result);
        }