示例#1
0
        public virtual void TestClone_Properties2()
        {
            IChemObject chemObject1 = NewChemObject();
            var         props1      = new Dictionary <object, object>();
            IAtom       atom        = chemObject1.Builder.NewAtom("C");

            props1.Add("atom", atom);
            chemObject1.AddProperties(props1);
            IChemObject chemObject2 = (IChemObject)chemObject1.Clone();

            // test cloning of properties field
            var props2 = new Dictionary <object, object>();

            chemObject2.AddProperties(props2);
            Assert.IsTrue(Compares.AreDeepEqual(props1, chemObject1.GetProperties()));
            Assert.AreEqual(1, chemObject2.GetProperties().Count());
            Assert.AreEqual(1, chemObject1.GetProperties().Count());
            // ok, copied hashtable item, but this item should be cloned
            Assert.IsTrue(atom.Compare(chemObject2.GetProperties().First(pair => pair.Key.Equals("atom")).Value));
        }