/// <inheritdoc /> public override string Run(TaskContext context, string input) { CheckInnerActivity(); using (OrchestrationScope.EnterScope(context.OrchestrationInstance.InstanceId)) { return(InnerActivity.Run(context, input)); } }
/// <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)); } }
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)); }
public void CreateScope_ArgumentNullServiceProvider() { // arrange, act ArgumentNullException ex = Capture <ArgumentNullException>( () => OrchestrationScope.CreateScope(Guid.NewGuid().ToString(), null)); // assert ex.Should().NotBeNull(); }
public void CreateScope_ArgumentNullInstance() { // arrange, act ArgumentNullException ex = Capture <ArgumentNullException>( () => OrchestrationScope.CreateScope(null, GetServiceProvider())); // assert ex.Should().NotBeNull(); }
public void GetScope_KeyNotFound() { // arrange, act var ex = Capture <KeyNotFoundException>( () => OrchestrationScope.GetScope(Guid.NewGuid().ToString())); // assert ex.Should().NotBeNull(); }
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)); } }
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(); }
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(); }
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(); });