public void SkillsController_Delete_ReturnsNoContentResult_WhenIdIsValid() { //Arrange int id = 1; //Act var result = controller.Delete(id); //Assert Assert.IsType <NoContentResult>(result); }
public void Delete() { _repo.Setup(m => m.Delete(It.IsAny <int>())); var result = _controller.Delete(1) as OkResult; Assert.NotNull(result); }
public void When_DeletingItem_RemovesItem() { const int id = 1; var dataStore = new Mock <ISkillsDataStore>(); var controller = new SkillsController(dataStore.Object); controller.Delete(id); dataStore.Verify(ds => ds.Remove(It.Is <int>(s => s == id))); }
public async Task Delete_WhenCalled_ShouldWork() { _mockRepository.Setup( _ => _.Delete(It.IsAny <string>())).Returns(Task.FromResult(HttpStatusCode.NoContent) ); var controller = new SkillsController(_mockRepository.Object, _mockAdapter.Object, _mockLogger.Object); var actual = await controller.Delete(""); Assert.IsAssignableFrom <ActionResult <HttpStatusCode> >(actual); Assert.Contains( ((int)HttpStatusCode.NoContent).ToString(), JsonConvert.SerializeObject(actual) ); }
public void When_ItemNotFound_Returns_NotFound() { const int id = 1; var dataStore = new Mock <ISkillsDataStore>(); var controller = new SkillsController(dataStore.Object); dataStore.Setup(ds => ds.Remove(id)).Throws(new NotFoundException()); var result = controller.Delete(id); Assert.IsType(typeof(NotFoundResult), result); }