public AzureFunctionHandlerTests() { ILogger logger; ExecutionContext context; HttpContext httpContext; logger = Substitute.For <ILogger>(); context = Substitute.For <ExecutionContext>(); context.InvocationId = Guid.Empty; context.FunctionName = "TestRule"; context.FunctionDirectory = ""; context.FunctionAppDirectory = ""; var services = new ServiceCollection() .AddMvc() .AddWebApiConventions() .Services .BuildServiceProvider(); httpContext = new DefaultHttpContext() { RequestServices = services, }; httpContext.Request.Protocol = "http"; httpContext.Request.Host = new HostString("localhost"); httpContext.Request.Method = HttpMethod.Post.ToString(); azureFunctionHandler = new TestAzureFunctionHandler(logger, context, httpContext); }
public void HandleEventsWithDifferentResourceVersion_CheckIdentityConversion_Succeeds(WebHookEvent eventData) { var handler = new TestAzureFunctionHandler(logger, context); var eventContext = handler.InvokeCreateContextFromEvent(eventData); var workItem = eventContext.WorkItemPayload.WorkItem; Assert.IsType <IdentityRef>(workItem.Fields[CoreFieldRefNames.AssignedTo]); Assert.IsType <IdentityRef>(workItem.Fields[CoreFieldRefNames.ChangedBy]); Assert.IsType <IdentityRef>(workItem.Fields[CoreFieldRefNames.CreatedBy]); }