1 // -----------------------------------------------------------------------
\r
2 // <copyright file="ExtensionTests.cs" company="GRNet">
\r
3 // Copyright 2011 GRNET S.A. All rights reserved.
\r
5 // Redistribution and use in source and binary forms, with or
\r
6 // without modification, are permitted provided that the following
\r
7 // conditions are met:
\r
9 // 1. Redistributions of source code must retain the above
\r
10 // copyright notice, this list of conditions and the following
\r
13 // 2. Redistributions in binary form must reproduce the above
\r
14 // copyright notice, this list of conditions and the following
\r
15 // disclaimer in the documentation and/or other materials
\r
16 // provided with the distribution.
\r
18 // THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
\r
19 // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
\r
20 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
\r
21 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
\r
22 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
\r
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
\r
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
\r
25 // USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
\r
26 // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
\r
27 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
\r
28 // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
\r
29 // POSSIBILITY OF SUCH DAMAGE.
\r
31 // The views and conclusions contained in the software and
\r
32 // documentation are those of the authors and should not be
\r
33 // interpreted as representing official policies, either expressed
\r
34 // or implied, of GRNET S.A.
\r
36 // -----------------------------------------------------------------------
\r
38 using System.Collections.Concurrent;
\r
39 using NUnit.Framework;
\r
41 namespace Pithos.Core.Test
\r
47 /// TODO: Update summary.
\r
50 public class ExtensionTests
\r
53 public void TestRemoveConcurrent()
\r
55 var test=new ConcurrentQueue<int>();
\r
56 for (var i = 0; i < 100; i++)
\r
61 test.RemoveFirst(t=>t==3);
\r
62 Assert.IsFalse(test.Any(t => t == 3),"Item was not removed");
\r
63 for (var i=0;i<3;i++)
\r
66 Assert.IsTrue(test.TryDequeue(out item),"Missing items");
\r
67 Assert.AreEqual(i, item,"Preceding items not queued correctly");
\r
69 for (var i = 4; i < 100; i++)
\r
72 Assert.IsTrue(test.TryDequeue(out item), "Missing items");
\r
73 Assert.AreEqual(i, item, "Succeeding items not queued correctly");
\r