Example #1
0
        public async Task DeleteVehicle_CanValidateInput()
        {
            IActionResult actual = await _controller.DeleteVehicleAsync(122);

            _vehiclesRepository.Verify(db => db.GetAsync(122), Times.Once);
            _vehiclesRepository.Verify(db => db.Delete(It.IsAny <Vehicle>()), Times.Never);
            _unitOfWork.Verify(u => u.CompeleteAsync(), Times.Never);

            Assert.IsInstanceOf <BadRequestObjectResult>(actual);
            BadRequestObjectResult result    = actual as BadRequestObjectResult;
            SerializableError      errorList = result?.Value as SerializableError;

            Assert.IsNotNull(errorList);
            Assert.AreEqual(1, errorList.Count);
            CollectionAssert.AreEqual(new[] { "Vehicle with Id = 122 not found!" }, errorList["Id"] as string[]);
        }