I am writing a unit test cases fro Azure function.In my function app configuration section i have added my connection string.
When the azure function runs in azure below line of code is working fine.
var connStr = ConfigurationManager.ConnectionStrings["SqlConnection"].ConnectionString;
If i am calling the azure function from unit test case this line is throwing exception. "object reference not set to an instance of an object".
Form unit test case how i can execute this line of code.(using Moq).
Test Method :
[TestMethod]
public async Task GetDataFromAzureSQL_Test()
{
var req = new HttpRequestMessage();
var obj = new Modeltest
{
id = 1,
name ="",
location=""
};
var content = new StringContent(JsonConvert.SerializeObject(obj).ToString(), Encoding.UTF8, "application/json");
req.Content = content;
var result = await Function.Function1.Run(req, new Mock<ILogger>().Object);
Assert.IsTrue("OK" == result.StatusCode.ToString());
}