Пример #1
0
        internal bool ObjectsEqual <TExpected, TActual>(TExpected expected, TActual actual, ref Tolerance tolerance)
        {
            FailurePoints = new FailurePointList();

            if (expected == null && actual == null)
            {
                return(true);
            }

            if (expected == null || actual == null)
            {
                return(false);
            }

            if (object.ReferenceEquals(expected, actual))
            {
                return(true);
            }

            EqualityAdapter externalComparer = GetExternalComparer(expected, actual);

            if (externalComparer != null)
            {
                return(externalComparer.AreEqual(expected, actual));
            }

            ITCLiteEqualityComparer comparer = GetEqualityComparer(expected, actual);

            if (comparer != null)
            {
                return(comparer.AreEqual(expected, actual, ref tolerance));
            }

            return(expected.Equals(actual));
        }
Пример #2
0
 /// <summary>
 /// Flag the constraint to use the supplied predicate function
 /// </summary>
 /// <param name="comparison">The comparison function to use.</param>
 /// <returns>Self.</returns>
 public CollectionEquivalentConstraint Using <TActual, TExpected>(Func <TActual, TExpected, bool> comparison)
 {
     base.Using(EqualityAdapter.For(comparison));
     return(this);
 }
Пример #3
0
 /// <summary>
 /// Flag the constraint to use the supplied IEqualityComparer object.
 /// </summary>
 /// <param name="comparer">The IComparer object to use.</param>
 /// <returns>Self.</returns>
 public EqualConstraint <TExpected> Using <T>(IEqualityComparer <T> comparer)
 {
     _comparer.ExternalComparers.Add(EqualityAdapter.For(comparer));
     return(this);
 }
Пример #4
0
 /// <summary>
 /// Flag the constraint to use the supplied Comparison object.
 /// </summary>
 /// <param name="comparer">The IComparer object to use.</param>
 /// <returns>Self.</returns>
 public CollectionItemsEqualConstraint Using <T>(Comparison <T> comparer)
 {
     return(Using(EqualityAdapter.For(comparer)));
 }
Пример #5
0
 /// <summary>
 /// Flag the constraint to use the supplied EqualityAdapter.
 /// NOTE: For internal use only.
 /// </summary>
 /// <param name="adapter">The EqualityAdapter to use.</param>
 /// <returns>Self.</returns>
 internal CollectionItemsEqualConstraint Using(EqualityAdapter adapter)
 {
     _comparer.ExternalComparers.Add(adapter);
     return(this);
 }
Пример #6
0
 /// <summary>
 /// Flag the constraint to use the supplied IEqualityComparer object.
 /// </summary>
 /// <param name="comparer">The IComparer object to use.</param>
 /// <returns>Self.</returns>
 public CollectionItemsEqualConstraint Using(IEqualityComparer comparer)
 {
     return(Using(EqualityAdapter.For(comparer)));
 }