1
// ****************************************************************
2
// Copyright 2011, Charlie Poole
3
// This is free software licensed under the NUnit license. You may
4
// obtain a copy of the license at http://nunit.org
5
// ****************************************************************
9
namespace NUnit.Framework.Constraints
12
/// Tests whether a value is greater than the value supplied to its constructor
14
public class GreaterThanConstraint : ComparisonConstraint
17
/// The value against which a comparison is to be made
19
private object expected;
22
/// Initializes a new instance of the <see cref="T:GreaterThanConstraint"/> class.
24
/// <param name="expected">The expected value.</param>
25
public GreaterThanConstraint(object expected) : base(expected)
27
this.expected = expected;
31
/// Write the constraint description to a MessageWriter
33
/// <param name="writer">The writer on which the description is displayed</param>
34
public override void WriteDescriptionTo(MessageWriter writer)
36
writer.WritePredicate("greater than");
37
writer.WriteExpectedValue(expected);
41
/// Test whether the constraint is satisfied by a given value
43
/// <param name="actual">The value to be tested</param>
44
/// <returns>True for success, false for failure</returns>
45
public override bool Matches(object actual)
49
if (expected == null || actual == null)
50
throw new ArgumentException("Cannot compare using a null reference");
52
return comparer.Compare(actual, expected) > 0;
1
// ****************************************************************
2
// Copyright 2011, Charlie Poole
3
// This is free software licensed under the NUnit license. You may
4
// obtain a copy of the license at http://nunit.org
5
// ****************************************************************
9
namespace NUnit.Framework.Constraints
12
/// Tests whether a value is greater than the value supplied to its constructor
14
public class GreaterThanConstraint : ComparisonConstraint
17
/// The value against which a comparison is to be made
19
private object expected;
22
/// Initializes a new instance of the <see cref="T:GreaterThanConstraint"/> class.
24
/// <param name="expected">The expected value.</param>
25
public GreaterThanConstraint(object expected) : base(expected)
27
this.expected = expected;
31
/// Write the constraint description to a MessageWriter
33
/// <param name="writer">The writer on which the description is displayed</param>
34
public override void WriteDescriptionTo(MessageWriter writer)
36
writer.WritePredicate("greater than");
37
writer.WriteExpectedValue(expected);
41
/// Test whether the constraint is satisfied by a given value
43
/// <param name="actual">The value to be tested</param>
44
/// <returns>True for success, false for failure</returns>
45
public override bool Matches(object actual)
49
if (expected == null || actual == null)
50
throw new ArgumentException("Cannot compare using a null reference");
52
return comparer.Compare(actual, expected) > 0;