-
-
Save justinyoo/78a6d70095df2fe66a9e3b76ad17a5d8 to your computer and use it in GitHub Desktop.
Testing Azure Functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#load "run.csx" | |
using Microsoft.Azure.WebJobs.Extensions; | |
using Microsoft.Azure.WebJobs.Host; | |
// Arrange | |
var context = Require<AzureFunctionsPackContext>(); | |
var moq = Require<MoqPackContext>(); | |
var req = new HttpRequestMessage() { Content = new StringContent("Hello World") }; | |
TraceWriter log = new TraceMonitor(); | |
var mocked = moq.Mock<IMyServiceClass>(); | |
locator.AddService(typeof(IMyServiceClass), mocked.Object); | |
locator.AddService(typeof(MyStatusClass), new MyStatusClass()); | |
// Action | |
var res = Run(req, log).Result; | |
// Assert | |
Console.WriteLine(locator.GetStatus().Status); | |
Console.WriteLine(res.Content.ReadAsStringAsync().Result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment