コード例 #1
0
ファイル: Given_HashtableEx.cs プロジェクト: unoplatform/uno
        public void Clone_IsShallowCopy()
        {
            var hash = new HashtableEx();

            for (int i = 0; i < 10; i++)
            {
                hash.Add(i, new Foo());
            }

            HashtableEx clone = (HashtableEx)hash.Clone();

            for (int i = 0; i < clone.Count; i++)
            {
                Assert.AreEqual("Hello World", ((Foo)clone[i]).StringValue);
                Assert.AreEqual(hash[i], clone[i]);
            }

            // Change object in original hashtable
            ((Foo)hash[1]).StringValue = "Goodbye";
            Assert.AreEqual("Goodbye", ((Foo)clone[1]).StringValue);

            // Removing an object from the original hashtable doesn't change the clone
            hash.Remove(0);
            Assert.IsTrue(clone.Contains(0));
        }