public void Delete_não_deve_perguntar_para_excluir_um_tópico_inexistente() { //Arrange var guidBase = Guid.NewGuid(); var mock = new Mock<ITopicRepository>(); mock. Setup(m => m.ReadById(guidBase)). Returns((Topic) null); var controller = new TopicController(mock.Object); //Act var result = (RedirectToRouteResult) controller.Delete(guidBase); //Assert Assert.AreEqual("Index", result.RouteValues["action"]); }
public void Delete_deve_perguntar_para_excluir_um_tópico_válido() { //Arrange var guidBase = Guid.NewGuid(); var topic = new Topic() { Id = guidBase, Value = "gradiente" }; var mock = new Mock<ITopicRepository>(); mock. Setup(m => m.ReadById(guidBase)). Returns(topic); var controller = new TopicController(mock.Object); //Act var result = (ViewResult)controller.Delete(topic.Id); //Assert Assert.AreEqual("", result.ViewName); }