public void AllBasicParametersShouldBeSet() { var originalSettigs = new TypedHandlingSettings<SystemChecked>(() => new SpecEventHandler<SystemChecked>(ev => { }), priority: 99); var settigs = new DeferredHandlingSettings(originalSettigs, DelayUntil.Finished); settigs.Type.Should().Be(typeof(SystemChecked)); settigs.Priority.Should().Be(99); }
public void ActionShouldBeFilteredByType() { var resolved = 0; var called = 0; var originalSettigs = new TypedHandlingSettings<SystemChecked>( () => { resolved++; return new SpecEventHandler<SystemChecked>(ev => { called++; }); }, priority: 99); var settigs = new DeferredHandlingSettings(originalSettigs, DelayUntil.PreCompleted); using (var uow = new UnitOfWork()) { settigs.Action(new object()); settigs.Action(new object()); resolved.Should().Be(0); called.Should().Be(0); uow.Complete(); resolved.Should().Be(0); called.Should().Be(0); } resolved.Should().Be(0); called.Should().Be(0); using (var uow = new UnitOfWork()) { settigs.Action(new SystemChecked()); settigs.Action(new SystemChecked()); resolved.Should().Be(0); called.Should().Be(0); uow.Complete(); resolved.Should().Be(2); called.Should().Be(2); } resolved.Should().Be(2); called.Should().Be(2); }
public void OriginalActionShouldBeCalledWhenUnitOfWorkScopeFinishedSuccessfullyIfAppropriateStageIsSpecified() { var resolved = 0; var called = 0; var originalSettigs = new TypedHandlingSettings<SystemChecked>( () => { // ReSharper disable once AccessToModifiedClosure resolved++; // ReSharper disable once AccessToModifiedClosure return new SpecEventHandler<SystemChecked>(ev => { called++; }); }, priority: 99); var settigs = new DeferredHandlingSettings(originalSettigs, DelayUntil.Finished); using (var uow = new UnitOfWork()) { settigs.Action(new SystemChecked()); settigs.Action(new SystemChecked()); resolved.Should().Be(0); called.Should().Be(0); uow.Complete(); resolved.Should().Be(0); called.Should().Be(0); } resolved.Should().Be(2); called.Should().Be(2); resolved = 0; called = 0; try { using (var uow = new UnitOfWork("test")) { // ReSharper disable once UnusedVariable var session = ((IWrapper)uow).WrappedObject; settigs.Action(new SystemChecked()); settigs.Action(new SystemChecked()); resolved.Should().Be(0); called.Should().Be(0); uow.Complete(); } } catch (NotSupportedException) { } resolved.Should().Be(0); called.Should().Be(0); }
public void SubscriberShouldBeIgnoredIfIsUsedOutsideOfUnitOfWork() { var resolved = false; var called = false; var originalSettigs = new TypedHandlingSettings<SystemChecked>( () => { resolved = true; return new SpecEventHandler<SystemChecked>(ev => { called = true; }); }, priority: 99); var settigs = new DeferredHandlingSettings(originalSettigs, DelayUntil.Finished); settigs.Action(new SystemChecked()); resolved.Should().Be.False(); called.Should().Be.False(); }