-
-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
4492375
commit ce4e3a7
Showing
3 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/DynamicData.Tests/Cache/InnerJoinFixtureRaceCondition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
using System.Reactive.Concurrency; | ||
using System.Reactive.Linq; | ||
using Xunit; | ||
|
||
namespace DynamicData.Tests.Cache | ||
{ | ||
public class InnerJoinFixtureRaceCondition | ||
{ | ||
public class Thing | ||
{ | ||
public long Id { get; set; } | ||
public string Name { get; set; } | ||
} | ||
|
||
/// <summary> | ||
/// Tests to see whether we have fixed a race condition. See https://github.com/reactiveui/DynamicData/issues/364 | ||
/// | ||
/// RP: 04-June-2020 Before the fix, this code occasionally caused a threading issue and the fix seems to have worked. | ||
/// I am leaving it here for a short period of time to see whether it produces traffic light test results. | ||
/// </summary> | ||
[Fact] | ||
public void LetsSeeWhetherWeCanRandomlyHitARaceCondition() | ||
{ | ||
var ids = ObservableChangeSet.Create<long, long>(sourceCache => | ||
{ | ||
return Observable.Range(1, 1000000, Scheduler.Default) | ||
.Subscribe(x => sourceCache.AddOrUpdate(x)); | ||
}, x => x); | ||
|
||
var itemsCache = new SourceCache<Thing, long>(x => x.Id); | ||
itemsCache.AddOrUpdate(new[] | ||
{ | ||
new Thing {Id = 300, Name = "Quick"}, | ||
new Thing {Id = 600, Name = "Brown"}, | ||
new Thing {Id = 900, Name = "Fox"}, | ||
new Thing {Id = 1200, Name = "Hello"}, | ||
}); | ||
|
||
ids.InnerJoin(itemsCache.Connect(), x => x.Id, (_, thing) => thing) | ||
.Subscribe((z)=>{},ex=>{},()=>{}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters