Example #1
0
        public void TestRefs()
        {
            int         x    = 1;
            int         y    = 1;
            IDifference diff = IntegerDifference.Construct("foo", x, y);

            Assert.IsNull(diff);
        }
Example #2
0
        public void TestToString()
        {
            IDifference result     = IntegerDifference.Construct("Foo", 1, 2);
            string      diffString = result.ToString();

            Assert.IsNotNull(diffString);
            AssertOneLiner(diffString);
        }
Example #3
0
        public void TestOneNull()
        {
            IDifference result = IntegerDifference.Construct("Foo", null, 1);

            Assert.IsNotNull(result);

            result = IntegerDifference.Construct("Foo", 2, null);
            Assert.IsNotNull(result);
        }
Example #4
0
        public void TestChildDiffs()
        {
            DifferenceClass    diffClass = new DifferenceClass();
            List <IDifference> diffs     = new List <IDifference>
            {
                StringDifference.Construct("Foo", "Bar1", "Bar2"),
                IntegerDifference.Construct("Foo", 1, 2)
            };

            diffClass.AddChildren(diffs);
            Assert.AreEqual(2, diffClass.ChildCount());
            var diffs2 = diffClass.GetChildren().GetEnumerator();
            int count  = 0;

            while (diffs2.MoveNext())
            {
                var dummy = diffs2.Current;
                count++;
            }
            Assert.AreEqual(2, count);
        }
Example #5
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 IIsotope && second is IIsotope))
            {
                return(null);
            }
            IIsotope             firstElem  = (IIsotope)first;
            IIsotope             secondElem = (IIsotope)second;
            ChemObjectDifference totalDiff  = new ChemObjectDifference("IsotopeDiff");

            totalDiff.AddChild(IntegerDifference.Construct("MN", firstElem.MassNumber, secondElem.MassNumber));
            totalDiff.AddChild(DoubleDifference.Construct("EM", firstElem.ExactMass, secondElem.ExactMass));
            totalDiff.AddChild(DoubleDifference.Construct("AB", firstElem.Abundance,
                                                          secondElem.Abundance));
            totalDiff.AddChild(ElementDiff.Difference(first, second));
            if (totalDiff.ChildCount() > 0)
            {
                return(totalDiff);
            }
            else
            {
                return(null);
            }
        }
Example #6
0
        public void TestTwoNull()
        {
            IDifference result = IntegerDifference.Construct("Foo", null, null);

            Assert.IsNull(result);
        }
Example #7
0
        public void TestSame()
        {
            IDifference result = IntegerDifference.Construct("Foo", 1, 1);

            Assert.IsNull(result);
        }
Example #8
0
        public void TestDiff()
        {
            IDifference result = IntegerDifference.Construct("Foo", 1, 2);

            Assert.IsNotNull(result);
        }