Skip to content

Commit

Permalink
Update tests per feedbacks: enable more innerloop tests; fix exceptio…
Browse files Browse the repository at this point in the history
…n tests using Assert.Throws etc.
  • Loading branch information
dotnet-bot committed Jan 20, 2015
1 parent 2d3f6fa commit b9e4acf
Show file tree
Hide file tree
Showing 11 changed files with 886 additions and 2,070 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,22 @@ namespace Test
public class BlockingCollectionCancellationTests
{
[Fact]
[OuterLoop]
public static void InternalCancellation_CompleteAdding_Negative()
{
BlockingCollection<int> coll1 = new BlockingCollection<int>();

Task.Run(() => coll1.CompleteAdding());
//call Take.. it should wake up with an OCE. when CompleteAdding() is called.
Assert.Throws<InvalidOperationException>(
() => coll1.Take());
Assert.Throws<InvalidOperationException>(() => coll1.Take());
// "InternalCancellation_WakingUpTake: an IOE should be thrown if CompleteAdding occurs during blocking Take()");
Assert.Throws<InvalidOperationException>(
() => coll1.Add(1));
Assert.Throws<InvalidOperationException>(() => coll1.Add(1));
// "InternalCancellation_WakingUpAdd: an InvalidOpEx should be thrown if CompleteAdding occurs during blocking Add()");
Assert.Throws<InvalidOperationException>(
() => coll1.TryAdd(1, 1000000)); //an indefinite wait to add.. 1000 seconds.
Assert.Throws<InvalidOperationException>(() => coll1.TryAdd(1, 1000000)); //an indefinite wait to add.. 1000 seconds.
// "InternalCancellation_WakingUpTryAdd: an InvalidOpEx should be thrown if CompleteAdding occurs during blocking Add()");
}

//This tests that Take/TryTake wake up correctly if CompleteAdding() is called while the taker is waiting.
[Fact]
[OuterLoop]
public static void InternalCancellation_WakingUpTryTake()
{
BlockingCollection<int> coll1 = new BlockingCollection<int>();
Expand All @@ -52,7 +47,6 @@ public static void InternalCancellation_WakingUpTryTake()

//This tests that Take/TryTake wake up correctly if CompleteAdding() is called while the taker is waiting.
[Fact]
[OuterLoop]
public static void InternalCancellation_WakingUpAdd()
{
BlockingCollection<int> coll1 = new BlockingCollection<int>(1);
Expand Down Expand Up @@ -85,7 +79,6 @@ public static void InternalCancellation_WakingUpTryAdd()
}

[Fact]
[OuterLoop]
public static void ExternalCancel_Negative()
{
BlockingCollection<int> bc = new BlockingCollection<int>(); //empty collection.
Expand All @@ -94,7 +87,6 @@ public static void ExternalCancel_Negative()
Task.Run(() => cs.Cancel());

int item;

EnsureOperationCanceledExceptionThrown(
() => bc.Take(cs.Token), cs.Token,
"ExternalCancel_Take: The operation should wake up via token cancellation.");
Expand Down Expand Up @@ -129,7 +121,6 @@ public static void ExternalCancel_Negative()
}

[Fact]
[OuterLoop]
public static void ExternalCancel_AddToAny()
{
BlockingCollection<int> bc1 = new BlockingCollection<int>(1);
Expand All @@ -148,7 +139,6 @@ public static void ExternalCancel_AddToAny()
}

[Fact]
[OuterLoop]
public static void ExternalCancel_TryAddToAny()
{
BlockingCollection<int> bc1 = new BlockingCollection<int>(1);
Expand All @@ -167,7 +157,6 @@ public static void ExternalCancel_TryAddToAny()
}

[Fact]
[OuterLoop]
public static void ExternalCancel_GetConsumingEnumerable()
{
BlockingCollection<int> bc = new BlockingCollection<int>();
Expand Down
1,058 changes: 226 additions & 832 deletions src/System.Collections.Concurrent/tests/BlockingCollectionTests.cs

Large diffs are not rendered by default.

Loading

0 comments on commit b9e4acf

Please sign in to comment.