Beispiel #1
0
        public void TestVertexArray()
        {
            VertexArray <Vertex> va = new VertexArray <Vertex>(2);

            Assert.AreEqual(va.Count, 2);
            Assert.IsNull(va[0]);
            Assert.IsNull(va[1]);
            Vertex v0 = new Vertex();
            Vertex v1 = new Vertex();

            va.Add(0, v0);
            va.Add(1, v1);

            foreach (KeyValuePair <int, Vertex> pair in va)
            {
                Assert.AreNotEqual(pair, null);
                Assert.AreNotEqual(pair.Value, null);
            }

            Assert.AreEqual(va.Count, 2);
            Assert.IsTrue(va.ContainsKey(0));
            Assert.IsTrue(va.ContainsKey(1));
            Assert.IsTrue(va.Contains(new KeyValuePair <int, Vertex>(0, v0)));
            Assert.IsTrue(va.Contains(new KeyValuePair <int, Vertex>(1, v1)));

            Vertex re = null;

            Assert.IsTrue(va.TryGetValue(0, out re));
            Assert.AreEqual(re, v0);
            re = null;
            Assert.IsFalse(va.TryGetValue(2, out re));
            Assert.IsNull(re);

            Assert.IsTrue(va.Remove(new KeyValuePair <int, Vertex>(0, v0)));
            Assert.IsTrue(va.ContainsKey(0));
            Assert.IsTrue(va.ContainsKey(1));
            Assert.IsNull(va[0]);
            Assert.IsNotNull(va[1]);
            Assert.AreEqual(va[1], v1);
            Assert.IsTrue(va.Remove(1));
            Assert.IsNull(va[1]);
            Assert.AreEqual(va.Count, 2);
        }