/// <summary> /// Test whether the constraint is satisfied by a given value /// </summary> /// <param name="actual">The value to be tested</param> /// <returns>True for success, false for failure</returns> protected override ConstraintResult ApplyConstraint <TActual>(TActual actual) { if (_from == null || _to == null || actual == null) { throw new ArgumentException("Cannot compare using a null reference", nameof(actual)); } CompareFromAndTo(); bool isInsideRange = _comparer.Compare(_from, actual) <= 0 && _comparer.Compare(_to, actual) >= 0; return(new ConstraintResult(this, actual, isInsideRange)); }
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); }