public HttpResponseMessage Delete(int id) { var handler = new DashboardComponentDeleteHandler(); var response = handler.Handle(id); if (handler.Errors == null || handler.Errors.Count < 1) { return(Request.CreateResponse(HttpStatusCode.OK, response.ComponentDtos[0])); } return(Request.CreateResponse(HttpStatusCode.BadRequest, handler.Errors)); }
public void DashboardComponentDeleteHandlerShouldValidateItsExistence() { //Arrange var repository = new Mock <IDashboardComponentRepository>(); repository.Setup(x => x.Exists(It.IsAny <int>())).Returns(false); var handler = new DashboardComponentDeleteHandler(repository.Object); //Act handler.Handle(1); //Assert Assert.IsNotNull(handler.Errors); Assert.IsTrue(handler.Errors.Count > 0); }