示例#1
0
        /// <summary>
        /// Compare two <see cref="IChemObject"/> classes and return the difference as an <see cref="IDifference"/>.
        /// </summary>
        /// <param name="first">the first of the two classes to compare</param>
        /// <param name="second">the second of the two classes to compare</param>
        /// <returns>an <see cref="IDifference"/> representation of the difference between the first and second <see cref="IChemObject"/>.</returns>
        public static IDifference Difference(IChemObject first, IChemObject second)
        {
            if (!(first is IAtom && second is IAtom))
            {
                return(null);
            }
            IAtom firstElem  = (IAtom)first;
            IAtom secondElem = (IAtom)second;
            ChemObjectDifference totalDiff = new ChemObjectDifference("AtomDiff");

            totalDiff.AddChild(IntegerDifference.Construct("H", firstElem.ImplicitHydrogenCount,
                                                           secondElem.ImplicitHydrogenCount));
            totalDiff
            .AddChild(IntegerDifference.Construct("SP", (int)firstElem.StereoParity, (int)secondElem.StereoParity));
            totalDiff.AddChild(Point2DDifference.Construct("2D", firstElem.Point2D, secondElem.Point2D));
            totalDiff.AddChild(Point3DDifference.Construct("3D", firstElem.Point3D, secondElem.Point3D));
            totalDiff.AddChild(Point3DDifference.Construct("F3D", firstElem.FractionalPoint3D,
                                                           secondElem.FractionalPoint3D));
            totalDiff.AddChild(DoubleDifference.Construct("C", firstElem.Charge, secondElem.Charge));
            totalDiff.AddChild(AtomTypeDiff.Difference(first, second));
            if (totalDiff.ChildCount() > 0)
            {
                return(totalDiff);
            }
            else
            {
                return(null);
            }
        }
示例#2
0
        public void TestMatchAgainstItself()
        {
            var    m_element1 = new Mock <IAtomType>(); IAtomType element1 = m_element1.Object;
            string result = AtomTypeDiff.Diff(element1, element1);

            AssertZeroLength(result);
        }
示例#3
0
        public void TestDifference()
        {
            var m_element1 = new Mock <IAtomType>(); IAtomType element1 = m_element1.Object;
            var m_element2 = new Mock <IAtomType>(); IAtomType element2 = m_element2.Object;

            m_element1.SetupGet(n => n.Hybridization).Returns(Hybridization.Planar3);
            m_element2.SetupGet(n => n.Hybridization).Returns(Hybridization.SP3);

            IDifference difference = AtomTypeDiff.Difference(element1, element2);

            Assert.IsNotNull(difference);
        }
示例#4
0
        public void TestDiff()
        {
            var m_element1 = new Mock <IAtomType>(); IAtomType element1 = m_element1.Object;
            var m_element2 = new Mock <IAtomType>(); IAtomType element2 = m_element2.Object;

            m_element1.SetupGet(n => n.Hybridization).Returns(Hybridization.Planar3);
            m_element2.SetupGet(n => n.Hybridization).Returns(Hybridization.SP3);

            string result = AtomTypeDiff.Diff(element1, element2);

            Assert.IsNotNull(result);
            Assert.AreNotSame(0, result.Length);
            AssertContains(result, "AtomTypeDiff");
            AssertContains(result, "PLANAR3/SP3");
        }