public void DeleteReturnsOk() { // Arrange var mock = new Mock <ITypesRepository>(); var controller = new TypesController(mock.Object); // Act IHttpActionResult actionResult = (IHttpActionResult)controller.Delete(5); // Assert Assert.IsInstanceOf((System.Type)actionResult, typeof(OkResult)); }
public void TypesControllerDeleteTest() { var topic = CreateContext(); var typeId = Guid.NewGuid(); var Logic = CreateLogic(); var Controller = new TypesController(Logic); TypeEntity type = new TypeEntity() { Id = typeId, Name = "First Type", Topic = topic, TopicId = topic.Id }; Logic.Create(type); Controller.Delete(type.Id); Assert.ThrowsException <ExceptionController>(() => Logic.Get(type.Id)); }
public void Delete_API() { //Arrange Type item = new Type() { ID = id, Description = "test", Status = "test" }; typeServiceMock.Setup(x => x.Get(id)).Returns(item); //Act var actionResult = controllerAPI.Delete(id); var contentResult = actionResult as OkNegotiatedContentResult <Type>; //Assert Assert.IsNotNull(contentResult); Assert.IsNotNull(contentResult.Content); Assert.IsInstanceOfType(contentResult.Content, typeof(Type)); Assert.AreEqual(item, contentResult.Content); }