예제 #1
0
 /// <summary>
 /// Modifies the constraint to use an IComparer&lt;T&gt; and returns self.
 /// </summary>
 public RangeConstraint Using <T>(IComparer <T> comparer)
 {
     this.comparer = ComparisonAdapter.For(comparer);
     return(this);
 }
예제 #2
0
 /// <summary>
 /// Modifies the constraint to use an IComparer and returns self
 /// </summary>
 public ComparisonConstraint Using(IComparer comparer)
 {
     this.comparer = ComparisonAdapter.For(comparer);
     return(this);
 }
예제 #3
0
 /// <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);
 }
예제 #4
0
 /// <summary>
 /// Modifies the constraint to use a Comparison&lt;T&gt; 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);
 }
예제 #8
0
 /// <summary>
 /// Returns an EqualityAdapter that wraps a Comparison&lt;T&gt;.
 /// </summary>
 public static EqualityAdapter For <T>(Comparison <T> comparer)
 {
     return(new ComparisonAdapterAdapter(ComparisonAdapter.For(comparer)));
 }
예제 #9
0
 public ComparisonAdapterAdapter(ComparisonAdapter comparer)
 {
     this.comparer = comparer;
 }