Exemple #1
0
        public void Acquire_WhenAcquiredWithoutDispose_ShouldReturnSame()
        {
            IEventScope firstScope  = this.testee.Acquire();
            IEventScope secondScope = this.testee.Acquire();

            firstScope.Should().BeSameAs(secondScope);
        }
Exemple #2
0
        public void Acquire_WhenSameThread_ShouldReturnSame()
        {
            IEventScope firstScope  = this.testee.Acquire();
            IEventScope secondScope = this.testee.Acquire();

            firstScope.Should().BeSameAs(secondScope);
        }
Exemple #3
0
        public void Acquire_WhenAcquiredWithDispose_ShouldReturnNew()
        {
            IEventScope firstScope = this.testee.Acquire();

            firstScope.Dispose();

            using (IEventScope secondScope = this.testee.Acquire())
            {
                firstScope.Should().NotBeSameAs(secondScope);
            }
        }
Exemple #4
0
        public void Acquire_WhenDifferentThread_ReturnsNew()
        {
            IEventScope firstScopeTaskResult  = null;
            IEventScope secondScopeTaskResult = null;

            var firstScopeTask  = new Thread(() => firstScopeTaskResult = this.testee.Acquire());
            var secondScopeTask = new Thread(() => secondScopeTaskResult = this.testee.Acquire());

            firstScopeTask.Start();
            firstScopeTask.Join();

            secondScopeTask.Start();
            secondScopeTask.Join();

            using (IEventScope firstScope = firstScopeTaskResult)
                using (IEventScope secondScope = secondScopeTaskResult)
                {
                    firstScope.Should().NotBeSameAs(secondScope);
                }
        }
Exemple #5
0
        public void CreateScope_CreatesDefaultEventScope(IEventScopeFactory factory, Type scopeType)
        {
            IEventScope eventScope = factory.CreateScope();

            eventScope.Should().BeOfType <EventScope>();
        }