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 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); }