public void CannotClearTimeoutIfNotScheduled() { var saga = new FakeSaga { CorrelationId = GuidStrategy.NewGuid(), Timeout = null }; var ex = Assert.Throws <InvalidOperationException>(() => saga.Handle(new FakeEvent())); Assert.Equal(Exceptions.SagaTimeoutNotScheduled.FormatWith(saga.GetType(), saga.CorrelationId), ex.Message); }
protected Saga ConfigureSagaTimeout(DateTime?timeout) { Saga saga = new FakeSaga(); saga.Timeout = timeout; saga.CorrelationId = GuidStrategy.NewGuid(); SagaStore.Setup(mock => mock.TryGetSaga(saga.GetType(), saga.CorrelationId, out saga)).Returns(true); return(saga); }
protected Saga ConfigureSagaTimeout(DateTime? timeout) { Saga saga = new FakeSaga(); saga.Timeout = timeout; saga.CorrelationId = GuidStrategy.NewGuid(); SagaStore.Setup(mock => mock.TryGetSaga(saga.GetType(), saga.CorrelationId, out saga)).Returns(true); return saga; }
public void DoNotUpdateTimerIfScheduledTimeoutAfterNextCachedTimeout() { var saga = new FakeSaga { CorrelationId = GuidStrategy.NewGuid(), Timeout = SystemTime.Now.AddMinutes(6) }; using (var context = new SagaContext(saga.GetType(), saga.CorrelationId, new FakeEvent())) { context.TimeoutChanged = true; timeoutDispatcher.PostSave(saga, context, null); } Assert.False(timer.Changed); }
public void TimeoutContainsAllNonStateData() { var timeout = DateTime.Now.AddMinutes(20); var saga = new FakeSaga { CorrelationId = GuidStrategy.NewGuid(), Version = 0, Timeout = timeout }; SagaStore.Save(saga, SagaContext); var sagaTimeout = SagaStore.GetScheduledTimeouts(timeout.AddMinutes(1)).Single(); Assert.Equal(saga.CorrelationId, sagaTimeout.SagaId); Assert.Equal(saga.GetType(), sagaTimeout.SagaType); Assert.Equal(saga.Timeout, sagaTimeout.Timeout); }
public void ScheduleTimeoutIfTimeoutHasValueAndSagaNotCompleted() { var saga = new FakeSaga { CorrelationId = GuidStrategy.NewGuid(), Timeout = SystemTime.Now.AddMinutes(1) }; var cachedItems = timeoutDispatcher.TimeoutCache.Count + 1; using (var context = new SagaContext(saga.GetType(), saga.CorrelationId, new FakeEvent())) { context.TimeoutChanged = true; timeoutDispatcher.PostSave(saga, context, null); } Assert.Equal(cachedItems, timeoutDispatcher.TimeoutCache.Count); }
public void CannotScheduleTimeoutIfAlreadyScheduled() { var saga = new FakeSaga { CorrelationId = GuidStrategy.NewGuid(), Timeout = SystemTime.Now }; var e = new FakeEvent(); using (var context = new SagaContext(typeof(Saga), GuidStrategy.NewGuid(), e)) { var ex = Assert.Throws <InvalidOperationException>(() => saga.Handle(e)); Assert.Equal(Exceptions.SagaTimeoutAlreadyScheduled.FormatWith(saga.GetType(), saga.CorrelationId), ex.Message); Assert.False(context.TimeoutChanged); } }
public void CannotClearTimeoutIfNotScheduled() { var saga = new FakeSaga { CorrelationId = GuidStrategy.NewGuid(), Timeout = null }; var ex = Assert.Throws<InvalidOperationException>(() => saga.Handle(new FakeEvent())); Assert.Equal(Exceptions.SagaTimeoutNotScheduled.FormatWith(saga.GetType(), saga.CorrelationId), ex.Message); }
public void CannotScheduleTimeoutIfAlreadyScheduled() { var saga = new FakeSaga { CorrelationId = GuidStrategy.NewGuid(), Timeout = SystemTime.Now }; var e = new FakeEvent(); using (var context = new SagaContext(typeof(Saga), GuidStrategy.NewGuid(), e)) { var ex = Assert.Throws<InvalidOperationException>(() => saga.Handle(e)); Assert.Equal(Exceptions.SagaTimeoutAlreadyScheduled.FormatWith(saga.GetType(), saga.CorrelationId), ex.Message); Assert.False(context.TimeoutChanged); } }