public async void Delete_ReturnsDeleted() { var value = "AET"; var entity = new DestinationApplicationEntity { AeTitle = value, Name = value }; _repository.Setup(p => p.FindAsync(It.IsAny <string>())).Returns(Task.FromResult(entity)); _repository.Setup(p => p.Remove(It.IsAny <DestinationApplicationEntity>())); _repository.Setup(p => p.SaveChangesAsync(It.IsAny <CancellationToken>())); var result = await _controller.Delete(value); Assert.NotNull(result.Value); Assert.Equal(value, result.Value.AeTitle); _repository.Verify(p => p.FindAsync(value), Times.Once()); _repository.Verify(p => p.Remove(entity), Times.Once()); _repository.Verify(p => p.SaveChangesAsync(It.IsAny <CancellationToken>()), Times.Once()); }
public async void Delete_ShallReturnDeletedResponse() { var response = new HttpOperationResponse <object>(); response.Response = new HttpResponseMessage(HttpStatusCode.OK); response.Response.Content = new StringContent("Go!Clara"); _kubernetesClient .Setup(p => p.DeleteNamespacedCustomObjectWithHttpMessagesAsync(It.IsAny <CustomResourceDefinition>(), It.IsAny <string>())) .Returns(() => { return(Task.FromResult(response)); }); var name = "delete-me"; var result = await _controller.Delete(name); _kubernetesClient.Verify(p => p.DeleteNamespacedCustomObjectWithHttpMessagesAsync(It.IsAny <CustomResourceDefinition>(), name), Times.Once()); Assert.NotNull(result); var contentResult = result.Result as ContentResult; Assert.NotNull(contentResult); Assert.Equal(response.Response.Content.AsString(), contentResult.Content); }