Skip to content

Instantly share code, notes, and snippets.

@justinyoo
Created September 5, 2016 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinyoo/78a6d70095df2fe66a9e3b76ad17a5d8 to your computer and use it in GitHub Desktop.
Save justinyoo/78a6d70095df2fe66a9e3b76ad17a5d8 to your computer and use it in GitHub Desktop.
Testing Azure Functions
#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