public void Delete_GivenProductId_ShouldReturnNotFound() { // Arrange var inMemoryRepoMock = new Mock <IProductRepository>(); inMemoryRepoMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(false); var controller = new ProductsApiController(inMemoryRepoMock.Object); controller.Request = new HttpRequestMessage(); controller.Configuration = new HttpConfiguration(); // Act var response = controller.Delete(1); // Assert var res = response.ExecuteAsync(CancellationToken.None).Result; Assert.AreEqual(HttpStatusCode.NotFound, res.StatusCode); }