I have this Azure Function orchestrator
using Microsoft.Azure.Functions.Worker;
using Microsoft.DurableTask;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace Functions.Triggers.Orchestration.StudentEnrollments
{
public class SimpleOrchestrator
{
[Function("O_Simple")]
public async Task<bool> RunAsync([OrchestrationTrigger] TaskOrchestrationContext ctx)
{
var aTest = await ctx.CallHttpAsync(HttpMethod.Get, new Uri("https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide?tabs=linux"));
if (aTest.StatusCode == System.Net.HttpStatusCode.OK)
{
return true;
}
return false;
}
}
}
And this test
using Microsoft.Azure.Functions.Worker.Extensions.DurableTask.Http;
using Microsoft.DurableTask;
using Moq;
using Functions.Triggers.Orchestration.StudentEnrollments;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Xunit;
namespace tests.UnitTests
{
public class SimpleTest
{
[Fact]
public async Task Test_SimpleTestOrchestrator()
{
var test = new SimpleOrchestrator();
var mockContext = new Mock<TaskOrchestrationContext>();
mockContext
.Setup(x => x.CallHttpAsync(HttpMethod.Get, new Uri("https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide?tabs=linux"), null, null))
.ReturnsAsync(new DurableHttpResponse(System.Net.HttpStatusCode.OK));
var sut = await test.RunAsync(mockContext.Object);
Assert.True(sut);
}
}
}
I get the error
System.NotSupportedException : Unsupported expression: x => x.CallHttpAsync(HttpMethod.Get, ltiUserGetUrl, null, null) Extension methods (here: TaskOrchestrationContextExtensionMethods.CallHttpAsync) may not be used in setup / verification expressions.
This is how I was able to mock CallHttpAsync
for the in process model but I can’t seem to find out how to do it for .net isolated.