public void CanCallDisposeMoreThanOnce() { using (var context = new SagaContext(typeof(Saga), GuidStrategy.NewGuid(), new FakeEvent())) { context.Dispose(); context.Dispose(); } }
public void CannotDisposeContextOutOfOrder() { var context1 = new SagaContext(typeof(Saga), GuidStrategy.NewGuid(), new FakeEvent()); var context2 = new SagaContext(typeof(Saga), GuidStrategy.NewGuid(), new FakeEvent()); // ReSharper disable AccessToDisposedClosure var ex = Assert.Throws <InvalidOperationException>(() => context1.Dispose()); // ReSharper restore AccessToDisposedClosure context2.Dispose(); context1.Dispose(); Assert.Equal(Exceptions.SagaContextInvalidThread, ex.Message); }
public void CannotDisposeContextFromAnotherThread() { var contextDisposedEvent = new ManualResetEvent(false); var contextCreatedEvent = new ManualResetEvent(false); var context = default(SagaContext); Task.Factory.StartNew(() => { context = new SagaContext(typeof(Saga), GuidStrategy.NewGuid(), new FakeEvent()); contextCreatedEvent.Set(); contextDisposedEvent.WaitOne(); context.Dispose(); }); contextCreatedEvent.WaitOne(); var ex = Assert.Throws <InvalidOperationException>(() => context.Dispose()); Assert.Equal(Exceptions.SagaContextInterleaved, ex.Message); contextDisposedEvent.Set(); }
public void Dispose() { SagaContext.Dispose(); SagaStore.Purge(); }
public void Dispose() { _context.Dispose(); }
public void CannotDisposeContextFromAnotherThread() { var contextDisposedEvent = new ManualResetEvent(false); var contextCreatedEvent = new ManualResetEvent(false); var context = default(SagaContext); Task.Factory.StartNew(() => { context = new SagaContext(typeof(Saga), GuidStrategy.NewGuid(), new FakeEvent()); contextCreatedEvent.Set(); contextDisposedEvent.WaitOne(); context.Dispose(); }); contextCreatedEvent.WaitOne(); var ex = Assert.Throws<InvalidOperationException>(() => context.Dispose()); Assert.Equal(Exceptions.SagaContextInterleaved, ex.Message); contextDisposedEvent.Set(); }
public void CanCallDisposeMoreThanOnce() { using (var context = new SagaContext(typeof(Saga), GuidStrategy.NewGuid(), new FakeEvent())) { context.Dispose(); context.Dispose(); } }
public void CannotDisposeContextOutOfOrder() { var context1 = new SagaContext(typeof(Saga), GuidStrategy.NewGuid(), new FakeEvent()); var context2 = new SagaContext(typeof(Saga), GuidStrategy.NewGuid(), new FakeEvent()); // ReSharper disable AccessToDisposedClosure var ex = Assert.Throws<InvalidOperationException>(() => context1.Dispose()); // ReSharper restore AccessToDisposedClosure context2.Dispose(); context1.Dispose(); Assert.Equal(Exceptions.SagaContextInvalidThread, ex.Message); }