Esempio n. 1
0
        public async Task CanValidateModelFields_UpdateVehicle_RequiredFielsAreMissing()
        {
            SaveVehicleResource vehicleResource = new SaveVehicleResource {
                Contact = null
            };

            _controller.ModelState.AddModelError("Contact", "The Contact Name field is required.");

            IActionResult actual = await _controller.UpdateVehicleAsync(123, vehicleResource);

            _vehiclesRepository.Verify(db => db.GetWithDependenciesAsync(It.IsAny <int>()), Times.Never);
            _vehiclesRepository.Verify(db => db.IsModelExists(It.IsAny <int>()), Times.Never);
            _vehiclesRepository.Verify(db => db.IsFeatureExists(It.IsAny <int>()), Times.Never);
            Assert.IsInstanceOf <BadRequestObjectResult>(actual);
        }