Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ bool TryTake (out T item, Func<bool> contFunc, CancellationToken token)

if (!mreRemove.IsSet)
mreRemove.Set ();
return true;
} while (contFunc ());

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,22 @@ public void ConsumingEnumerableTestCase()
}
Assert.AreEqual(0, defaultCollection.Count, "#" + i);
}

[TestAttribute]
public void TryTakeTestCase ()
{
defaultCollection.Add (1);

int value = default (int);
bool firstTake = defaultCollection.TryTake (out value);
int value2 = default (int);
bool secondTake = defaultCollection.TryTake (out value2);

Assert.AreEqual (1, value);
Assert.IsTrue (firstTake);
Assert.AreEqual (default (int), value2);
Assert.IsFalse (secondTake);
}
}
}
#endif