Esempio n. 1
0
        public void TestToString()
        {
            IDifference result     = BooleanArrayDifference.Construct("Foo", new bool[] { true }, new bool[] { false });
            string      diffString = result.ToString();

            Assert.IsNotNull(diffString);
            AssertOneLiner(diffString);
        }
Esempio n. 2
0
        public void TestOneNull()
        {
            IDifference result = BooleanArrayDifference.Construct("Foo", null, new bool[] { false, false });

            Assert.IsNotNull(result);

            result = BooleanArrayDifference.Construct("Foo", new bool[] { false, false }, null);
            Assert.IsNotNull(result);
        }
Esempio n. 3
0
        /// <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);
        }
Esempio n. 4
0
        public void TestTwoNull()
        {
            IDifference result = BooleanArrayDifference.Construct("Foo", null, null);

            Assert.IsNull(result);
        }