public void PostMaintenanceTask_ShouldReturnBadRequest_GivenNull()
        {
            var controller = new MaintenanceTaskController(_mockRepo.Object);

            _mockRepo.Setup(a => a.InsertMaintenanceTask(It.IsAny <MaintenanceTask>())).Throws(new Exception("should not be called"));

            IHttpActionResult result = controller.PostMaintenanceTask(null);

            Assert.IsInstanceOfType(result, typeof(BadRequestResult));
        }
        public void PostMaintenanceTask_ShouldReturnExceptionRequest_GivenRepositoryThrows()
        {
            var controller = new MaintenanceTaskController(_mockRepo.Object);

            _mockRepo.Setup(a => a.InsertMaintenanceTask(It.IsAny <MaintenanceTask>())).Throws(new Exception("boom"));

            IHttpActionResult result = controller.PostMaintenanceTask(new MaintenanceTask());

            Assert.IsInstanceOfType(result, typeof(ExceptionResult));
        }
        public void PostMaintenanceTask_ShouldCallRepository_InsertTask()
        {
            var _mockRepo  = new Mock <IMaintenanceTaskRepository>();
            var controller = new MaintenanceTaskController(_mockRepo.Object);
            var newAuto    = new MaintenanceTask()
            {
                Id = 1
            };

            controller.PostMaintenanceTask(newAuto);

            _mockRepo.Verify(m => m.InsertMaintenanceTask(newAuto));
        }
        public void PostMaintenanceTask_ShouldReturnContentResult_GivenTaskSaved()
        {
            var expectedAuto = new MaintenanceTask()
            {
                VIN = "1"
            };
            var controller = new MaintenanceTaskController(_mockRepo.Object);

            IHttpActionResult actionResult = controller.PostMaintenanceTask(expectedAuto);
            var result = actionResult as NegotiatedContentResult <MaintenanceTask>;

            Assert.IsNotNull(result);
            Assert.AreEqual(HttpStatusCode.Accepted, result.StatusCode);
            Assert.IsNotNull(result.Content);
            Assert.AreEqual(expectedAuto.VIN, result.Content.VIN);
        }