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(); }
private static Func <DispatchMiddlewareContext, Func <Task>, Task> BeginMiddlewareScope(IServiceProvider serviceProvider) { return(async(context, next) => { IOrchestrationScope scope = OrchestrationScope.GetOrCreateScope( context.GetProperty <OrchestrationInstance>().InstanceId, serviceProvider); using (scope.Enter()) { await next().ConfigureAwait(false); } }); }
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); }
/// <summary> /// Enters the scope identified by <paramref name="orchestrationInstanceId"/>. /// </summary> /// <param name="orchestrationInstanceId">The orchestration instance id. Not null or empty.</param> /// <returns>A disposalable that will exit the scope when disposed.</returns> public static IDisposable EnterScope(string orchestrationInstanceId) { IOrchestrationScope scope = GetScope(orchestrationInstanceId); return(scope?.Enter() ?? EmptyDisposable.Instance); }