public async void UpdatebyProduct_CallsUpdatebyProductOnMockRepo_ReturnsCreatedObjectResult() { //Arrange int productId = 1; var newProduct = new Product() { }; mockRepo.Setup(repo => repo.UpdatebyProduct(newProduct)).Returns(Task.FromResult <Product>(newProduct)); //Act var result = await controller.UpdatebyProduct(productId, newProduct); var resultObj = result as OkObjectResult; //Asset mockRepo.Verify(repo => repo.UpdatebyProduct(newProduct), Times.Once); Assert.NotNull(resultObj); Assert.Equal(200, resultObj.StatusCode); }