Esempio n. 1
0
 /// <summary>
 /// Constructs a constraint with the specified expected value and node filter.
 /// </summary>
 /// <param name="expected">the expected value</param>
 /// <param name="nodeFilter">the filter to use, or null if no filter should be used</param>
 public ObjectTreeEqualConstraint(object expected, IObjectTreeNodeFilter nodeFilter)
 {
     this.expected     = expected;
     this.nodeFilter   = nodeFilter;
     this.expectedTree = ObjectTree.Create(expected, nodeFilter);
     this.DisplayName  = "equal";
 }
        private void AssertAreNotEqual(object expected, object actual, IObjectTreeNodeFilter nodeFilter)
        {
            ObjectTreeAssert.AreNotEqual(expected, actual, nodeFilter);
            Assert.That(actual, IsObjectTree.NotEqualTo(expected).WithFilter(nodeFilter));
            Assert.That(actual, Is.Not.ObjectTreeEqualTo(expected).WithFilter(nodeFilter));

            Assert.Throws <AssertionException>(() => ObjectTreeAssert.AreEqual(expected, actual, nodeFilter));
            Assert.Throws <AssertionException>(() => Assert.That(actual, IsObjectTree.EqualTo(expected).WithFilter(nodeFilter)));
        }
Esempio n. 3
0
 /// <summary>
 /// Adds the specified node filter to this constraint.
 /// </summary>
 /// <param name="nodeFilter">the filter to use, or null if no filter should be used</param>
 /// <returns>self</returns>
 public ObjectTreeEqualConstraint WithFilter(IObjectTreeNodeFilter nodeFilter)
 {
     if (nodeFilter == null)
     {
         throw new ArgumentNullException(nameof(nodeFilter));
     }
     this.nodeFilter   = nodeFilter;
     this.expectedTree = ObjectTree.Create(expected, nodeFilter);
     return(this);
 }
 /// <summary>
 /// Verifies that two objects are equal based on their filtered object trees.
 /// If they are not, an <see cref="AssertionException"/> is thrown.
 /// </summary>
 /// <param name="expected">the expected object</param>
 /// <param name="actual">the actual object</param>
 /// <param name="nodeFilter">a filter on the nodes of the object trees to include in the comparison</param>
 /// <param name="message">the message to display in case of failure</param>
 /// <param name="args">objects to be used in formatting the message</param>
 public static void AreEqual(object expected, object actual, IObjectTreeNodeFilter nodeFilter, string message, params object[] args)
 {
     Assert.That(actual, new ObjectTreeEqualConstraint(expected, nodeFilter), message, args);
 }
 /// <summary>
 /// Verifies that two objects are equal based on their filtered object trees.
 /// If they are not, an <see cref="AssertionException"/> is thrown.
 /// </summary>
 /// <param name="expected">the expected object</param>
 /// <param name="actual">the actual object</param>
 /// <param name="nodeFilter">a filter on the nodes of the object trees to include in the comparison</param>
 /// <param name="message">the message to display in case of failure</param>
 public static void AreEqual(object expected, object actual, IObjectTreeNodeFilter nodeFilter, string message)
 {
     AreEqual(expected, actual, nodeFilter, message, args: default(object[]));
 }