public void Create_WrapperCreated()
        {
            var descriptor = TaskOrchestrationDescriptor.Create <TestOrchestration>();
            var creator    = new OrchestrationObjectCreator(descriptor);
            TaskOrchestration Orchestration = creator.Create();

            Orchestration.Should().NotBeNull();
            Orchestration.Should().BeOfType <WrapperOrchestration>()
            .Which.Descriptor.Should().Be(descriptor);
        }
        public async Task InvokeAsync_NotWrapped_Continues()
        {
            // arrange
            var activity        = new TestOrchestration();
            var serviceProvider = new Mock <IServiceProvider>();
            DispatchMiddlewareContext context = CreateContext(activity);
            var middleware = new ServiceProviderOrchestrationMiddleware(serviceProvider.Object);

            // act
            await middleware.InvokeAsync(context, () => Task.CompletedTask);

            // assert
            TaskOrchestration actual = context.GetProperty <TaskOrchestration>();

            actual.Should().NotBeNull();
            actual.Should().Be(activity);
            serviceProvider.Verify(m => m.GetService(It.IsAny <Type>()), Times.Never);
        }
        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);
        }