public void Acquire_WhenAcquiredWithoutDispose_ShouldReturnSame() { IEventScope firstScope = this.testee.Acquire(); IEventScope secondScope = this.testee.Acquire(); firstScope.Should().BeSameAs(secondScope); }
public void Acquire_WhenSameThread_ShouldReturnSame() { IEventScope firstScope = this.testee.Acquire(); IEventScope secondScope = this.testee.Acquire(); firstScope.Should().BeSameAs(secondScope); }
public void Acquire_WhenAcquiredWithDispose_ShouldReturnNew() { IEventScope firstScope = this.testee.Acquire(); firstScope.Dispose(); using (IEventScope secondScope = this.testee.Acquire()) { firstScope.Should().NotBeSameAs(secondScope); } }
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); } }
public void CreateScope_CreatesDefaultEventScope(IEventScopeFactory factory, Type scopeType) { IEventScope eventScope = factory.CreateScope(); eventScope.Should().BeOfType <EventScope>(); }