public async Task WhenInvalidatingDuringAnUpdate_DoesSomething() { await _sut.GetLatestProjectionTime(); Thread.Sleep(_expiration.Add(TimeSpan.FromSeconds(0.25))); // Expire await _sut.GetLatestProjectionTime(); // Trigger update Thread.Sleep(TimeSpan.FromMilliseconds(_updateDuration.TotalMilliseconds / 2)); // Updating now Assert.ThrowsAsync <InvalidStateTransitionException>(() => _sut.InvalidateProjection()); // Mark as Expired during Updating state }
public override async Task AfterEnter() { // Expire after the specified amount of time await Task.Factory.StartNew(async() => { await _sleeper .Sleep(_timeout) .ContinueWith(previous => _projectionSystem.InvalidateProjection()) .ConfigureAwait(false); }, CancellationToken.None, TaskCreationOptions.LongRunning, _taskScheduler) .ConfigureAwait(false); }