Skip to content

Commit

Permalink
Improving test stability
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomelli committed Sep 6, 2022
1 parent 5f2e185 commit d3b739e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,19 @@ public void GetDouble_NoArgs_RandomResult()
[Repeat(10)]
public void GetDouble_ManyThreads_DiffRandomResult()
{
var target = new BasicRandomization();
var actual = new BlockingCollection<int>();

Parallel.For(0, 1000, (i) =>
FlowAssert.IsAtLeastOneAttemptOk(10, () =>
{
actual.Add(target.GetInt(0, int.MaxValue));
});
var target = new BasicRandomization();
var actual = new BlockingCollection<int>();
Assert.AreEqual(1000, actual.Count);
Assert.AreEqual(1000, actual.Distinct().Count());
Parallel.For(0, 1000, (i) =>
{
actual.Add(target.GetInt(0, int.MaxValue));
});
Assert.AreEqual(1000, actual.Count);
Assert.AreEqual(1000, actual.Distinct().Count());
});
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,19 @@ public void GetDouble_NoArgs_RandomResult()
[Repeat(10)]
public void GetDouble_ManyThreads_DiffRandomResult()
{
var target = new FastRandomRandomization();
var actual = new BlockingCollection<int>();

Parallel.For(0, 1000, (i) =>
FlowAssert.IsAtLeastOneAttemptOk(10, () =>
{
actual.Add(target.GetInt(0, int.MaxValue));
});
var target = new FastRandomRandomization();
var actual = new BlockingCollection<int>();
Assert.AreEqual(1000, actual.Count);
Assert.AreEqual(1000, actual.Distinct().Count());
Parallel.For(0, 1000, (i) =>
{
actual.Add(target.GetInt(0, int.MaxValue));
});
Assert.AreEqual(1000, actual.Count);
Assert.AreEqual(1000, actual.Distinct().Count());
});
}

[Test]
Expand Down

0 comments on commit d3b739e

Please sign in to comment.