public void TestToString() { IDifference result = DoubleDifference.Construct("Foo", 1.0, 2.0); string diffString = result.ToString(); Assert.IsNotNull(diffString); AssertOneLiner(diffString); }
public void TestOneNull() { IDifference result = DoubleDifference.Construct("Foo", null, 1.0); Assert.IsNotNull(result); result = DoubleDifference.Construct("Foo", 3.0, null); Assert.IsNotNull(result); }
/// <summary> /// Constructs a new <see cref="IDifference"/> object. /// </summary> /// <param name="name">a name reflecting the nature of the created <see cref="IDifference"/></param> /// <param name="first">the first object to compare</param> /// <param name="second">the second object to compare</param> /// <returns>an <see cref="IDifference"/> reflecting the differences between the first and second object</returns> public static IDifference Construct(string name, Vector2?first, Vector2?second) { if (first == null && second == null) { return(null); } var totalDiff = new Point2DDifference(name); totalDiff.AddChild(DoubleDifference.Construct("x", first.HasValue ? (double?)null : first.Value.X, second.HasValue ? (double?)null : second.Value.X)); totalDiff.AddChild(DoubleDifference.Construct("y", first.HasValue ? (double?)null : first.Value.Y, second.HasValue ? (double?)null : second.Value.Y)); if (totalDiff.ChildCount() == 0) { return(null); } return(totalDiff); }
/// <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); } }
public void TestTwoNull() { IDifference result = DoubleDifference.Construct("Foo", null, null); Assert.IsNull(result); }
public void TestSame() { IDifference result = DoubleDifference.Construct("Foo", 1.0, 1.0); Assert.IsNull(result); }