I have http Azure function and I'm writing unit test of that function. I'm getting below error
Message: Test method Functions.Tests.CacheFunctionTests.CacheRefreshFunction threw exception: System.InvalidOperationException: The request does not have an associated configuration object or the provided configuration was null.
UnitTest
[TestMethod]
public async Task CacheRefreshFunction()
{
// Arrange
mockLog.Setup(x => x.Info(It.IsAny<string>()));
mockService.Setup(x => x.RefreshCache()).Returns(Task.FromResult(0));
HttpRequestMessage httpRequestMessage = new HttpRequestMessage() {
RequestUri = new System.Uri("http://localhost:0895/CacheRefreshFunction"),
Method = HttpMethod.Get
};
// Act
await Functions.CacheRefreshFunction.Run(httpRequestMessage, mockRuleService.Object, mockLog.Object);
// Assert
Assert.IsTrue(true);
}
I guess, I'm not passing some essential value in "HttpRequestMessage" property. Any idea?