Example #1
0
        public void AddCarFunction()
        {
            // Arrange:
            var          okCar      = _data.okCar;
            CarViewModel invalidCar = null;

            // Act:
            var okResponse = _carController.AddCarFunction(okCar);
            CreatedAtActionResult okResult = okResponse as CreatedAtActionResult;

            var badResponse            = _carController.AddCarFunction(invalidCar);
            BadRequestResult badResult = badResponse as BadRequestResult;

            var invalidModelStateResponse = _carController.AddCarFunction(invalidCar);
            StatusCodeResult badStatus    = invalidModelStateResponse as StatusCodeResult;

            // Assert:

            Assert.IsInstanceOfType(okResponse, typeof(CreatedAtActionResult));
            Assert.IsInstanceOfType(badResponse, typeof(BadRequestResult));
            Assert.IsInstanceOfType(badResponse, typeof(StatusCodeResult));
        }