Exemplo n.º 1
0
        public void Acquire_WhenAcquiredWithoutDispose_ShouldReturnSame()
        {
            IEventScope firstScope  = this.testee.Acquire();
            IEventScope secondScope = this.testee.Acquire();

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

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

            firstScope.Dispose();

            using (IEventScope secondScope = this.testee.Acquire())
            {
                firstScope.Should().NotBeSameAs(secondScope);
            }
        }
Exemplo n.º 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);
                }
        }
Exemplo n.º 5
0
        public void CreateScope_CreatesDefaultEventScope(IEventScopeFactory factory, Type scopeType)
        {
            IEventScope eventScope = factory.CreateScope();

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