/// <summary> /// Modifies the constraint to use an IComparer<T> and returns self. /// </summary> public RangeConstraint Using <T>(IComparer <T> comparer) { this.comparer = ComparisonAdapter.For(comparer); return(this); }
/// <summary> /// Modifies the constraint to use an IComparer and returns self /// </summary> public ComparisonConstraint Using(IComparer comparer) { this.comparer = ComparisonAdapter.For(comparer); return(this); }
/// <summary> /// Perform the comparison /// </summary> protected override bool PerformComparison(ComparisonAdapter comparer, object actual, object expected, Tolerance tolerance) { return(comparer.Compare(actual, tolerance.ApplyToValue(expected).LowerBound) > 0); }
/// <summary> /// Modifies the constraint to use a Comparison<T> and returns self. /// </summary> public CollectionOrderedConstraint Using <T>(Comparison <T> comparer) { this.comparer = ComparisonAdapter.For(comparer); this.comparerName = comparer.GetType().FullName; return(this); }
/// <summary> /// Protected function overridden by derived class to actually perform the comparison /// </summary> protected abstract bool PerformComparison(ComparisonAdapter comparer, object actual, object expected, Tolerance tolerance);
/// <summary> /// Modifies the constraint to use a <see cref="Comparison{T}"/> and returns self /// </summary> /// <param name="comparer">The comparer used for comparison tests</param> /// <returns>A constraint modified to use the given comparer</returns> public ComparisonConstraint Using <T>(Comparison <T> comparer) { this._comparer = ComparisonAdapter.For(comparer); return(this); }
public static void CanCompareWithNull(ComparisonAdapter adapter) { Assert.That(adapter.Compare(null, "a"), Is.LessThan(0)); Assert.That(adapter.Compare("a", null), Is.GreaterThan(0)); Assert.That(adapter.Compare(null, null), Is.Zero); }
/// <summary> /// Returns an EqualityAdapter that wraps a Comparison<T>. /// </summary> public static EqualityAdapter For <T>(Comparison <T> comparer) { return(new ComparisonAdapterAdapter(ComparisonAdapter.For(comparer))); }
public ComparisonAdapterAdapter(ComparisonAdapter comparer) { this.comparer = comparer; }