public void TestCompressMetInts() { Container c1 = new Container(); Container c2 = new Container(); c1.Add( 2 ); c1.Add( 7 ); c1.Add( 5 ); c1.Add( 3 ); c1.Add( 2 ); c2.Add( 2 ); c2.Add( 7 ); c2.Add( 5 ); c2.Add( 3 ); c2.Add( 2 ); c2.Compress(); Object[] items = c1.Items; foreach (IComparable o in c1.Items) { Assert.AreEqual( c2.Count( o ), 1 ); } foreach (IComparable o in c2.Items) { Assert.AreNotEqual( 0, c1.Count( o ) ); } }
public void TestCompressMetPersoon() { Container c1 = new Container(); Persoon p1 = new Persoon( "jan", "eindhoven" ), p2 = new Persoon( "Jan", "Amsterdam" ), p3 = new Persoon( "Piet", "Eindhoven" ), p4 = new Persoon( "jan", "eindhoven" ), p5 = new Persoon( "jan", "Tilburg" ), p6 = new Persoon( "piet", "Utrecht" ); c1.Add( p5 ); c1.Add( p3 ); c1.Add( p2 ); c1.Add( p6 ); c1.Add( p4 ); c1.Add( p3 ); c1.Add( p1 ); c1.Add( p5 ); c1.Add( p2 ); c1.Add( p5 ); Container c2 = new Container(); c2.Add( p5 ); c2.Add( p3 ); c2.Add( p2 ); c2.Add( p6 ); c2.Add( p4 ); c2.Add( p3 ); c2.Add( p1 ); c2.Add( p5 ); c2.Add( p2 ); c2.Add( p5 ); c2.Compress(); Object[] items = c1.Items; foreach (IComparable o in c1.Items) { Assert.AreEqual( c2.Count( o ), 1 ); } foreach (IComparable o in c2.Items) { Assert.AreNotEqual( 0, c1.Count( o ) ); } }
public void TestCompressMetStrings() { Container c1 = new Container(); c1.Add( "c" ); c1.Add( "c" ); c1.Add( "A" ); c1.Add( "Goedemorgen" ); c1.Add( "a" ); c1.Add( "thee" ); c1.Add( "Koffie" ); c1.Add( "Groot" ); c1.Add( "goedemorgen" ); c1.Add( "klein" ); Container c2 = new Container(); c2.Add( "c" ); c2.Add( "c" ); c2.Add( "A" ); c2.Add( "Goedemorgen" ); c2.Add( "a" ); c2.Add( "thee" ); c2.Add( "Koffie" ); c2.Add( "Groot" ); c2.Add( "goedemorgen" ); c2.Add( "klein" ); c2.Compress(); Object[] items = c1.Items; foreach (IComparable o in c1.Items) { Assert.AreEqual( c2.Count( o ), 1 ); } foreach (IComparable o in c2.Items) { Assert.AreNotEqual( 0, c1.Count( o ) ); } }
public void TestLegeContainer() { Container container = new Container(); Assert.AreEqual( 0, container.Items.Length ); Assert.AreEqual( 0, container.Count( "wat dan ook" ) ); //controle of de Sort- en Compressmethode geen Exception veroorzaken container.Compress(); Assert.AreEqual( 0, container.Items.Length ); container.Sort(); Assert.AreEqual( 0, container.Items.Length ); }