Open sanjaybhagia opened 7 years ago
We found a workaround, but still need to understand why the regular unit test project doesn't work. @vijayrkn was going to take a look.
Will provide an update as soon as I find why it doesn't work on regular unit test projects.
Sample function app with tests are available here - https://github.com/Azure/azure-functions-vs-build-sdk/tree/master/sample/FunctionApp
Replace the 1.0.3 version of Functions sdk with 1.0.2 version (which is the most recent version available on NuGet)
While unit testing Azure Functions Project i get this this exception running my test case:
Investigative information
I'm using Visual Studio 2017 15.3.4
Repro steps
Step 1: Create Azure Functions Project for HttpTrigger using VS template (it's targetted at .net framework 4.6.1)
Step 2: Then create a unit test project (4.6.1 framework). Add reference to the azure function projected created above.
Step 3: Run the sample test case You get the exception mentioned above.
Provide the steps required to reproduce the problem:
Expected behavior
Expected behavior is that the test cases runs successfully without complaining about this issue with System.Net.Http dll
Known workarounds
Please check the response from David on this stackoverflow issue that i created. this workaround worked for me.
https://stackoverflow.com/questions/46287628/could-not-load-file-or-assembly-system-net-http-version-4-1-1-0-in-unit-test-fo
In short, i had to create the unit test project using .net core template, edit the csproj file to change the target framework to net461, then everything worked fine.
Related information
Here is the code for unit test that validates the response from azure function