public void Delete_ReturnsOk() { //Arrange _topicService.Setup(s => s.DeleteEntityByIdAsync(_topic.Id)); //Act var actionResult = _topicController.Delete(_topic.Id).Result as OkResult; //Assert actionResult.StatusCode.Equals(200); }
public void Delete_WhenCalled_RemoveGivenTopicFromDatabase() { var topic = _context.AddTestTopicToDatabase(); var postedTopic = new Topic { Id = topic.Id, Name = topic.Name }; _controller.Delete(postedTopic); var topicInDb = _contextAfterAction.Topics.Find(topic.Id); Assert.That(topicInDb, Is.Null); }
public void TopicController_Delete_WhenTheTopicIsDeletedSuccessfully_WillReturnAnOKStatusAndASuccessMessage() { var controller = new TopicController(_topicsRepository.Object); SetUpHttpRequestParameters(controller); var response = controller.Delete(1); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); ExpandoObject expando; Assert.IsTrue(response.TryGetContentValue(out expando)); var expandoDict = (IDictionary <string, object>)expando; Assert.AreEqual("The topic was deleted successfully", expandoDict["message"]); _topicsRepository.Verify(t => t.Delete(It.IsAny <int>()), Times.Once()); _topicsRepository.Verify(c => c.Save(), Times.Once()); }
public void DeleteReturnsBadRequest() { var result = controller.Delete(Guid.NewGuid()); Assert.IsType <BadRequestObjectResult>(result.Result); }
public void Delete_WhenCalled_ReturnRedirectToRouteResult() { var result = _controller.Delete(_topic1); Assert.That(result, Is.TypeOf <RedirectToRouteResult>()); }