I have the following Azure Function:
[Function("O_StudentEnrollmentUpdated")]
public async Task<bool> StudentEnrollmentUpdated(
[OrchestrationTrigger] TaskOrchestrationContext ctx,
StudentEnrollment studentEnrollment
)
{
var log = ctx.CreateReplaySafeLogger("O_StudentEnrollmentUpdated");
...
...
...
}
I am attempting to write a test for this, but I get an Exception on the very first line of code:
System.NullReferenceException HResult=0x80004003 Message=Object
reference not set to an instance of an object.
Source=Microsoft.DurableTask.Abstractions StackTrace: at
Microsoft.DurableTask.TaskOrchestrationContext.CreateReplaySafeLogger(String
categoryName)
This is the test, I’m thinking something is wrong with the Mock, but unsure:
[Fact]
public async Task TestStudentEnrollmentUpdatedOrchestrator()
{
var mockClient = new Mock<ServiceBusClient>();
var taskContextMock = new Mock<TaskOrchestrationContext>();
var _sut = new StudentEnrollmentUpdatedOrchestrator(mockClient.Object);
StudentEnrollment se = new StudentEnrollment()
{
CourseId = 1,
UserId = 2
};
var run = await _sut.StudentEnrollmentUpdated(taskContextMock.Object, se);
Assert.True(run);
}
The documentation for testing isolated functions seems to be very lacking as of now so I’m having trouble figuring out what I’m doing wrong here.