Exemple #1
0
 /// <inheritdoc />
 public override string Run(TaskContext context, string input)
 {
     CheckInnerActivity();
     using (OrchestrationScope.EnterScope(context.OrchestrationInstance.InstanceId))
     {
         return(InnerActivity.Run(context, input));
     }
 }
Exemple #2
0
 /// <inheritdoc />
 public override async Task <string> RunAsync(TaskContext context, string input)
 {
     CheckInnerActivity();
     using (OrchestrationScope.EnterScope(context.OrchestrationInstance.InstanceId))
     {
         return(await InnerActivity.RunAsync(context, input).ConfigureAwait(false));
     }
 }
Exemple #3
0
        private static IOrchestrationScope CreateScope()
        {
            IServiceScopeFactory factory = Mock.Of <IServiceScopeFactory>(
                m => m.CreateScope() == Mock.Of <IServiceScope>());
            IServiceProvider serviceProvider = Mock.Of <IServiceProvider>(
                m => m.GetService(typeof(IServiceScopeFactory)) == factory);

            return(OrchestrationScope.CreateScope(InstanceId, serviceProvider));
        }
Exemple #4
0
        public void CreateScope_ArgumentNullServiceProvider()
        {
            // arrange, act
            ArgumentNullException ex = Capture <ArgumentNullException>(
                () => OrchestrationScope.CreateScope(Guid.NewGuid().ToString(), null));

            // assert
            ex.Should().NotBeNull();
        }
Exemple #5
0
        public void CreateScope_ArgumentNullInstance()
        {
            // arrange, act
            ArgumentNullException ex = Capture <ArgumentNullException>(
                () => OrchestrationScope.CreateScope(null, GetServiceProvider()));

            // assert
            ex.Should().NotBeNull();
        }
Exemple #6
0
        public void GetScope_KeyNotFound()
        {
            // arrange, act
            var ex = Capture <KeyNotFoundException>(
                () => OrchestrationScope.GetScope(Guid.NewGuid().ToString()));

            // assert
            ex.Should().NotBeNull();
        }
Exemple #7
0
        public void GetScope_ArgumentNull()
        {
            // arrange, act
            var ex = Capture <ArgumentNullException>(
                () => OrchestrationScope.GetScope(null));

            // assert
            ex.Should().NotBeNull();
        }
 /// <inheritdoc />
 public override Task <string> Execute(OrchestrationContext context, string input)
 {
     CheckInnerOrchestration();
     using (OrchestrationScope.EnterScope(context.OrchestrationInstance.InstanceId))
     {
         // While this looks wrong to not await this task before disposing the scope,
         // DurableTask orchestrations are never resumed after yielding. They will only
         // be replayed from scratch.
         return(InnerOrchestration.Execute(context, input));
     }
 }
Exemple #9
0
        public void CreateScope_Created()
        {
            // arrange
            string instanceId = Guid.NewGuid().ToString();

            // act
            IOrchestrationScope scope = OrchestrationScope.CreateScope(instanceId, GetServiceProvider());

            // assert
            scope.Should().NotBeNull();
            scope.ServiceProvider.Should().NotBeNull();
        }
Exemple #10
0
        public void CreateScope_AlreadyExists()
        {
            // arrange
            string instanceId = Guid.NewGuid().ToString();

            OrchestrationScope.CreateScope(instanceId, GetServiceProvider());

            // act
            InvalidOperationException ex = Capture <InvalidOperationException>(
                () => OrchestrationScope.CreateScope(instanceId, GetServiceProvider()));

            // assert
            ex.Should().NotBeNull();
        }
Exemple #11
0
        public void GetOrCreateScope_Found()
        {
            // arrange
            string instanceId = Guid.NewGuid().ToString();

            // act
            IOrchestrationScope first  = OrchestrationScope.CreateScope(instanceId, GetServiceProvider());
            IOrchestrationScope second = OrchestrationScope.GetOrCreateScope(instanceId, GetServiceProvider());

            // assert
            second.Should().NotBeNull();
            second.ServiceProvider.Should().NotBeNull();
            second.Should().BeSameAs(first);
        }
        public Task Execute_DisposesScope()
        => RunTestAsync(
            typeof(TestOrchestration),
            async wrapper =>
        {
            CreateScope();
            wrapper.InnerOrchestration =
                (TaskOrchestration)Activator.CreateInstance(wrapper.InnerOrchestrationType, this);
            await wrapper.Execute(s_orchestrationContext, Input);

            return(Capture <KeyNotFoundException>(
                       () => OrchestrationScope.GetScope(InstanceId)));
        },
            (wrapper, ex) =>
        {
            ex.Should().NotBeNull();
        });