Пример #1
0
        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 ) );

              }
        }
Пример #2
0
        public void TestSortMetPersoon()
        {
            Container container = new Container();

              Persoon p1 = new Persoon( "jan", "eindhoven" ),
              p2 = new Persoon( "Jan", "Amsterdam" ),
              p3 = new Persoon( "Piet", "Eindhoven" ),
              p4 = new Persoon( "jan", "eindhoven" );
              //in andere testen worden ook personen gecreeerd, dus eerst even kijken waar de
              //nummering voor deze test begint
              int startId = p1.Id;
              container.Add( new Persoon( "jan", "Tilburg" ) );
              container.Add( p3 );
              container.Add( p2 );
              container.Add( new Persoon( "piet", "Utrecht" ) );
              container.Add( p4 );
              container.Add( p3 );
              container.Add( p1 );

              container.Sort( );
              Assert.AreEqual( 7, container.Items.Length );
              Object[] items = container.Items;
              Assert.AreEqual( p1, items[0] );
              Assert.AreEqual( p2, items[1] );
              Assert.AreEqual( p3, items[2] );
              Assert.AreEqual( p3, items[3] );
              Assert.AreEqual( p4, items[4] );
              Assert.AreEqual( startId + 4, ((Persoon)items[5]).Id );
              Assert.AreEqual( startId + 5, ((Persoon)items[6]).Id );
        }
Пример #3
0
 public void TestCountMetPersoon()
 {
     Container container = new Container();
       Persoon p = new Persoon( "jan", "eindhoven" );
       container.Add( new Persoon( "jan", "eindhoven" ) );
       container.Add( new Persoon( "jan", "eindhoven" ) );
       container.Add( p );
       container.Add( p );
       Assert.AreEqual( 4, container.Items.Length );
       Assert.AreEqual( 2, container.Count( p ) );
       Assert.AreEqual( 0, container.Count( new Persoon( "jan", "eindhoven" ) ) );
 }