Ejemplo n.º 1
0
        private VisitableHashtable <string, string> GetTestHashtable()
        {
            VisitableHashtable <string, string> h = new VisitableHashtable <string, string>();

            h.Add("a", "aa");
            h.Add("b", "bb");
            h.Add("c", "cc");

            return(h);
        }
Ejemplo n.º 2
0
        public void TestSuccesfulInit()
        {
            // Default constructor
            VisitableHashtable <string, string> h1 = new VisitableHashtable <string, string>();

            Assert.AreEqual(h1.Count, 0);
            Assert.AreEqual(h1.IsEmpty, true);
            Assert.AreEqual(h1.IsFull, false);

            VisitableHashtable <string, string> h2 = new VisitableHashtable <string, string>();

            h2.Add("aa", "bb");
            h2.Add("cc", "dd");

            Assert.AreEqual(h2.Count, 2);
            Assert.AreEqual(h2.IsEmpty, false);
            Assert.AreEqual(h2.IsFull, false);

            h1 = new VisitableHashtable <string, string>(h2);

            Assert.AreEqual(h1.Count, 2);
            Assert.AreEqual(h1.IsEmpty, false);
            Assert.AreEqual(h1.IsFull, false);

            h1 = new VisitableHashtable <string, string>(new DummyComparer());

            Assert.AreEqual(h1.Count, 0);
            Assert.AreEqual(h1.IsEmpty, true);
            Assert.AreEqual(h1.IsFull, false);

            h1 = new VisitableHashtable <string, string>(50);

            Assert.AreEqual(h1.Count, 0);
            Assert.AreEqual(h1.IsEmpty, true);
            Assert.AreEqual(h1.IsFull, false);

            h1 = new VisitableHashtable <string, string>(h2, new DummyComparer());

            Assert.AreEqual(h1.Count, 2);
            Assert.AreEqual(h1.IsEmpty, false);
            Assert.AreEqual(h1.IsFull, false);

            h1 = new VisitableHashtable <string, string>(300, new DummyComparer());

            Assert.AreEqual(h1.Count, 0);
            Assert.AreEqual(h1.IsEmpty, true);
            Assert.AreEqual(h1.IsFull, false);
        }
Ejemplo n.º 3
0
        public void TestIsFull()
        {
            VisitableHashtable <string, string> h = GetTestHashtable();

            Assert.AreEqual(h.IsFull, false);

            h = new VisitableHashtable <string, string>();
            Assert.AreEqual(h.IsFull, false);

            h.Add("ff", "fff");
            Assert.AreEqual(h.IsFull, false);
        }
Ejemplo n.º 4
0
        public void TestCompareTo()
        {
            VisitableHashtable <string, string> h1 = GetTestHashtable();
            VisitableHashtable <string, string> h2 = GetTestHashtable();

            h2.Add("d", "dd");

            Assert.AreEqual(h1.CompareTo(h2), -1);
            Assert.AreEqual(h2.CompareTo(h1), 1);
            Assert.AreEqual(h1.CompareTo(h1), 0);

            object o = new object();

            Assert.AreEqual(h1.CompareTo(o), -1);
        }