Skip to content

Commit

Permalink
Re-designed ExpireAfter operators, from scratch, eliminating a variet…
Browse files Browse the repository at this point in the history
…y of defects, including #716.
  • Loading branch information
JakenVeina committed Feb 25, 2024
1 parent efcb93a commit 1c297ec
Show file tree
Hide file tree
Showing 15 changed files with 1,332 additions and 283 deletions.
12 changes: 6 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ dotnet_diagnostic.SA1136.severity = error
dotnet_diagnostic.SA1137.severity = error
dotnet_diagnostic.SA1139.severity = error
dotnet_diagnostic.SA1200.severity = none
dotnet_diagnostic.SA1201.severity = error
dotnet_diagnostic.SA1201.severity = none
dotnet_diagnostic.SA1202.severity = error
dotnet_diagnostic.SA1203.severity = error
dotnet_diagnostic.SA1204.severity = error
Expand Down Expand Up @@ -424,10 +424,10 @@ dotnet_diagnostic.SA1508.severity = error
dotnet_diagnostic.SA1509.severity = error
dotnet_diagnostic.SA1510.severity = error
dotnet_diagnostic.SA1511.severity = error
dotnet_diagnostic.SA1512.severity = error
dotnet_diagnostic.SA1513.severity = error
dotnet_diagnostic.SA1512.severity = none
dotnet_diagnostic.SA1513.severity = none
dotnet_diagnostic.SA1514.severity = error
dotnet_diagnostic.SA1515.severity = error
dotnet_diagnostic.SA1515.severity = none
dotnet_diagnostic.SA1516.severity = error
dotnet_diagnostic.SA1517.severity = error
dotnet_diagnostic.SA1518.severity = error
Expand Down Expand Up @@ -503,7 +503,7 @@ dotnet_diagnostic.RCS1058.severity=warning
dotnet_diagnostic.RCS1068.severity=warning
dotnet_diagnostic.RCS1073.severity=warning
dotnet_diagnostic.RCS1084.severity=error
dotnet_diagnostic.RCS1085.severity=error
dotnet_diagnostic.RCS1085.severity=none
dotnet_diagnostic.RCS1105.severity=error
dotnet_diagnostic.RCS1112.severity=error
dotnet_diagnostic.RCS1128.severity=error
Expand Down Expand Up @@ -547,4 +547,4 @@ end_of_line = lf
[*.{cmd, bat}]
end_of_line = crlf

vsspell_dictionary_languages = en-US
vsspell_dictionary_languages = en-US
16 changes: 8 additions & 8 deletions src/DynamicData.Tests/Cache/ExpireAfterFixture.ForSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public void PollingIntervalIsGiven_RemovalsAreScheduledAtInterval()
results.TryGetRecordedCompletion().Should().BeFalse();
}

[Fact(Skip = "Existing defect, very minor defect, items defined to never expire actually do, at DateTimeOffset.MaxValue")]
[Fact]
public void PollingIntervalIsNotGiven_RemovalsAreScheduledImmediately()
{
using var source = CreateTestSource();
Expand Down Expand Up @@ -390,7 +390,7 @@ public void PollingIntervalIsNotGiven_RemovalsAreScheduledImmediately()
}

// Covers https://github.com/reactivemarbles/DynamicData/issues/716
[Fact(Skip = "Existing defect, removals are skipped when scheduler invokes early")]
[Fact]
public void SchedulerIsInaccurate_RemovalsAreNotSkipped()
{
using var source = CreateTestSource();
Expand Down Expand Up @@ -425,7 +425,7 @@ public void SchedulerIsInaccurate_RemovalsAreNotSkipped()
results.TryGetRecordedCompletion().Should().BeFalse();
}

[Fact(Skip = "Existing defect, completion is not propagated from the source")]
[Fact]
public void SourceCompletes_CompletionIsPropagated()
{
using var source = CreateTestSource();
Expand Down Expand Up @@ -454,7 +454,7 @@ public void SourceCompletes_CompletionIsPropagated()
results.EnumerateInvalidNotifications().Should().BeEmpty();
}

[Fact(Skip = "Existing defect, completion is not propagated from the source")]
[Fact]
public void SourceCompletesImmediately_CompletionIsPropagated()
{
using var source = CreateTestSource();
Expand Down Expand Up @@ -482,7 +482,7 @@ public void SourceCompletesImmediately_CompletionIsPropagated()
results.EnumerateInvalidNotifications().Should().BeEmpty();
}

[Fact(Skip = "Exsiting defect, errors are re-thrown instead of propagated, operator does not use safe subscriptions")]
[Fact]
public void SourceErrors_ErrorIsPropagated()
{
using var source = CreateTestSource();
Expand Down Expand Up @@ -512,7 +512,7 @@ public void SourceErrors_ErrorIsPropagated()
results.EnumerateInvalidNotifications().Should().BeEmpty();
}

[Fact(Skip = "Existing defect, immediately-occuring error is not propagated")]
[Fact]
public void SourceErrorsImmediately_ErrorIsPropagated()
{
using var source = CreateTestSource();
Expand Down Expand Up @@ -552,7 +552,7 @@ public void SourceIsNull_ThrowsException()
interval: null))
.Should().Throw<ArgumentNullException>();

[Fact(Skip = "Existing defect, operator does not properly handle items with a null timeout, when using a real scheduler, it passes a TimeSpan to the scheduler that is outside of the supported range")]
[Fact]
public async Task ThreadPoolSchedulerIsUsedWithoutPolling_ExpirationIsThreadSafe()
{
using var source = new TestSourceCache<StressItem, int>(static item => item.Id);
Expand Down Expand Up @@ -624,7 +624,7 @@ public void TimeSelectorIsNull_ThrowsException()
interval: null))
.Should().Throw<ArgumentNullException>();

[Fact(Skip = "Exsiting defect, errors are re-thrown instead of propagated, user code is not protected")]
[Fact]
public void TimeSelectorThrows_ErrorIsPropagated()
{
using var source = CreateTestSource();
Expand Down
10 changes: 5 additions & 5 deletions src/DynamicData.Tests/Cache/ExpireAfterFixture.ForStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ public void PollingIntervalIsGiven_RemovalsAreScheduledAtInterval()
results.IsCompleted.Should().BeFalse();
}

[Fact(Skip = "Existing defect, very minor defect, items defined to never expire actually do, at DateTimeOffset.MaxValue")]
[Fact]
public void PollingIntervalIsNotGiven_RemovalsAreScheduledImmediately()
{
using var source = new Subject<IChangeSet<TestItem, int>>();
Expand Down Expand Up @@ -499,7 +499,7 @@ public void PollingIntervalIsNotGiven_RemovalsAreScheduledImmediately()
results.IsCompleted.Should().BeFalse();
}

[Fact(Skip = "Existing defect, completion does not wait")]
[Fact]
public void RemovalsArePending_CompletionWaitsForRemovals()
{
using var source = new Subject<IChangeSet<TestItem, int>>();
Expand Down Expand Up @@ -550,7 +550,7 @@ public void RemovalsArePending_CompletionWaitsForRemovals()
}

// Covers https://github.com/reactivemarbles/DynamicData/issues/716
[Fact(Skip = "Existing defect, removals are skipped when scheduler invokes early")]
[Fact]
public void SchedulerIsInaccurate_RemovalsAreNotSkipped()
{
using var source = new Subject<IChangeSet<TestItem, int>>();
Expand Down Expand Up @@ -742,7 +742,7 @@ public void SourceIsNull_ThrowsException()
timeSelector: static _ => default))
.Should().Throw<ArgumentNullException>();

[Fact(Skip = "Existing defect, operator does not properly handle items with a null timeout, when using a real scheduler, it passes a TimeSpan to the scheduler that is outside of the supported range")]
[Fact]
public async Task ThreadPoolSchedulerIsUsedWithoutPolling_ExpirationIsThreadSafe()
{
using var source = new Subject<IChangeSet<StressItem, int>>();
Expand Down Expand Up @@ -809,7 +809,7 @@ public void TimeSelectorIsNull_ThrowsException()
timeSelector: null!))
.Should().Throw<ArgumentNullException>();

[Fact(Skip = "Exsiting defect, errors are re-thrown instead of propagated, user code is not protected")]
[Fact]
public void TimeSelectorThrows_ErrorIsPropagated()
{
using var source = new Subject<IChangeSet<TestItem, int>>();
Expand Down
20 changes: 10 additions & 10 deletions src/DynamicData.Tests/List/ExpireAfterFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void NextItemToExpireIsReplaced_ExpirationIsRescheduledIfNeeded()
results.TryGetRecordedCompletion().Should().BeFalse();
}

[Fact(Skip = "Existing defect, operator emits empty sets of expired items, instead of skipping emission")]
[Fact]
public void PollingIntervalIsGiven_RemovalsAreScheduledAtInterval()
{
using var source = new TestSourceList<TestItem>();
Expand Down Expand Up @@ -276,7 +276,7 @@ public void PollingIntervalIsGiven_RemovalsAreScheduledAtInterval()
results.TryGetRecordedCompletion().Should().BeFalse();
}

[Fact(Skip = "Existing defect, very minor defect, items defined to never expire actually do, at DateTimeOffset.MaxValue")]
[Fact]
public void PollingIntervalIsNotGiven_RemovalsAreScheduledImmediately()
{
using var source = new TestSourceList<TestItem>();
Expand Down Expand Up @@ -393,7 +393,7 @@ public void PollingIntervalIsNotGiven_RemovalsAreScheduledImmediately()
}

// Covers https://github.com/reactivemarbles/DynamicData/issues/716
[Fact(Skip = "Existing defect, removals are skipped when scheduler invokes early")]
[Fact]
public void SchedulerIsInaccurate_RemovalsAreNotSkipped()
{
using var source = new TestSourceList<TestItem>();
Expand Down Expand Up @@ -428,7 +428,7 @@ public void SchedulerIsInaccurate_RemovalsAreNotSkipped()
results.TryGetRecordedCompletion().Should().BeFalse();
}

[Fact(Skip = "Existing defect, completion is not propagated from the source")]
[Fact]
public void SourceCompletes_CompletionIsPropagated()
{
using var source = new TestSourceList<TestItem>();
Expand Down Expand Up @@ -457,7 +457,7 @@ public void SourceCompletes_CompletionIsPropagated()
results.EnumerateInvalidNotifications().Should().BeEmpty();
}

[Fact(Skip = "Existing defect, completion is not propagated from the source")]
[Fact]
public void SourceCompletesImmediately_CompletionIsPropagated()
{
using var source = new TestSourceList<TestItem>();
Expand Down Expand Up @@ -485,7 +485,7 @@ public void SourceCompletesImmediately_CompletionIsPropagated()
results.EnumerateInvalidNotifications().Should().BeEmpty();
}

[Fact(Skip = "Exsiting defect, errors are re-thrown instead of propagated, operator does not use safe subscriptions")]
[Fact]
public void SourceErrors_ErrorIsPropagated()
{
using var source = new TestSourceList<TestItem>();
Expand Down Expand Up @@ -515,7 +515,7 @@ public void SourceErrors_ErrorIsPropagated()
results.EnumerateInvalidNotifications().Should().BeEmpty();
}

[Fact(Skip = "Existing defect, immediately-occuring error is not propagated")]
[Fact]
public void SourceErrorsImmediately_ErrorIsPropagated()
{
using var source = new TestSourceList<TestItem>();
Expand Down Expand Up @@ -555,7 +555,7 @@ public void SourceIsNull_ThrowsException()
pollingInterval: null))
.Should().Throw<ArgumentNullException>();

[Fact(Skip = "Existing defect, operator does not properly handle items with a null timeout, when using a real scheduler, it passes a TimeSpan to the scheduler that is outside of the supported range")]
[Fact]
public async Task ThreadPoolSchedulerIsUsedWithoutPolling_ExpirationIsThreadSafe()
{
using var source = new TestSourceList<StressItem>();
Expand Down Expand Up @@ -587,7 +587,7 @@ public async Task ThreadPoolSchedulerIsUsedWithoutPolling_ExpirationIsThreadSafe
_output.WriteLine($"{results.EnumerateRecordedValues().Count()} Expirations occurred, for {results.EnumerateRecordedValues().SelectMany(static item => item).Count()} items");
}

[Fact(Skip = "Existing defect, deadlocks")]
[Fact]
public async Task ThreadPoolSchedulerIsUsedWithPolling_ExpirationIsThreadSafe()
{
using var source = new TestSourceList<StressItem>();
Expand Down Expand Up @@ -627,7 +627,7 @@ public void TimeSelectorIsNull_ThrowsException()
pollingInterval: null))
.Should().Throw<ArgumentNullException>();

[Fact(Skip = "Exsiting defect, errors are re-thrown instead of propagated, user code is not protected")]
[Fact]
public void TimeSelectorThrows_ThrowsException()
{
using var source = new TestSourceList<TestItem>();
Expand Down
8 changes: 3 additions & 5 deletions src/DynamicData.Tests/Utilities/FakeScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,9 @@ public void SimulateUntilIdle(TimeSpan inaccuracyOffset = default)
ScheduledActions[0].Invoke();
ScheduledActions.RemoveAt(0);
}
// If the next action is in the future, advance time by 1ms.
else
{
Now += TimeSpan.FromMilliseconds(1);
}

// Advance time by at least one tick after every action, to eliminate infinite-looping
Now += TimeSpan.FromTicks(1);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/DynamicData.Tests/Utilities/TestSourceCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public void Complete()

public void Dispose()
{
_source.Dispose();
_error.Dispose();
_hasCompleted.Dispose();
_source.Dispose();
}

public void Edit(Action<ISourceUpdater<TObject, TKey>> updateAction)
Expand Down
2 changes: 1 addition & 1 deletion src/DynamicData.Tests/Utilities/TestSourceList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public void Complete()

public void Dispose()
{
_source.Dispose();
_error.Dispose();
_hasCompleted.Dispose();
_source.Dispose();
}

public void Edit(Action<IExtendedList<T>> updateAction)
Expand Down
Loading

0 comments on commit 1c297ec

Please sign in to comment.