Exemple #1
0
        private void AssertExpectedIdenticalResult(string input1, string input2, bool expected)
        {
            DiffResult result = GetDiffResult(input1, input2);
            string     msg    = "Identical: comparing " + input1 + " to " + input2 + ": " + result.Difference;

            OldAssert.AreEqual(expected, result.Identical, msg);
        }
Exemple #2
0
        /// <summary>
        /// Asserts that all items contained in collection are of the type specified by expectedType.
        /// </summary>
        /// <param name="collection">ICollection of objects to be considered.</param>
        /// <param name="expectedType">System.Type that all objects in collection must be instances of.</param>
        /// <param name="message">The message that will be displayed on failure.</param>
        /// <param name="args">Arguments to be used in formatting the message.</param>
        public static void AllItemsAreInstancesOfType(ICollection collection, Type expectedType, string message, params object[] args)
        {
            bool fail = false;

            foreach (object o in collection)
            {
                if (o.GetType() != expectedType)
                {
                    fail = true;
                    break;
                }
            }

            if (fail)
            {
                if (args != null)
                {
                    OldAssert.Fail(message, args);
                }
                else
                {
                    OldAssert.Fail(message);
                }
            }
        }
Exemple #3
0
        public void EqualResultForSameReader()
        {
            TextReader reader = new StringReader("<empty/>");
            DiffResult result = PerformDiff(reader, reader);

            OldAssert.AreEqual(true, result.Equal);
        }
Exemple #4
0
        [Test] public void XpathExistsFalseForUnmatchedExpression()
        {
            XPath xpath = new XPath(NONEXISTENT_XPATH);

            OldAssert.AreEqual(false,
                               xpath.XPathExists(SIMPLE_XML));
        }
 public static void IsSealed(Type t)
 {
     OldAssert.IsNotNull(t);
     OldAssert.IsTrue(t.IsSealed,
                      "Type {0} is not sealed",
                      t.FullName);
 }
Exemple #6
0
        /// <summary>
        /// Asserts that all items contained in collection are not equal to null.
        /// </summary>
        /// <param name="collection">ICollection of objects to be considered.</param>
        /// <param name="message">The message that will be displayed on failure.</param>
        /// <param name="args">Arguments to be used in formatting the message.</param>
        public static void AllItemsAreNotNull(ICollection collection, string message, params object[] args)
        {
            bool fail = false;

            foreach (object o in collection)
            {
                if (o == null)
                {
                    fail = true;
                    break;
                }
            }

            if (fail)
            {
                if (args != null)
                {
                    OldAssert.Fail(message, args);
                }
                else
                {
                    OldAssert.Fail(message);
                }
            }
        }
Exemple #7
0
        /// <summary>
        /// Ensures that every object contained in collection exists within the collection
        /// once and only once.
        /// </summary>
        /// <param name="collection">ICollection of objects to be considered.</param>
        /// <param name="message">The message that will be displayed on failure.</param>
        /// <param name="args">Arguments to be used in formatting the message.</param>
        public static void AllItemsAreUnique(ICollection collection, string message, params object[] args)
        {
            bool      fail = false;
            ArrayList arr  = new ArrayList();

            foreach (object o in collection)
            {
                //do a check to see if it is in the collection already
                if (arr.Contains(o))
                {
                    fail = true;
                    break;
                }
                else
                {
                    arr.Add(o);
                }
            }

            if (fail)
            {
                if (args != null)
                {
                    OldAssert.Fail(message, args);
                }
                else
                {
                    OldAssert.Fail(message);
                }
            }
        }
Exemple #8
0
        [Test] public void TextReaderInputTranslatesToXmlReader()
        {
            XmlInput input  = new XmlInput(new StringReader(INPUT));
            string   actual = ReadOuterXml(input.CreateXmlReader());

            OldAssert.AreEqual(_expected, actual);
        }
Exemple #9
0
        [Test] public void XpathExistsTrueForXpathThatExists()
        {
            XPath xpath = new XPath(EXISTENT_XPATH);

            OldAssert.AreEqual(true,
                               xpath.XPathExists(SIMPLE_XML));
        }
Exemple #10
0
        /// <summary>
        /// Asserts that subset is a subset of superset.
        /// </summary>
        /// <param name="subset">The ICollection subset to be considered.</param>
        /// <param name="superset">The ICollection superset to be considered.</param>
        /// <param name="message">The message that will be displayed on failure.</param>
        /// <param name="args">Arguments to be used in formatting the message.</param>
        public static void IsSubsetOf(ICollection subset, ICollection superset, string message, params object[] args)
        {
            bool foundAll = true;

            //All of superset are in subset
            foreach (object o in subset)
            {
                bool found = CheckItemInCollection(superset, o);
                if (!found)
                {
                    foundAll = false;
                    break;
                }
            }

            if (!foundAll)
            {
                if (args != null)
                {
                    OldAssert.Fail(message, args);
                }
                else
                {
                    OldAssert.Fail(message);
                }
            }
        }
Exemple #11
0
        /// <summary>
        /// Asserts that the flattened String obtained by executing an Xpath on some XML is a particular value
        /// </summary>
        /// <param name="anXPathExpression">An X path expression.</param>
        /// <param name="inXml">The XML to test.</param>
        /// <param name="expectedValue">The expected value.</param>
        public static void XPathEvaluatesTo(string anXPathExpression, XmlInput inXml,
                                            string expectedValue)
        {
            XPath xpath = new XPath(anXPathExpression);

            OldAssert.AreEqual(expectedValue, xpath.EvaluateXPath(inXml));
        }
Exemple #12
0
        [SetUp] public void CreateMinorDifference()
        {
            DifferenceType id = DifferenceType.AttributeSequence;

            OldAssert.AreEqual(false, Differences.IsMajorDifference(id));
            minorDifference = new Difference(id);
        }
Exemple #13
0
        [Test] public void XpathEvaluatesToEmptyStringForUnmatchedExpression()
        {
            string expectedValue = "";
            XPath  xpath         = new XPath(NONEXISTENT_XPATH);

            OldAssert.AreEqual(expectedValue,
                               xpath.EvaluateXPath(SIMPLE_XML));
        }
 /// <summary>
 /// Asserts that the type has a constructor, with the specified bindind flags, with a signature defined by parameters.
 /// </summary>
 public static void HasConstructor(Type type, BindingFlags flags, params Type[] parameters)
 {
     OldAssert.IsNotNull(type);
     OldAssert.IsNotNull(type.GetConstructor(flags, null, parameters, null),
                         "{0} does not have matching constructor",
                         type.FullName
                         );
 }
Exemple #15
0
        [Test] public void XpathEvaluatesMultiNodeExpression()
        {
            string expectedValue = "onetwo";
            XPath  xpath         = new XPath(MULTI_NODE_XPATH);

            OldAssert.AreEqual(expectedValue,
                               xpath.EvaluateXPath(MORE_COMPLEX_XML));
        }
Exemple #16
0
        [Test] public void XpathEvaluatesCountExpression()
        {
            string expectedValue = "2";
            XPath  xpath         = new XPath(COUNT_XPATH);

            OldAssert.AreEqual(expectedValue,
                               xpath.EvaluateXPath(MORE_COMPLEX_XML));
        }
Exemple #17
0
 /// <summary>
 /// Verifies that the property value <see cref="ICollection.IsSynchronized"/>
 /// is true.
 /// </summary>
 /// <param name="actual">
 /// Instance containing the expected value.
 /// </param>
 public static void IsSynchronized(
     ICollection actual
     )
 {
     OldAssert.IsNotNull(actual);
     OldAssert.IsTrue(actual.IsSynchronized,
                      "Property IsSynchronized is false");
 }
Exemple #18
0
        public void SameResultForTwoInvocations()
        {
            TextReader reader  = new StringReader("<empty/>");
            DiffResult result1 = PerformDiff(reader, reader);
            DiffResult result2 = _xmlDiff.Compare();

            OldAssert.AreSame(result1, result2);
        }
Exemple #19
0
        [Test] public void XpathEvaluatesToTextValueForSimpleString()
        {
            string expectedValue = "one two";
            XPath  xpath         = new XPath(EXISTENT_XPATH);

            OldAssert.AreEqual(expectedValue,
                               xpath.EvaluateXPath(SIMPLE_XML));
        }
Exemple #20
0
        public static Stream GetTestFile(string file)
        {
            Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream(
                "MbUnit.Tests.Compatibility.Framework.Xml.etc." + file);

            OldAssert.IsNotNull(s);
            return(s);
        }
Exemple #21
0
 /// <summary>
 /// Verifies that the property value <see cref="ICollection.IsSynchronized"/>
 /// of <paramref name="actual"/> is equal to <paramref name="expected"/>.
 /// </summary>
 /// <param name="expected">
 /// Expected value.
 /// </param>
 /// <param name="actual">
 /// Instance containing the tested value.
 /// </param>
 public static void AreIsSynchronizedEqual(
     Boolean expected,
     ICollection actual
     )
 {
     OldAssert.IsNotNull(actual);
     OldAssert.AreEqual(expected, actual.IsSynchronized,
                        "Property IsSynchronized not equal");
 }
 public static void WriteOnlyProperty(PropertyInfo pi)
 {
     OldAssert.IsNotNull(pi);
     OldAssert.IsFalse(pi.CanRead,
                       "Property {0}.{1} is not read-only",
                       pi.DeclaringType.FullName,
                       pi.Name
                       );
 }
Exemple #23
0
 private Validator PerformAssertion(Stream input, bool expected)
 {
     using (input)
     {
         Validator validator = new Validator(new XmlInput(new StreamReader(input)));
         OldAssert.AreEqual(expected, validator.IsValid, validator.ValidationMessage);
         return(validator);
     }
 }
Exemple #24
0
 /// <summary>
 /// Verifies that the property value <see cref="ICollection.Count"/>
 /// of <paramref name="actual"/> is equal to <paramref name="expected"/>.
 /// </summary>
 /// <param name="expected">
 /// Expected value.
 /// </param>
 /// <param name="actual">
 /// Instance containing the tested value.
 /// </param>
 public static void AreCountEqual(
     Int32 expected,
     ICollection actual
     )
 {
     OldAssert.IsNotNull(actual);
     OldAssert.AreEqual(expected, actual.Count,
                        "Property Count not equal");
 }
        public void IsNotAssignableFrom()
        {
            int[] array10 = new int[10];
            int[,] array2 = new int[2, 2];

            OldAssert.IsNotAssignableFrom(array2.GetType(), array10);
            OldAssert.IsNotAssignableFrom(array2.GetType(), array10, "Type Failure Message");
            OldAssert.IsNotAssignableFrom(array2.GetType(), array10, "Type Failure Message", null);
        }
Exemple #26
0
        [Test] public void CanPerformTransform()
        {
            Xslt   xslt   = new Xslt(IDENTITY_TRANSFORM);
            string input  = "<qwerty>uiop</qwerty>";
            string output = new string(input.ToCharArray());

            OldAssert.AreEqual(output, xslt.Transform(input).AsString());
            OldAssert.AreEqual(output, xslt.Transform(input).AsString());
        }
Exemple #27
0
 [Test] public void NotIdenticalButEqualAfterMinorDifferenceFound()
 {
     _result.DifferenceFound(_diff, _minorDifference);
     OldAssert.AreEqual(false, _result.Identical);
     OldAssert.AreEqual(true, _result.Equal);
     OldAssert.AreEqual(_diff.OptionalDescription
                        + Environment.NewLine
                        + _minorDifference.ToString(), _result.StringValue);
 }
 /// <summary>
 /// Asserts whether <paramref name="child"/> is an instance of the
 /// <paramref name="type"/>.
 /// </summary>
 /// <param name="type">
 /// <see cref="Type"/> instance.
 /// </param>
 /// <param name="child">
 /// Child instance.
 /// </param>
 public static void IsInstanceOf(Type type, Object child)
 {
     OldAssert.IsNotNull(type);
     OldAssert.IsNotNull(child);
     OldAssert.IsTrue(type.IsInstanceOfType(child),
                      "{0} is not an instance of {1}",
                      type,
                      child
                      );
 }
 public static void NotCreatable(Type t)
 {
     OldAssert.IsNotNull(t);
     foreach (ConstructorInfo ci in t.GetConstructors())
     {
         OldAssert.Fail(
             "Non-private constructor found in class {0}  that must not be creatable",
             t.FullName);
     }
 }
 /// <summary>
 /// Asserts whether an instance of the <paramref name="parent"/>
 /// can be assigned from an instance of <paramref name="child"/>.
 /// </summary>
 /// <param name="parent">
 /// Parent <see cref="Type"/> instance.
 /// </param>
 /// <param name="child">
 /// Child <see cref="Type"/> instance.
 /// </param>
 public static void IsAssignableFrom(Type parent, Type child)
 {
     OldAssert.IsNotNull(parent);
     OldAssert.IsNotNull(child);
     OldAssert.IsTrue(parent.IsAssignableFrom(child),
                      "{0} is not assignable from {1}",
                      parent,
                      child
                      );
 }