public void TestToString() { IDifference result = BooleanDifference.Construct("Foo", true, false); string diffString = result.ToString(); Assert.IsNotNull(diffString); AssertOneLiner(diffString); }
public void TestOneNull() { IDifference result = BooleanDifference.Construct("Foo", null, false); Assert.IsNotNull(result); result = BooleanDifference.Construct("Foo", false, 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, bool[] first, bool[] second) { if (first == null && second == null) { return(null); } BooleanArrayDifference totalDiff = new BooleanArrayDifference(name); int firstLength = first == null ? 0 : first.Length; int secondLength = second == null ? 0 : second.Length; if (firstLength == secondLength) { for (int i = 0; i < firstLength; i++) { totalDiff.AddChild(BooleanDifference.Construct("" + i, first[i], second[i])); } } else if (firstLength < secondLength) { for (int i = 0; i < firstLength; i++) { totalDiff.AddChild(BooleanDifference.Construct("" + i, first[i], second[i])); } for (int i = firstLength; i < secondLength; i++) { totalDiff.AddChild(BooleanDifference.Construct("" + i, null, second[i])); } } else { // secondLength < firstLength for (int i = 0; i < secondLength; i++) { totalDiff.AddChild(BooleanDifference.Construct("" + i, first[i], second[i])); } for (int i = secondLength; i < firstLength; i++) { totalDiff.AddChild(BooleanDifference.Construct("" + i, first[i], null)); } } if (totalDiff.ChildCount() == 0) { return(null); } return(totalDiff); }
public void TestTwoNull() { IDifference result = BooleanDifference.Construct("Foo", null, null); Assert.IsNull(result); }
public void TestSame() { IDifference result = BooleanDifference.Construct("Foo", false, false); Assert.IsNull(result); }
public void TestDiff() { IDifference result = BooleanDifference.Construct("Foo", true, false); Assert.IsNotNull(result); }