private static void RunTest <TResult>( Type innerType, Func <WrapperOrchestration, TResult> act, Action <WrapperOrchestration, TResult> verify) { var services = new WrapperOrchestration(innerType); TResult result = act(services); verify?.Invoke(services, result); }
private static async Task RunTestAsync <TResult>( Type innerType, Func <WrapperOrchestration, Task <TResult> > act, Action <WrapperOrchestration, TResult> verify) { var services = new WrapperOrchestration(innerType); TResult result = await act(services); verify?.Invoke(services, result); }
public async Task InvokeAsync_Wrapped_SetsOrchestration() { // arrange var serviceProvider = new Mock <IServiceProvider>(); serviceProvider.Setup(m => m.GetService(typeof(TestOrchestration))).Returns(new TestOrchestration()); var wrapper = new WrapperOrchestration(new TaskOrchestrationDescriptor(typeof(TestOrchestration))); DispatchMiddlewareContext context = CreateContext(wrapper); var middleware = new ServiceProviderOrchestrationMiddleware(serviceProvider.Object); // act await middleware.InvokeAsync(context, () => Task.CompletedTask); // assert TaskOrchestration activity = context.GetProperty <TaskOrchestration>(); activity.Should().NotBeNull(); activity.Should().Be(wrapper.InnerOrchestration); serviceProvider.Verify(m => m.GetService(typeof(TestOrchestration)), Times.Once); }