示例#1
0
        public async Task CanValidateModelFields_CreateVehicle_RequiredFielsAreMissing()
        {
            SaveVehicleResource vehicleResource = new SaveVehicleResource {
                Contact = null
            };

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

            IActionResult actual = await _controller.CreateVehicleAsync(vehicleResource);

            _vehiclesRepository.Verify(db => db.GetAsync(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);
        }