Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
0
        public void CreateScope_ArgumentNullServiceProvider()
        {
            // arrange, act
            ArgumentNullException ex = Capture <ArgumentNullException>(
                () => OrchestrationScope.CreateScope(Guid.NewGuid().ToString(), null));

            // assert
            ex.Should().NotBeNull();
        }
Ejemplo n.º 3
0
        public void CreateScope_ArgumentNullInstance()
        {
            // arrange, act
            ArgumentNullException ex = Capture <ArgumentNullException>(
                () => OrchestrationScope.CreateScope(null, GetServiceProvider()));

            // assert
            ex.Should().NotBeNull();
        }
Ejemplo n.º 4
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();
        }
Ejemplo n.º 5
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();
        }
Ejemplo n.º 6
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);
        }