Skip to content

Commit

Permalink
Reformatted.
Browse files Browse the repository at this point in the history
SVN: trunk@2660
  • Loading branch information
Sergey Koshcheyev committed Feb 23, 2007
1 parent 5e71e83 commit 2d2b09b
Show file tree
Hide file tree
Showing 298 changed files with 7,354 additions and 7,873 deletions.
29 changes: 14 additions & 15 deletions src/Iesi.Collections.Test/Generic/HashedSetFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

using System;
using System.Collections.Generic;

using Iesi.Collections.Generic;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;

using NUnit.Framework;

Expand All @@ -15,7 +16,6 @@ namespace Iesi.Collections.Generic.Test
[TestFixture]
public class HashedSetFixture : GenericSetFixture
{

protected override ISet<string> CreateInstance()
{
return new HashedSet<string>();
Expand All @@ -32,24 +32,23 @@ protected override Type ExpectedType
}

[Test]
public void Serialization()
public void Serialization()
{
// serialize and then deserialize the ISet.
System.IO.Stream stream = new System.IO.MemoryStream();
System.Runtime.Serialization.IFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
formatter.Serialize( stream, _set );
Stream stream = new MemoryStream();
IFormatter formatter = new BinaryFormatter();
formatter.Serialize(stream, _set);
stream.Position = 0;

ISet<string> desSet = (ISet<string>)formatter.Deserialize(stream);
ISet<string> desSet = (ISet<string>) formatter.Deserialize(stream);
stream.Close();

Assert.AreEqual( 3, desSet.Count, "should have des 3 items" );
Assert.IsTrue( desSet.Contains( one ), "should contain one" );
Assert.IsTrue( desSet.Contains( two ), "should contain two" );
Assert.IsTrue( desSet.Contains( three ), "should contain three" );
Assert.AreEqual(3, desSet.Count, "should have des 3 items");
Assert.IsTrue(desSet.Contains(one), "should contain one");
Assert.IsTrue(desSet.Contains(two), "should contain two");
Assert.IsTrue(desSet.Contains(three), "should contain three");
}


}
}
#endif

#endif
8 changes: 3 additions & 5 deletions src/Iesi.Collections.Test/Generic/ImmutableSetFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
using System;
using System.Collections.Generic;

using Iesi.Collections.Generic;

using NUnit.Framework;

namespace Iesi.Collections.Generic.Test
Expand All @@ -15,7 +13,6 @@ namespace Iesi.Collections.Generic.Test
[TestFixture]
public class ImmutableSetFixture : GenericSetFixture
{

protected override ISet<string> CreateInstance()
{
return new ImmutableSet<string>(new HashedSet<string>());
Expand All @@ -29,7 +26,8 @@ protected override ISet<string> CreateInstance(ICollection<string> init)
protected override Type ExpectedType
{
get { return typeof(ImmutableSet<string>); }
}
}
}
}
#endif

#endif
45 changes: 21 additions & 24 deletions src/Iesi.Collections.Test/Generic/SetFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
using System;
using System.Collections.Generic;

using Iesi.Collections.Generic;

using NUnit.Framework;

namespace Iesi.Collections.Generic.Test
Expand Down Expand Up @@ -36,15 +34,15 @@ public virtual void SetUp()
_bInitValues.Add("three");
_bInitValues.Add("four");

_set = CreateInstance(new string[] { one, two, three });
_set = CreateInstance(new string[] {one, two, three});
}

#region System.IClonable Member Tests

[Test]
public void Clone()
{
ISet<string> clonedSet = (ISet<string>)_set.Clone();
ISet<string> clonedSet = (ISet<string>) _set.Clone();

Assert.AreEqual(ExpectedType, clonedSet.GetType(), "cloned set should be the same type");
Assert.AreEqual(_set.Count, clonedSet.Count, "set and cloned version should be same");
Expand All @@ -54,7 +52,7 @@ public void Clone()
clonedSet.Add("not in original");
Assert.IsFalse(_set.Count == clonedSet.Count, "adding to clone should not add to original.");
if (clonedSet.IsReadOnly)
Assert.Fail("Read-only set can be modified");
Assert.Fail("Read-only set can be modified");
}
catch (NotSupportedException)
{
Expand All @@ -77,7 +75,7 @@ public void CopyTo()
{
string[] dest = new string[3];
_set.CopyTo(dest, 0);

int count = 0;

foreach (string obj in dest)
Expand Down Expand Up @@ -164,7 +162,7 @@ public void AddAll()
catch (NotSupportedException)
{
if (!_set.IsReadOnly)
throw;
throw;
}
}

Expand All @@ -177,12 +175,12 @@ public void Clear()
Assert.AreEqual(0, _set.Count, "should have no items in ISet.");

if (_set.IsReadOnly)
Assert.Fail("Read-only set can be modified");
Assert.Fail("Read-only set can be modified");
}
catch (NotSupportedException)
{
if (!_set.IsReadOnly)
throw;
throw;
}
}

Expand Down Expand Up @@ -234,7 +232,7 @@ public void ExclusiveOr()
Assert.AreEqual(null, bothNull, "two null sets return null set");
}

[Test]
[Test]
public void Intersect()
{
ISet<string> a = CreateInstance(_aInitValues);
Expand Down Expand Up @@ -303,12 +301,12 @@ public void Remove()

Assert.IsFalse(_set.Remove(one), "was already removed.");
if (_set.IsReadOnly)
Assert.Fail("Read-only set can be modified");
Assert.Fail("Read-only set can be modified");
}
catch (NotSupportedException)
{
if (!_set.IsReadOnly)
throw;
throw;
}
}

Expand All @@ -327,10 +325,10 @@ public void RemoveAll()
if (_set.IsReadOnly)
Assert.Fail("Read-only set can be modified");
}
catch (NotSupportedException)
catch (NotSupportedException)
{
if (!_set.IsReadOnly)
throw;
throw;
}
}

Expand Down Expand Up @@ -387,16 +385,17 @@ public void Union()
Assert.AreEqual(null, bothNull, "two nulls intersect as null");
}

#endregion
#endregion

#region Iesi.Collection.ISet<string> Operator Tests

[Test]
public void ExclusiveOrOperator()
{
ISet<string> a = CreateInstance(_aInitValues);
ISet<string> b = CreateInstance(_bInitValues);

ISet<string> ab = (Set<string>)a ^ (Set<string>)b;
ISet<string> ab = (Set<string>) a ^ (Set<string>) b;

Assert.AreEqual(3, ab.Count, "contains 3 elements - 'zero', 'one', and 'four'");
Assert.IsTrue(ab.Contains("zero"), "should contain 'zero'");
Expand All @@ -413,7 +412,7 @@ public void IntersectOperator()
ISet<string> a = CreateInstance(_aInitValues);
ISet<string> b = CreateInstance(_bInitValues);

ISet<string> ab = (Set<string>)a & (Set<string>)b;
ISet<string> ab = (Set<string>) a & (Set<string>) b;

Assert.AreEqual(2, ab.Count, "contains 2 elements - 'two', and 'three'");
Assert.IsTrue(ab.Contains("two"), "should contain 'two'");
Expand All @@ -426,15 +425,14 @@ public void MinusOperator()
ISet<string> a = CreateInstance(_aInitValues);
ISet<string> b = CreateInstance(_bInitValues);

ISet<string> ab = (Set<string>)a - (Set<string>)b;
ISet<string> ab = (Set<string>) a - (Set<string>) b;

Assert.AreEqual(2, ab.Count, "contains 2 elements - 'zero', and 'one'");
Assert.IsTrue(ab.Contains("zero"), "should contain 'zero'");
Assert.IsTrue(ab.Contains("one"), "should contain 'one'");

Assert.IsTrue(a.ContainsAll(_aInitValues), "should not have modified a");
Assert.IsTrue(b.ContainsAll(_bInitValues), "should not have modified b");

}

[Test]
Expand All @@ -443,7 +441,7 @@ public void UnionOperator()
ISet<string> a = CreateInstance(_aInitValues);
ISet<string> b = CreateInstance(_bInitValues);

ISet<string> ab = (Set<string>)a | (Set<string>)b;
ISet<string> ab = (Set<string>) a | (Set<string>) b;

Assert.AreEqual(5, ab.Count, "contains 5 elements - 'zero' through 'four'");
Assert.IsTrue(ab.Contains("zero"), "should contain 'zero'");
Expand All @@ -454,17 +452,16 @@ public void UnionOperator()

Assert.IsTrue(a.ContainsAll(_aInitValues), "should not have modified a");
Assert.IsTrue(b.ContainsAll(_bInitValues), "should not have modified b");

}


#endregion

protected abstract ISet<string> CreateInstance();

protected abstract ISet<string> CreateInstance(ICollection<string> init);

protected abstract System.Type ExpectedType { get; }
protected abstract Type ExpectedType { get; }
}
}
#endif

#endif
36 changes: 18 additions & 18 deletions src/Iesi.Collections.Test/Generic/SortedSetFixture.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#if NET_2_0

using System;
using System.Collections;
using System.Collections.Generic;

using Iesi.Collections.Generic;

using NUnit.Framework;

namespace Iesi.Collections.Generic.Test
Expand All @@ -13,7 +12,7 @@ namespace Iesi.Collections.Generic.Test
/// Summary description for SortedSetFixture.
/// </summary>
[TestFixture]
public class SortedSetFixture : GenericSetFixture
public class SortedSetFixture : GenericSetFixture
{
protected override ISet<string> CreateInstance()
{
Expand All @@ -31,29 +30,29 @@ protected override Type ExpectedType
}

[Test]
public void OrderedEnumeration()
public void OrderedEnumeration()
{
List<string> expectedOrder = new List<string>(3);
expectedOrder.Add( one );
expectedOrder.Add( two );
expectedOrder.Add( three );
expectedOrder.Sort( );
expectedOrder.Add(one);
expectedOrder.Add(two);
expectedOrder.Add(three);
expectedOrder.Sort();

int index = 0;
foreach( string str in _set )
foreach (string str in _set)
{
Assert.AreEqual( str, expectedOrder[index], index.ToString() + " did not have same value" );
Assert.AreEqual(str, expectedOrder[index], index.ToString() + " did not have same value");
index++;
}
}

[Test]
public void OrderedCaseInsensitiveEnumeration()
public void OrderedCaseInsensitiveEnumeration()
{
System.Collections.ArrayList expectedOrder = new System.Collections.ArrayList(3);
expectedOrder.Add( "ONE" );
expectedOrder.Add( "two" );
expectedOrder.Add( "tHree" );
ArrayList expectedOrder = new ArrayList(3);
expectedOrder.Add("ONE");
expectedOrder.Add("two");
expectedOrder.Add("tHree");

SortedSet<string> theSet = new SortedSet<string>(StringComparer.CurrentCultureIgnoreCase);
foreach (string str in expectedOrder)
Expand All @@ -62,12 +61,13 @@ public void OrderedCaseInsensitiveEnumeration()
expectedOrder.Sort(StringComparer.CurrentCultureIgnoreCase);

int index = 0;
foreach( string str in theSet )
foreach (string str in theSet)
{
Assert.AreEqual( str, expectedOrder[index], index.ToString() + " did not have same value" );
Assert.AreEqual(str, expectedOrder[index], index.ToString() + " did not have same value");
index++;
}
}
}
}
#endif

#endif
Loading

0 comments on commit 2d2b09b

Please sign in to comment.