private void testUnion(DisjointSets <DSString> the_d_sets)
        {
            //union two sets
            the_d_sets.union(new DSString("A"), new DSString("B"));
            Assert.AreEqual(true, the_d_sets.find(new DSString("A")) == the_d_sets.find(new DSString("B")));

            //union a different pair
            the_d_sets.union(new DSString("C"), new DSString("D"));
            Assert.AreEqual(true, the_d_sets.find(new DSString("C")) == the_d_sets.find(new DSString("D")));

            //join the two pairs
            the_d_sets.union(new DSString("A"), new DSString("C"));
            Assert.AreEqual(true, the_d_sets.find(new DSString("A")) == the_d_sets.find(new DSString("C")));
            Assert.AreEqual(true, the_d_sets.find(new DSString("A")) == the_d_sets.find(new DSString("D")));
            Assert.AreEqual(true, the_d_sets.find(new DSString("B")) == the_d_sets.find(new DSString("C")));
            Assert.AreEqual(true, the_d_sets.find(new DSString("B")) == the_d_sets.find(new DSString("D")));

            //join the last set
            the_d_sets.union(new DSString("D"), new DSString("E"));
            Assert.AreEqual(true, the_d_sets.find(new DSString("A")) == the_d_sets.find(new DSString("B")));
            Assert.AreEqual(true, the_d_sets.find(new DSString("A")) == the_d_sets.find(new DSString("C")));
            Assert.AreEqual(true, the_d_sets.find(new DSString("A")) == the_d_sets.find(new DSString("D")));
            Assert.AreEqual(true, the_d_sets.find(new DSString("A")) == the_d_sets.find(new DSString("E")));
            Assert.AreEqual(true, the_d_sets.find(new DSString("B")) == the_d_sets.find(new DSString("C")));
            Assert.AreEqual(true, the_d_sets.find(new DSString("B")) == the_d_sets.find(new DSString("D")));
            Assert.AreEqual(true, the_d_sets.find(new DSString("B")) == the_d_sets.find(new DSString("E")));
            Assert.AreEqual(true, the_d_sets.find(new DSString("C")) == the_d_sets.find(new DSString("D")));
            Assert.AreEqual(true, the_d_sets.find(new DSString("C")) == the_d_sets.find(new DSString("E")));
            Assert.AreEqual(true, the_d_sets.find(new DSString("D")) == the_d_sets.find(new DSString("E")));
        }
 private void testToString(DisjointSets <DSString> the_d_sets)
 {
     //just test for no exceptions, leave the output to the programmer, user
     try
     {
         the_d_sets.ToString();
     }
     catch (Exception the_ex)
     {
         Assert.Fail();
     }
 }
        private void testFind(DisjointSets <DSString> the_d_sets)
        {
            Assert.AreEqual(0, the_d_sets.find(new DSString("A")));
            Assert.AreEqual(1, the_d_sets.find(new DSString("B")));
            Assert.AreEqual(2, the_d_sets.find(new DSString("C")));
            Assert.AreEqual(3, the_d_sets.find(new DSString("D")));
            Assert.AreEqual(4, the_d_sets.find(new DSString("E")));

            the_d_sets.union(new DSString("A"), new DSString("B"));
            Assert.AreEqual(0, the_d_sets.find(new DSString("A")));
            Assert.AreEqual(0, the_d_sets.find(new DSString("B")));
        }
        private void testGetSetElements(DisjointSets <DSString> the_d_sets)
        {
            //union two sets
            the_d_sets.union(new DSString("A"), new DSString("B"));

            //get elements and make sure only the correct ones are in the set
            List <DSString> elements = the_d_sets.getSetElements(the_d_sets.find(new DSString("A")));

            Assert.AreEqual(2, elements.size());
            Assert.AreEqual(true, elements.contains(new DSString("A")));
            Assert.AreEqual(true, elements.contains(new DSString("B")));

            //union two sets
            the_d_sets.union(new DSString("C"), new DSString("D"));

            //get elements and make sure only the correct ones are in the set
            elements = the_d_sets.getSetElements(the_d_sets.find(new DSString("C")));
            Assert.AreEqual(2, elements.size());
            Assert.AreEqual(true, elements.contains(new DSString("C")));
            Assert.AreEqual(true, elements.contains(new DSString("D")));

            //union both pair sets
            the_d_sets.union(new DSString("B"), new DSString("D"));

            //get elements and make sure only the correct ones are in the set
            elements = the_d_sets.getSetElements(the_d_sets.find(new DSString("A")));
            Assert.AreEqual(4, elements.size());
            Assert.AreEqual(true, elements.contains(new DSString("A")));
            Assert.AreEqual(true, elements.contains(new DSString("B")));
            Assert.AreEqual(true, elements.contains(new DSString("C")));
            Assert.AreEqual(true, elements.contains(new DSString("D")));

            //union both pair sets
            the_d_sets.union(new DSString("A"), new DSString("E"));

            //get elements and make sure only the correct ones are in the set
            elements = the_d_sets.getSetElements(the_d_sets.find(new DSString("A")));
            Assert.AreEqual(5, elements.size());
            Assert.AreEqual(true, elements.contains(new DSString("A")));
            Assert.AreEqual(true, elements.contains(new DSString("B")));
            Assert.AreEqual(true, elements.contains(new DSString("C")));
            Assert.AreEqual(true, elements.contains(new DSString("D")));
            Assert.AreEqual(true, elements.contains(new DSString("E")));
        }
        private void testAdd(DisjointSets <DSString> the_d_sets)
        {
            my_d_sets = new DisjointSets <DSString>();

            //add 100 items
            for (int i = 0; i < 100; i++)
            {
                my_d_sets.addSet(new DSString(i.ToString()));
            }

            //union them all
            for (int i = 0; i < 99; i++)
            {
                my_d_sets.union(new DSString(i.ToString()), new DSString((i + 1).ToString()));
            }

            //ensure they are all in the same set
            for (int i = 0; i < 99; i++)
            {
                Assert.AreEqual(true, my_d_sets.find(new DSString(i.ToString())) == my_d_sets.find(new DSString((i + 1).ToString())));
            }
        }
 public void MyTestInitialize()
 {
     my_d_sets = new DisjointSets <DSString>(new DSString[] { new DSString("A"), new DSString("B"),
                                                              new DSString("C"), new DSString("D"), new DSString("E") });
 }