nunit-core team mailing list archive
-
nunit-core team
-
Mailing list archive
-
Message #01721
[Merge] lp:~saidout/nunit-3.0/constraint-class into lp:nunit-3.0
Said Outgajjouft has proposed merging lp:~saidout/nunit-3.0/constraint-class into lp:nunit-3.0.
Requested reviews:
NUnit Core Developers (nunit-core)
For more details, see:
https://code.launchpad.net/~saidout/nunit-3.0/constraint-class/+merge/60713
constraint-class refactoring.
--
The attached diff has been truncated due to its size.
https://code.launchpad.net/~saidout/nunit-3.0/constraint-class/+merge/60713
Your team NUnit Core Developers is requested to review the proposed merge of lp:~saidout/nunit-3.0/constraint-class into lp:nunit-3.0.
=== modified file 'solutions/vs2008/nunit.framework/nunit.framework.csproj'
--- solutions/vs2008/nunit.framework/nunit.framework.csproj 2011-03-31 17:46:09 +0000
+++ solutions/vs2008/nunit.framework/nunit.framework.csproj 2011-05-12 00:38:23 +0000
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
=== modified file 'solutions/vs2008/nunitlite/nunitlite.csproj'
--- solutions/vs2008/nunitlite/nunitlite.csproj 2011-03-31 17:46:09 +0000
+++ solutions/vs2008/nunitlite/nunitlite.csproj 2011-05-12 00:38:23 +0000
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
=== modified file 'solutions/vs2010/nunit.framework.tests/nunit.framework.tests.csproj'
--- solutions/vs2010/nunit.framework.tests/nunit.framework.tests.csproj 2011-03-31 17:46:09 +0000
+++ solutions/vs2010/nunit.framework.tests/nunit.framework.tests.csproj 2011-05-12 00:38:23 +0000
@@ -209,27 +209,57 @@
<Compile Include="..\..\..\src\tests\Constraints\ComparerTests.cs">
<Link>Constraints\ComparerTests.cs</Link>
</Compile>
- <Compile Include="..\..\..\src\tests\Constraints\ComparisonConstraintTests.cs">
- <Link>Constraints\ComparisonConstraintTests.cs</Link>
+ <Compile Include="..\..\..\src\tests\Constraints\ComparisonConstraintTestsBase.cs">
+ <Link>Constraints\ComparisonConstraintTestsBase.cs</Link>
+ </Compile>
+ <Compile Include="..\..\..\src\tests\Constraints\ConstraintResultTests.cs">
+ <Link>Constraints\ConstraintResultTests.cs</Link>
</Compile>
<Compile Include="..\..\..\src\tests\Constraints\ConstraintTestBase.cs">
<Link>Constraints\ConstraintTestBase.cs</Link>
</Compile>
+ <Compile Include="..\..\..\src\tests\Constraints\ConstraintTests.cs">
+ <Link>Constraints\ConstraintTests.cs</Link>
+ </Compile>
+ <Compile Include="..\..\..\src\tests\Constraints\ConstraintTestsBase.cs">
+ <Link>Constraints\ConstraintTestsBase.cs</Link>
+ </Compile>
<Compile Include="..\..\..\src\tests\Constraints\EmptyConstraintTest.cs">
<Link>Constraints\EmptyConstraintTest.cs</Link>
</Compile>
<Compile Include="..\..\..\src\tests\Constraints\EqualTest.cs">
<Link>Constraints\EqualTest.cs</Link>
</Compile>
+ <Compile Include="..\..\..\src\tests\Constraints\FalseConstraintTests.cs">
+ <Link>Constraints\FalseConstraintTests.cs</Link>
+ </Compile>
<Compile Include="..\..\..\src\tests\Constraints\FloatingPointNumericsTest.cs">
<Link>Constraints\FloatingPointNumericsTest.cs</Link>
</Compile>
+ <Compile Include="..\..\..\src\tests\Constraints\GreaterThanConstraintTests.cs">
+ <Link>Constraints\GreaterThanConstraintTests.cs</Link>
+ </Compile>
+ <Compile Include="..\..\..\src\tests\Constraints\GreaterThanOrEqualConstraintTests.cs">
+ <Link>Constraints\GreaterThanOrEqualConstraintTests.cs</Link>
+ </Compile>
+ <Compile Include="..\..\..\src\tests\Constraints\LessThanConstraintTests.cs">
+ <Link>Constraints\LessThanConstraintTests.cs</Link>
+ </Compile>
+ <Compile Include="..\..\..\src\tests\Constraints\LessThanOrEqualConstraintTests.cs">
+ <Link>Constraints\LessThanOrEqualConstraintTests.cs</Link>
+ </Compile>
<Compile Include="..\..\..\src\tests\Constraints\MsgUtilTests.cs">
<Link>Constraints\MsgUtilTests.cs</Link>
</Compile>
+ <Compile Include="..\..\..\src\tests\Constraints\NaNConstraintTests.cs">
+ <Link>Constraints\NaNConstraintTests.cs</Link>
+ </Compile>
<Compile Include="..\..\..\src\tests\Constraints\NotTest.cs">
<Link>Constraints\NotTest.cs</Link>
</Compile>
+ <Compile Include="..\..\..\src\tests\Constraints\NullConstraintTests.cs">
+ <Link>Constraints\NullConstraintTests.cs</Link>
+ </Compile>
<Compile Include="..\..\..\src\tests\Constraints\NumericsTest.cs">
<Link>Constraints\NumericsTest.cs</Link>
</Compile>
@@ -242,6 +272,9 @@
<Compile Include="..\..\..\src\tests\Constraints\PropertyTests.cs">
<Link>Constraints\PropertyTests.cs</Link>
</Compile>
+ <Compile Include="..\..\..\src\tests\Constraints\RangeConstraintTests.cs">
+ <Link>Constraints\RangeConstraintTests.cs</Link>
+ </Compile>
<Compile Include="..\..\..\src\tests\Constraints\ReusableConstraintTests.cs">
<Link>Constraints\ReusableConstraintTests.cs</Link>
</Compile>
@@ -257,6 +290,9 @@
<Compile Include="..\..\..\src\tests\Constraints\ToStringTests.cs">
<Link>Constraints\ToStringTests.cs</Link>
</Compile>
+ <Compile Include="..\..\..\src\tests\Constraints\TrueConstraintTests.cs">
+ <Link>Constraints\TrueConstraintTests.cs</Link>
+ </Compile>
<Compile Include="..\..\..\src\tests\Constraints\TypeConstraintTests.cs">
<Link>Constraints\TypeConstraintTests.cs</Link>
</Compile>
=== modified file 'solutions/vs2010/nunit.framework/nunit.framework.csproj'
--- solutions/vs2010/nunit.framework/nunit.framework.csproj 2011-03-31 17:46:09 +0000
+++ solutions/vs2010/nunit.framework/nunit.framework.csproj 2011-05-12 00:38:23 +0000
@@ -267,9 +267,6 @@
<Compile Include="..\..\..\src\framework\Constraints\AttributeOperator.cs">
<Link>Constraints\OF-ConstraintOperators\AttributeOperator.cs</Link>
</Compile>
- <Compile Include="..\..\..\src\framework\Constraints\BasicConstraint.cs">
- <Link>Constraints\OF-BasicConstraints\BasicConstraint.cs</Link>
- </Compile>
<Compile Include="..\..\..\src\framework\Constraints\BinaryConstraint.cs">
<Link>Constraints\OF-BinaryOperations\BinaryConstraint.cs</Link>
</Compile>
@@ -327,6 +324,9 @@
<Compile Include="..\..\..\src\framework\Constraints\ConstraintOperator.cs">
<Link>Constraints\OF-ConstraintOperators\ConstraintOperator.cs</Link>
</Compile>
+ <Compile Include="..\..\..\src\framework\Constraints\ConstraintResult.cs">
+ <Link>Constraints\ConstraintResult.cs</Link>
+ </Compile>
<Compile Include="..\..\..\src\framework\Constraints\ContainsConstraint.cs">
<Link>Constraints\ContainsConstraint.cs</Link>
</Compile>
@@ -753,6 +753,9 @@
<Compile Include="..\..\..\src\framework\Internal\NamespaceTreeBuilder.cs">
<Link>Internal\NamespaceTreeBuilder.cs</Link>
</Compile>
+ <Compile Include="..\..\..\src\framework\Internal\NumericComparison.cs">
+ <Link>Internal\NumericComparison.cs</Link>
+ </Compile>
<Compile Include="..\..\..\src\framework\Internal\NUnitException.cs">
<Link>Internal\NUnitException.cs</Link>
</Compile>
@@ -780,6 +783,9 @@
<Compile Include="..\..\..\src\framework\Internal\RuntimeFramework.cs">
<Link>Internal\RuntimeFramework.cs</Link>
</Compile>
+ <Compile Include="..\..\..\src\framework\Internal\StringConverterHelper.cs">
+ <Link>Internal\StringConverterHelper.cs</Link>
+ </Compile>
<Compile Include="..\..\..\src\framework\Internal\TestExecutionContext.cs" />
<Compile Include="..\..\..\src\framework\Internal\TestFixtureBuilder.cs">
<Link>Internal\TestFixtureBuilder.cs</Link>
=== modified file 'solutions/vs2010/nunitlite.tests/nunitlite.tests.csproj'
--- solutions/vs2010/nunitlite.tests/nunitlite.tests.csproj 2011-03-31 17:46:09 +0000
+++ solutions/vs2010/nunitlite.tests/nunitlite.tests.csproj 2011-05-12 00:38:23 +0000
@@ -101,27 +101,57 @@
<Compile Include="..\..\..\src\tests\Constraints\ComparerTests.cs">
<Link>Constraints\ComparerTests.cs</Link>
</Compile>
- <Compile Include="..\..\..\src\tests\Constraints\ComparisonConstraintTests.cs">
- <Link>Constraints\ComparisonConstraintTests.cs</Link>
+ <Compile Include="..\..\..\src\tests\Constraints\ComparisonConstraintTestsBase.cs">
+ <Link>Constraints\ComparisonConstraintTestsBase.cs</Link>
+ </Compile>
+ <Compile Include="..\..\..\src\tests\Constraints\ConstraintResultTests.cs">
+ <Link>Constraints\ConstraintResultTests.cs</Link>
</Compile>
<Compile Include="..\..\..\src\tests\Constraints\ConstraintTestBase.cs">
<Link>Constraints\ConstraintTestBase.cs</Link>
</Compile>
+ <Compile Include="..\..\..\src\tests\Constraints\ConstraintTests.cs">
+ <Link>Constraints\ConstraintTests.cs</Link>
+ </Compile>
+ <Compile Include="..\..\..\src\tests\Constraints\ConstraintTestsBase.cs">
+ <Link>Constraints\ConstraintTestsBase.cs</Link>
+ </Compile>
<Compile Include="..\..\..\src\tests\Constraints\EmptyConstraintTest.cs">
<Link>Constraints\EmptyConstraintTest.cs</Link>
</Compile>
<Compile Include="..\..\..\src\tests\Constraints\EqualTest.cs">
<Link>Constraints\EqualTest.cs</Link>
</Compile>
+ <Compile Include="..\..\..\src\tests\Constraints\FalseConstraintTests.cs">
+ <Link>Constraints\FalseConstraintTests.cs</Link>
+ </Compile>
<Compile Include="..\..\..\src\tests\Constraints\FloatingPointNumericsTest.cs">
<Link>Constraints\FloatingPointNumericsTest.cs</Link>
</Compile>
+ <Compile Include="..\..\..\src\tests\Constraints\GreaterThanConstraintTests.cs">
+ <Link>Constraints\GreaterThanConstraintTests.cs</Link>
+ </Compile>
+ <Compile Include="..\..\..\src\tests\Constraints\GreaterThanOrEqualConstraintTests.cs">
+ <Link>Constraints\GreaterThanOrEqualConstraintTests.cs</Link>
+ </Compile>
+ <Compile Include="..\..\..\src\tests\Constraints\LessThanConstraintTests.cs">
+ <Link>Constraints\LessThanConstraintTests.cs</Link>
+ </Compile>
+ <Compile Include="..\..\..\src\tests\Constraints\LessThanOrEqualConstraintTests.cs">
+ <Link>Constraints\LessThanOrEqualConstraintTests.cs</Link>
+ </Compile>
<Compile Include="..\..\..\src\tests\Constraints\MsgUtilTests.cs">
<Link>Constraints\MsgUtilTests.cs</Link>
</Compile>
+ <Compile Include="..\..\..\src\tests\Constraints\NaNConstraintTests.cs">
+ <Link>Constraints\NaNConstraintTests.cs</Link>
+ </Compile>
<Compile Include="..\..\..\src\tests\Constraints\NotTest.cs">
<Link>Constraints\NotTest.cs</Link>
</Compile>
+ <Compile Include="..\..\..\src\tests\Constraints\NullConstraintTests.cs">
+ <Link>Constraints\NullConstraintTests.cs</Link>
+ </Compile>
<Compile Include="..\..\..\src\tests\Constraints\NumericsTest.cs">
<Link>Constraints\NumericsTest.cs</Link>
</Compile>
@@ -134,6 +164,9 @@
<Compile Include="..\..\..\src\tests\Constraints\PropertyTests.cs">
<Link>Constraints\PropertyTests.cs</Link>
</Compile>
+ <Compile Include="..\..\..\src\tests\Constraints\RangeConstraintTests.cs">
+ <Link>Constraints\RangeConstraintTests.cs</Link>
+ </Compile>
<Compile Include="..\..\..\src\tests\Constraints\SameAsTest.cs">
<Link>Constraints\SameAsTest.cs</Link>
</Compile>
@@ -146,6 +179,9 @@
<Compile Include="..\..\..\src\tests\Constraints\ToStringTests.cs">
<Link>Constraints\ToStringTests.cs</Link>
</Compile>
+ <Compile Include="..\..\..\src\tests\Constraints\TrueConstraintTests.cs">
+ <Link>Constraints\TrueConstraintTests.cs</Link>
+ </Compile>
<Compile Include="..\..\..\src\tests\Constraints\TypeConstraintTests.cs">
<Link>Constraints\TypeConstraintTests.cs</Link>
</Compile>
=== modified file 'solutions/vs2010/nunitlite/nunitlite.csproj'
--- solutions/vs2010/nunitlite/nunitlite.csproj 2011-03-31 17:46:09 +0000
+++ solutions/vs2010/nunitlite/nunitlite.csproj 2011-05-12 00:38:23 +0000
@@ -167,9 +167,6 @@
<Compile Include="..\..\..\src\framework\Constraints\AttributeOperator.cs">
<Link>Constraints\OF-ConstraintOperators\AttributeOperator.cs</Link>
</Compile>
- <Compile Include="..\..\..\src\framework\Constraints\BasicConstraint.cs">
- <Link>Constraints\OF-BasicConstraints\BasicConstraint.cs</Link>
- </Compile>
<Compile Include="..\..\..\src\framework\Constraints\BinaryConstraint.cs">
<Link>Constraints\OF-BinaryOperations\BinaryConstraint.cs</Link>
</Compile>
@@ -227,6 +224,9 @@
<Compile Include="..\..\..\src\framework\Constraints\ConstraintOperator.cs">
<Link>Constraints\OF-ConstraintOperators\ConstraintOperator.cs</Link>
</Compile>
+ <Compile Include="..\..\..\src\framework\Constraints\ConstraintResult.cs">
+ <Link>Constraints\ConstraintResult.cs</Link>
+ </Compile>
<Compile Include="..\..\..\src\framework\Constraints\ContainsConstraint.cs">
<Link>Constraints\ContainsConstraint.cs</Link>
</Compile>
@@ -510,6 +510,9 @@
<Link>Internal\MethodHelper.cs</Link>
<SubType>Code</SubType>
</Compile>
+ <Compile Include="..\..\..\src\framework\Internal\NumericComparison.cs">
+ <Link>Internal\NumericComparison.cs</Link>
+ </Compile>
<Compile Include="..\..\..\src\framework\Internal\NUnitException.cs">
<Link>Internal\NUnitException.cs</Link>
<SubType>Code</SubType>
@@ -524,6 +527,9 @@
<Link>Internal\Reflect.cs</Link>
<SubType>Code</SubType>
</Compile>
+ <Compile Include="..\..\..\src\framework\Internal\StringConverterHelper.cs">
+ <Link>Internal\StringConverterHelper.cs</Link>
+ </Compile>
<Compile Include="..\..\..\src\framework\Internal\TestExecutionContext.cs">
<Link>Internal\TestExecutionContext.cs</Link>
</Compile>
@@ -650,6 +656,7 @@
<None Include="nunit.snk" />
</ItemGroup>
<ItemGroup>
+ <Folder Include="Helpers\" />
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
=== modified file 'src/direct-runner/TestEventListener.cs'
--- src/direct-runner/TestEventListener.cs 2010-01-20 01:31:10 +0000
+++ src/direct-runner/TestEventListener.cs 2011-05-12 00:38:23 +0000
@@ -23,9 +23,9 @@
using System;
using System.IO;
-using NUnit.Framework.Api;
-
-namespace NUnit.AdhocTestRunner
+using NUnit.Framework.Api;
+
+namespace NUnit.DirectRunner
{
class TestEventListener : MarshalByRefObject, ITestListener
{
=== modified file 'src/framework/Api/ResultState.cs'
--- src/framework/Api/ResultState.cs 2011-04-21 02:09:29 +0000
+++ src/framework/Api/ResultState.cs 2011-05-12 00:38:23 +0000
@@ -1,139 +1,141 @@
-// ***********************************************************************
-// Copyright (c) 2007 Charlie Poole
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-// ***********************************************************************
-
-namespace NUnit.Framework.Api
-{
- /// <summary>
- /// The ResultState class represents the outcome of running a test.
- /// It contains two pieces of information. The Status of the test
- /// is an enum indicating whether the test passed, failed, was
- /// skipped or was inconclusive. The Label provides a more
- /// detailed breakdown for use by client runners.
- /// </summary>
- public class ResultState
- {
- private readonly TestStatus status;
- private readonly string label;
-
- #region Constructors
-
- /// <summary>
- /// Initializes a new instance of the <see cref="ResultState"/> class.
- /// </summary>
- /// <param name="status">The TestStatus.</param>
- public ResultState(TestStatus status) : this (status, string.Empty)
- {
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="ResultState"/> class.
- /// </summary>
- /// <param name="status">The TestStatus.</param>
- /// <param name="label">The label.</param>
- public ResultState(TestStatus status, string label)
- {
- this.status = status;
- this.label = label == null ? string.Empty : label;
- }
-
- #endregion
-
- #region Predefined ResultStates
-
- /// <summary>
- /// The result is inconclusive
- /// </summary>
- public readonly static ResultState Inconclusive = new ResultState(TestStatus.Inconclusive);
-
- /// <summary>
- /// The test was not runnable.
- /// </summary>
- public readonly static ResultState NotRunnable = new ResultState(TestStatus.Skipped, "Invalid");
-
- /// <summary>
- /// The test has been skipped.
- /// </summary>
- public readonly static ResultState Skipped = new ResultState(TestStatus.Skipped);
-
- /// <summary>
- /// The test has been ignored.
- /// </summary>
- public readonly static ResultState Ignored = new ResultState(TestStatus.Skipped, "Ignored");
-
- /// <summary>
- /// The test succeeded
- /// </summary>
- public readonly static ResultState Success = new ResultState(TestStatus.Passed);
-
- /// <summary>
- /// The test failed
- /// </summary>
- public readonly static ResultState Failure = new ResultState(TestStatus.Failed);
-
- /// <summary>
- /// The test encountered an unexpected exception
- /// </summary>
- public readonly static ResultState Error = new ResultState(TestStatus.Failed, "Error");
-
- /// <summary>
- /// The test was cancelled by the user
- /// </summary>
- public readonly static ResultState Cancelled = new ResultState(TestStatus.Failed, "Cancelled");
-
- #endregion
-
- #region Properties
-
- /// <summary>
- /// Gets the TestStatus for the test.
- /// </summary>
- /// <value>The status.</value>
- public TestStatus Status
- {
- get { return status; }
- }
-
- /// <summary>
- /// Gets the label under which this test resullt is
- /// categorized, if any.
- /// </summary>
- public string Label
- {
- get { return label; }
- }
-
- #endregion
-
- /// <summary>
- /// Returns a <see cref="System.String"/> that represents this instance.
- /// </summary>
- /// <returns>
- /// A <see cref="System.String"/> that represents this instance.
- /// </returns>
- public override string ToString()
- {
- string s = status.ToString();
- return label == null || label.Length == 0 ? s : string.Format("{0}:{1}", s, label);
- }
- }
-}
+// ***********************************************************************
+// Copyright (c) 2007 Charlie Poole
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// ***********************************************************************
+
+namespace NUnit.Framework.Api
+{
+ /// <summary>
+ /// The ResultState class represents the outcome of running a test.
+ /// It contains two pieces of information. The Status of the test
+ /// is an enum indicating whether the test passed, failed, was
+ /// skipped or was inconclusive. The Label provides a more
+ /// detailed breakdown for use by client runners.
+ /// </summary>
+ public class ResultState
+ {
+ private readonly TestStatus status;
+ private readonly string label;
+
+ #region Constructors
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ResultState"/> class.
+ /// </summary>
+ /// <param name="status">The TestStatus.</param>
+ public ResultState(TestStatus status)
+ : this(status, string.Empty)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ResultState"/> class.
+ /// </summary>
+ /// <param name="status">The TestStatus.</param>
+ /// <param name="label">The label.</param>
+ public ResultState(TestStatus status, string label)
+ {
+ this.status = status;
+ this.label = label == null ? string.Empty : label;
+ }
+
+ #endregion
+
+ #region Predefined ResultStates
+
+ /// <summary>
+ /// The result is inconclusive
+ /// </summary>
+ public readonly static ResultState Inconclusive = new ResultState(TestStatus.Inconclusive);
+
+ /// <summary>
+ /// The test was not runnable.
+ /// </summary>
+ public readonly static ResultState NotRunnable = new ResultState(TestStatus.Skipped, "Invalid");
+
+ /// <summary>
+ /// The test has been skipped.
+ /// </summary>
+ public readonly static ResultState Skipped = new ResultState(TestStatus.Skipped);
+
+ /// <summary>
+ /// The test has been ignored.
+ /// </summary>
+ public readonly static ResultState Ignored = new ResultState(TestStatus.Skipped, "Ignored");
+
+ /// <summary>
+ /// The test succeeded
+ /// </summary>
+ public readonly static ResultState Success = new ResultState(TestStatus.Passed);
+
+ /// <summary>
+ /// The test failed
+ /// </summary>
+ public readonly static ResultState Failure = new ResultState(TestStatus.Failed);
+
+ /// <summary>
+ /// The test encountered an unexpected exception
+ /// </summary>
+ public readonly static ResultState Error = new ResultState(TestStatus.Failed, "Error");
+
+ /// <summary>
+ /// The test was cancelled by the user
+ /// </summary>
+ public readonly static ResultState Cancelled = new ResultState(TestStatus.Failed, "Cancelled");
+
+ #endregion
+
+ #region Properties
+
+ /// <summary>
+ /// Gets the TestStatus for the test.
+ /// </summary>
+ /// <value>The status.</value>
+ public TestStatus Status
+ {
+ get { return status; }
+ }
+
+ /// <summary>
+ /// Gets the label under which this test resullt is
+ /// categorized, if any.
+ /// </summary>
+ public string Label
+ {
+ get { return label; }
+ }
+
+ #endregion
+
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this instance.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public override string ToString()
+ {
+ string s = status.ToString();
+ return label == null || label.Length == 0 ? s : string.Format("{0}:{1}", s, label);
+ }
+ }
+}
=== modified file 'src/framework/Assert.cs'
--- src/framework/Assert.cs 2011-04-22 01:50:59 +0000
+++ src/framework/Assert.cs 2011-05-12 00:38:23 +0000
@@ -1,3803 +1,3675 @@
-// ***********************************************************************
-// Copyright (c) 2011 Charlie Poole
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-// ***********************************************************************
-
-using System;
-using System.Collections;
-using System.ComponentModel;
-using NUnit.Framework.Constraints;
-using NUnit.Framework.Internal;
-
-namespace NUnit.Framework
-{
- /// <summary>
- /// Delegate used by tests that execute code and
- /// capture any thrown exception.
- /// </summary>
- public delegate void TestDelegate();
-
- /// <summary>
- /// The Assert class contains a collection of static methods that
- /// implement the most common assertions used in NUnit.
- /// </summary>
- public class Assert
- {
- #region Constructor
-
- /// <summary>
- /// We don't actually want any instances of this object, but some people
- /// like to inherit from it to add other static methods. Hence, the
- /// protected constructor disallows any instances of this object.
- /// </summary>
- protected Assert() { }
-
- #endregion
-
- #region Equals and ReferenceEquals
-
-#if !NETCF
- /// <summary>
- /// The Equals method throws an AssertionException. This is done
- /// to make sure there is no mistake by calling this function.
- /// </summary>
- /// <param name="a"></param>
- /// <param name="b"></param>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static new bool Equals(object a, object b)
- {
- throw new InvalidOperationException("Assert.Equals should not be used for Assertions");
- }
-
- /// <summary>
- /// override the default ReferenceEquals to throw an AssertionException. This
- /// implementation makes sure there is no mistake in calling this function
- /// as part of Assert.
- /// </summary>
- /// <param name="a"></param>
- /// <param name="b"></param>
- public static new void ReferenceEquals(object a, object b)
- {
- throw new InvalidOperationException("Assert.ReferenceEquals should not be used for Assertions");
- }
-#endif
-
- #endregion
-
- #region Utility Asserts
-
- #region Pass
-
- /// <summary>
- /// Throws a <see cref="SuccessException"/> with the message and arguments
- /// that are passed in. This allows a test to be cut short, with a result
- /// of success returned to NUnit.
- /// </summary>
- /// <param name="message">The message to initialize the <see cref="AssertionException"/> with.</param>
- /// <param name="args">Arguments to be used in formatting the message</param>
- static public void Pass(string message, params object[] args)
- {
- if (message == null) message = string.Empty;
- else if (args != null && args.Length > 0)
- message = string.Format(message, args);
-
- throw new SuccessException(message);
- }
-
- /// <summary>
- /// Throws a <see cref="SuccessException"/> with the message and arguments
- /// that are passed in. This allows a test to be cut short, with a result
- /// of success returned to NUnit.
- /// </summary>
- /// <param name="message">The message to initialize the <see cref="AssertionException"/> with.</param>
- static public void Pass(string message)
- {
- Assert.Pass(message, null);
- }
-
- /// <summary>
- /// Throws a <see cref="SuccessException"/> with the message and arguments
- /// that are passed in. This allows a test to be cut short, with a result
- /// of success returned to NUnit.
- /// </summary>
- static public void Pass()
- {
- Assert.Pass(string.Empty, null);
- }
-
- #endregion
-
- #region Fail
-
- /// <summary>
- /// Throws an <see cref="AssertionException"/> with the message and arguments
- /// that are passed in. This is used by the other Assert functions.
- /// </summary>
- /// <param name="message">The message to initialize the <see cref="AssertionException"/> with.</param>
- /// <param name="args">Arguments to be used in formatting the message</param>
- static public void Fail(string message, params object[] args)
- {
- if (message == null) message = string.Empty;
- else if (args != null && args.Length > 0)
- message = string.Format(message, args);
-
- throw new AssertionException(message);
- }
-
- /// <summary>
- /// Throws an <see cref="AssertionException"/> with the message that is
- /// passed in. This is used by the other Assert functions.
- /// </summary>
- /// <param name="message">The message to initialize the <see cref="AssertionException"/> with.</param>
- static public void Fail(string message)
- {
- Assert.Fail(message, null);
- }
-
- /// <summary>
- /// Throws an <see cref="AssertionException"/>.
- /// This is used by the other Assert functions.
- /// </summary>
- static public void Fail()
- {
- Assert.Fail(string.Empty, null);
- }
-
- #endregion
-
- #region Ignore
-
- /// <summary>
- /// Throws an <see cref="IgnoreException"/> with the message and arguments
- /// that are passed in. This causes the test to be reported as ignored.
- /// </summary>
- /// <param name="message">The message to initialize the <see cref="AssertionException"/> with.</param>
- /// <param name="args">Arguments to be used in formatting the message</param>
- static public void Ignore(string message, params object[] args)
- {
- if (message == null) message = string.Empty;
- else if (args != null && args.Length > 0)
- message = string.Format(message, args);
-
- throw new IgnoreException(message);
- }
-
- /// <summary>
- /// Throws an <see cref="IgnoreException"/> with the message that is
- /// passed in. This causes the test to be reported as ignored.
- /// </summary>
- /// <param name="message">The message to initialize the <see cref="AssertionException"/> with.</param>
- static public void Ignore(string message)
- {
- Assert.Ignore(message, null);
- }
-
- /// <summary>
- /// Throws an <see cref="IgnoreException"/>.
- /// This causes the test to be reported as ignored.
- /// </summary>
- static public void Ignore()
- {
- Assert.Ignore(string.Empty, null);
- }
-
- #endregion
-
- #region InConclusive
-
- /// <summary>
- /// Throws an <see cref="InconclusiveException"/> with the message and arguments
- /// that are passed in. This causes the test to be reported as inconclusive.
- /// </summary>
- /// <param name="message">The message to initialize the <see cref="InconclusiveException"/> with.</param>
- /// <param name="args">Arguments to be used in formatting the message</param>
- static public void Inconclusive(string message, params object[] args)
- {
- if (message == null) message = string.Empty;
- else if (args != null && args.Length > 0)
- message = string.Format(message, args);
-
- throw new InconclusiveException(message);
- }
-
- /// <summary>
- /// Throws an <see cref="InconclusiveException"/> with the message that is
- /// passed in. This causes the test to be reported as inconclusive.
- /// </summary>
- /// <param name="message">The message to initialize the <see cref="InconclusiveException"/> with.</param>
- static public void Inconclusive(string message)
- {
- Assert.Inconclusive(message, null);
- }
-
- /// <summary>
- /// Throws an <see cref="InconclusiveException"/>.
- /// This causes the test to be reported as Inconclusive.
- /// </summary>
- static public void Inconclusive()
- {
- Assert.Inconclusive(string.Empty, null);
- }
-
- #endregion
-
- #endregion
-
- #region Assert.That
-
- #region Object
-
-#if !CLR_2_0 && !CLR_4_0
- /// <summary>
- /// Apply a constraint to an actual value, succeeding if the constraint
- /// is satisfied and throwing an assertion exception on failure.
- /// </summary>
- /// <param name="expression">A Constraint to be applied</param>
- /// <param name="actual">The actual value to test</param>
- static public void That(object actual, IResolveConstraint expression)
- {
- Assert.That(actual, expression, null, null);
- }
-
- /// <summary>
- /// Apply a constraint to an actual value, succeeding if the constraint
- /// is satisfied and throwing an assertion exception on failure.
- /// </summary>
- /// <param name="expression">A Constraint to be applied</param>
- /// <param name="actual">The actual value to test</param>
- /// <param name="message">The message that will be displayed on failure</param>
- static public void That(object actual, IResolveConstraint expression, string message)
- {
- Assert.That(actual, expression, message, null);
- }
-
- /// <summary>
- /// Apply a constraint to an actual value, succeeding if the constraint
- /// is satisfied and throwing an assertion exception on failure.
- /// </summary>
- /// <param name="expression">A Constraint expression to be applied</param>
- /// <param name="actual">The actual value to test</param>
- /// <param name="message">The message that will be displayed on failure</param>
- /// <param name="args">Arguments to be used in formatting the message</param>
- static public void That(object actual, IResolveConstraint expression, string message, params object[] args)
- {
- Constraint constraint = expression.Resolve();
-
- TestExecutionContext.CurrentContext.IncrementAssertCount();
- if (!constraint.Matches(actual))
- {
- MessageWriter writer = new TextMessageWriter(message, args);
- constraint.WriteMessageTo(writer);
- throw new AssertionException(writer.ToString());
- }
- }
-#endif
-
- #endregion
-
- #region Boolean
-
- /// <summary>
- /// Asserts that a condition is true. If the condition is false the method throws
- /// an <see cref="AssertionException"/>.
- /// </summary>
- /// <param name="condition">The evaluated condition</param>
- /// <param name="message">The message to display if the condition is false</param>
- /// <param name="args">Arguments to be used in formatting the message</param>
- static public void That(bool condition, string message, params object[] args)
- {
- Assert.That(condition, Is.True, message, args);
- }
-
- /// <summary>
- /// Asserts that a condition is true. If the condition is false the method throws
- /// an <see cref="AssertionException"/>.
- /// </summary>
- /// <param name="condition">The evaluated condition</param>
- /// <param name="message">The message to display if the condition is false</param>
- static public void That(bool condition, string message)
- {
- Assert.That(condition, Is.True, message, null);
- }
-
- /// <summary>
- /// Asserts that a condition is true. If the condition is false the method throws
- /// an <see cref="AssertionException"/>.
- /// </summary>
- /// <param name="condition">The evaluated condition</param>
- static public void That(bool condition)
- {
- Assert.That(condition, Is.True, null, null);
- }
-
- #endregion
-
- #region ref Boolean
-
-#if !CLR_2_0 && !CLR_4_0
- /// <summary>
- /// Apply a constraint to a referenced boolean, succeeding if the constraint
- /// is satisfied and throwing an assertion exception on failure.
- /// </summary>
- /// <param name="actual">The actual value to test</param>
- /// <param name="expression">A Constraint to be applied</param>
- static public void That(ref bool actual, IResolveConstraint expression)
- {
- Assert.That(ref actual, expression, null, null);
- }
-
- /// <summary>
- /// Apply a constraint to a referenced value, succeeding if the constraint
- /// is satisfied and throwing an assertion exception on failure.
- /// </summary>
- /// <param name="actual">The actual value to test</param>
- /// <param name="expression">A Constraint to be applied</param>
- /// <param name="message">The message that will be displayed on failure</param>
- static public void That(ref bool actual, IResolveConstraint expression, string message)
- {
- Assert.That(ref actual, expression, message, null);
- }
-
- /// <summary>
- /// Apply a constraint to a referenced value, succeeding if the constraint
- /// is satisfied and throwing an assertion exception on failure.
- /// </summary>
- /// <param name="actual">The actual value to test</param>
- /// <param name="expression">A Constraint to be applied</param>
- /// <param name="message">The message that will be displayed on failure</param>
- /// <param name="args">Arguments to be used in formatting the message</param>
- static public void That(ref bool actual, IResolveConstraint expression, string message, params object[] args)
- {
- Constraint constraint = expression.Resolve();
-
- TestExecutionContext.CurrentContext.IncrementAssertCount();
- if (!constraint.Matches(ref actual))
- {
- MessageWriter writer = new TextMessageWriter(message, args);
- constraint.WriteMessageTo(writer);
- throw new AssertionException(writer.ToString());
- }
- }
-#endif
-
- #endregion
-
- #region ActualValueDelegate
-#if !NUNITLITE
- /// <summary>
- /// Apply a constraint to an actual value, succeeding if the constraint
- /// is satisfied and throwing an assertion exception on failure.
- /// </summary>
- /// <param name="expr">A Constraint expression to be applied</param>
- /// <param name="del">An ActualValueDelegate returning the value to be tested</param>
- static public void That(ActualValueDelegate del, IResolveConstraint expr)
- {
- Assert.That(del, expr.Resolve(), null, null);
- }
-
- /// <summary>
- /// Apply a constraint to an actual value, succeeding if the constraint
- /// is satisfied and throwing an assertion exception on failure.
- /// </summary>
- /// <param name="expr">A Constraint expression to be applied</param>
- /// <param name="del">An ActualValueDelegate returning the value to be tested</param>
- /// <param name="message">The message that will be displayed on failure</param>
- static public void That(ActualValueDelegate del, IResolveConstraint expr, string message)
- {
- Assert.That(del, expr.Resolve(), message, null);
- }
-
- /// <summary>
- /// Apply a constraint to an actual value, succeeding if the constraint
- /// is satisfied and throwing an assertion exception on failure.
- /// </summary>
- /// <param name="del">An ActualValueDelegate returning the value to be tested</param>
- /// <param name="expr">A Constraint expression to be applied</param>
- /// <param name="message">The message that will be displayed on failure</param>
- /// <param name="args">Arguments to be used in formatting the message</param>
- static public void That(ActualValueDelegate del, IResolveConstraint expr, string message, params object[] args)
- {
- Constraint constraint = expr.Resolve();
-
- TestExecutionContext.CurrentContext.IncrementAssertCount();
- if (!constraint.Matches(del))
- {
- MessageWriter writer = new TextMessageWriter(message, args);
- constraint.WriteMessageTo(writer);
- throw new AssertionException(writer.ToString());
- }
- }
-#endif
- #endregion
-
- #region TestDelegate
-
- /// <summary>
- /// Asserts that the code represented by a delegate throws an exception
- /// that satisfies the constraint provided.
- /// </summary>
- /// <param name="code">A TestDelegate to be executed</param>
- /// <param name="constraint">A ThrowsConstraint used in the test</param>
- static public void That(TestDelegate code, IResolveConstraint constraint)
- {
- Assert.That((object)code, constraint);
- }
-
- #endregion
-
- #endregion
-
- #region Assert.That<T>
-
-#if CLR_2_0 || CLR_4_0
- /// <summary>
- /// Apply a constraint to an actual value, succeeding if the constraint
- /// is satisfied and throwing an assertion exception on failure.
- /// </summary>
- /// <param name="expression">A Constraint to be applied</param>
- /// <param name="actual">The actual value to test</param>
- static public void That<T>(T actual, IResolveConstraint expression)
- {
- Assert.That(actual, expression, null, null);
- }
-
- /// <summary>
- /// Apply a constraint to an actual value, succeeding if the constraint
- /// is satisfied and throwing an assertion exception on failure.
- /// </summary>
- /// <param name="expression">A Constraint to be applied</param>
- /// <param name="actual">The actual value to test</param>
- /// <param name="message">The message that will be displayed on failure</param>
- static public void That<T>(T actual, IResolveConstraint expression, string message)
- {
- Assert.That(actual, expression, message, null);
- }
-
- /// <summary>
- /// Apply a constraint to an actual value, succeeding if the constraint
- /// is satisfied and throwing an assertion exception on failure.
- /// </summary>
- /// <param name="expression">A Constraint expression to be applied</param>
- /// <param name="actual">The actual value to test</param>
- /// <param name="message">The message that will be displayed on failure</param>
- /// <param name="args">Arguments to be used in formatting the message</param>
- static public void That<T>(T actual, IResolveConstraint expression, string message, params object[] args)
- {
- Constraint constraint = expression.Resolve();
-
- TestExecutionContext.CurrentContext.IncrementAssertCount();
- if (!constraint.Matches(actual))
- {
- MessageWriter writer = new TextMessageWriter(message, args);
- constraint.WriteMessageTo(writer);
- throw new AssertionException(writer.ToString());
- }
- }
-
- /// <summary>
- /// Apply a constraint to a referenced value, succeeding if the constraint
- /// is satisfied and throwing an assertion exception on failure.
- /// </summary>
- /// <param name="actual">The actual value to test</param>
- /// <param name="expression">A Constraint to be applied</param>
- static public void That<T>(ref T actual, IResolveConstraint expression)
- {
- Assert.That(ref actual, expression, null, null);
- }
-
- /// <summary>
- /// Apply a constraint to a referenced value, succeeding if the constraint
- /// is satisfied and throwing an assertion exception on failure.
- /// </summary>
- /// <param name="actual">The actual value to test</param>
- /// <param name="expression">A Constraint to be applied</param>
- /// <param name="message">The message that will be displayed on failure</param>
- static public void That<T>(ref T actual, IResolveConstraint expression, string message)
- {
- Assert.That(ref actual, expression, message, null);
- }
-
- /// <summary>
- /// Apply a constraint to a referenced value, succeeding if the constraint
- /// is satisfied and throwing an assertion exception on failure.
- /// </summary>
- /// <param name="actual">The actual value to test</param>
- /// <param name="expression">A Constraint to be applied</param>
- /// <param name="message">The message that will be displayed on failure</param>
- /// <param name="args">Arguments to be used in formatting the message</param>
- static public void That<T>(ref T actual, IResolveConstraint expression, string message, params object[] args)
- {
- Constraint constraint = expression.Resolve();
-
- TestExecutionContext.CurrentContext.IncrementAssertCount();
- if (!constraint.Matches(ref actual))
- {
- MessageWriter writer = new TextMessageWriter(message, args);
- constraint.WriteMessageTo(writer);
- throw new AssertionException(writer.ToString());
- }
- }
-#endif
-
- #endregion
-
- #region Throws, Catch and DoesNotThrow
-
- #region Throws
- /// <summary>
- /// Verifies that a delegate throws a particular exception when called.
- /// </summary>
- /// <param name="expression">A constraint to be satisfied by the exception</param>
- /// <param name="code">A TestSnippet delegate</param>
- /// <param name="message">The message that will be displayed on failure</param>
- /// <param name="args">Arguments to be used in formatting the message</param>
- public static Exception Throws(IResolveConstraint expression, TestDelegate code, string message, params object[] args)
- {
- Exception caughtException = null;
-
- try
- {
- code();
- }
- catch (Exception ex)
- {
- caughtException = ex;
- }
-
- Assert.That(caughtException, expression, message, args);
-
- return caughtException;
- }
-
- /// <summary>
- /// Verifies that a delegate throws a particular exception when called.
- /// </summary>
- /// <param name="expression">A constraint to be satisfied by the exception</param>
- /// <param name="code">A TestSnippet delegate</param>
- /// <param name="message">The message that will be displayed on failure</param>
- public static Exception Throws(IResolveConstraint expression, TestDelegate code, string message)
- {
- return Throws(expression, code, message, null);
- }
-
- /// <summary>
- /// Verifies that a delegate throws a particular exception when called.
- /// </summary>
- /// <param name="expression">A constraint to be satisfied by the exception</param>
- /// <param name="code">A TestSnippet delegate</param>
- public static Exception Throws(IResolveConstraint expression, TestDelegate code)
- {
- return Throws(expression, code, string.Empty, null);
- }
-
- /// <summary>
- /// Verifies that a delegate throws a particular exception when called.
- /// </summary>
- /// <param name="expectedExceptionType">The exception Type expected</param>
- /// <param name="code">A TestSnippet delegate</param>
- /// <param name="message">The message that will be displayed on failure</param>
- /// <param name="args">Arguments to be used in formatting the message</param>
- public static Exception Throws(Type expectedExceptionType, TestDelegate code, string message, params object[] args)
- {
- return Throws(new ExactTypeConstraint(expectedExceptionType), code, message, args);
- }
-
- /// <summary>
- /// Verifies that a delegate throws a particular exception when called.
- /// </summary>
- /// <param name="expectedExceptionType">The exception Type expected</param>
- /// <param name="code">A TestSnippet delegate</param>
- /// <param name="message">The message that will be displayed on failure</param>
- public static Exception Throws(Type expectedExceptionType, TestDelegate code, string message)
- {
- return Throws(new ExactTypeConstraint(expectedExceptionType), code, message, null);
- }
-
- /// <summary>
- /// Verifies that a delegate throws a particular exception when called.
- /// </summary>
- /// <param name="expectedExceptionType">The exception Type expected</param>
- /// <param name="code">A TestSnippet delegate</param>
- public static Exception Throws(Type expectedExceptionType, TestDelegate code)
- {
- return Throws(new ExactTypeConstraint(expectedExceptionType), code, string.Empty, null);
- }
-
- #endregion
-
- #region Throws<T>
-#if CLR_2_0 || CLR_4_0
- /// <summary>
- /// Verifies that a delegate throws a particular exception when called.
- /// </summary>
- /// <typeparam name="T">Type of the expected exception</typeparam>
- /// <param name="code">A TestSnippet delegate</param>
- /// <param name="message">The message that will be displayed on failure</param>
- /// <param name="args">Arguments to be used in formatting the message</param>
- public static T Throws<T>(TestDelegate code, string message, params object[] args) where T : Exception
- {
- return (T)Throws(typeof(T), code, message, args);
- }
-
- /// <summary>
- /// Verifies that a delegate throws a particular exception when called.
- /// </summary>
- /// <typeparam name="T">Type of the expected exception</typeparam>
- /// <param name="code">A TestSnippet delegate</param>
- /// <param name="message">The message that will be displayed on failure</param>
- public static T Throws<T>(TestDelegate code, string message) where T : Exception
- {
- return Throws<T>(code, message, null);
- }
-
- /// <summary>
- /// Verifies that a delegate throws a particular exception when called.
- /// </summary>
- /// <typeparam name="T">Type of the expected exception</typeparam>
- /// <param name="code">A TestSnippet delegate</param>
- public static T Throws<T>(TestDelegate code) where T : Exception
- {
- return Throws<T>(code, string.Empty, null);
- }
-#endif
- #endregion
-
- #region Catch
- /// <summary>
- /// Verifies that a delegate throws an exception when called
- /// and returns it.
- /// </summary>
- /// <param name="code">A TestDelegate</param>
- /// <param name="message">The message that will be displayed on failure</param>
- /// <param name="args">Arguments to be used in formatting the message</param>
- public static Exception Catch(TestDelegate code, string message, params object[] args)
- {
- return Throws(new InstanceOfTypeConstraint(typeof(Exception)), code, message, args);
- }
-
- /// <summary>
- /// Verifies that a delegate throws an exception when called
- /// and returns it.
- /// </summary>
- /// <param name="code">A TestDelegate</param>
- /// <param name="message">The message that will be displayed on failure</param>
- public static Exception Catch(TestDelegate code, string message)
- {
- return Throws(new InstanceOfTypeConstraint(typeof(Exception)), code, message);
- }
-
- /// <summary>
- /// Verifies that a delegate throws an exception when called
- /// and returns it.
- /// </summary>
- /// <param name="code">A TestDelegate</param>
- public static Exception Catch(TestDelegate code)
- {
- return Throws(new InstanceOfTypeConstraint(typeof(Exception)), code);
- }
-
- /// <summary>
- /// Verifies that a delegate throws an exception of a certain Type
- /// or one derived from it when called and returns it.
- /// </summary>
- /// <param name="expectedExceptionType">The expected Exception Type</param>
- /// <param name="code">A TestDelegate</param>
- /// <param name="message">The message that will be displayed on failure</param>
- /// <param name="args">Arguments to be used in formatting the message</param>
- public static Exception Catch(Type expectedExceptionType, TestDelegate code, string message, params object[] args)
- {
- return Throws(new InstanceOfTypeConstraint(expectedExceptionType), code, message, args);
- }
-
- /// <summary>
- /// Verifies that a delegate throws an exception of a certain Type
- /// or one derived from it when called and returns it.
- /// </summary>
- /// <param name="expectedExceptionType">The expected Exception Type</param>
- /// <param name="code">A TestDelegate</param>
- /// <param name="message">The message that will be displayed on failure</param>
- public static Exception Catch(Type expectedExceptionType, TestDelegate code, string message)
- {
- return Throws(new InstanceOfTypeConstraint(expectedExceptionType), code, message);
- }
-
- /// <summary>
- /// Verifies that a delegate throws an exception of a certain Type
- /// or one derived from it when called and returns it.
- /// </summary>
- /// <param name="expectedExceptionType">The expected Exception Type</param>
- /// <param name="code">A TestDelegate</param>
- public static Exception Catch(Type expectedExceptionType, TestDelegate code)
- {
- return Throws(new InstanceOfTypeConstraint(expectedExceptionType), code);
- }
- #endregion
-
- #region Catch<T>
-#if CLR_2_0 || CLR_4_0
- /// <summary>
- /// Verifies that a delegate throws an exception of a certain Type
- /// or one derived from it when called and returns it.
- /// </summary>
- /// <param name="code">A TestDelegate</param>
- /// <param name="message">The message that will be displayed on failure</param>
- /// <param name="args">Arguments to be used in formatting the message</param>
- public static T Catch<T>(TestDelegate code, string message, params object[] args) where T : System.Exception
- {
- return (T)Throws(new InstanceOfTypeConstraint(typeof(T)), code, message, args);
- }
-
- /// <summary>
- /// Verifies that a delegate throws an exception of a certain Type
- /// or one derived from it when called and returns it.
- /// </summary>
- /// <param name="code">A TestDelegate</param>
- /// <param name="message">The message that will be displayed on failure</param>
- public static T Catch<T>(TestDelegate code, string message) where T : System.Exception
- {
- return (T)Throws(new InstanceOfTypeConstraint(typeof(T)), code, message);
- }
-
- /// <summary>
- /// Verifies that a delegate throws an exception of a certain Type
- /// or one derived from it when called and returns it.
- /// </summary>
- /// <param name="code">A TestDelegate</param>
- public static T Catch<T>(TestDelegate code) where T : System.Exception
- {
- return (T)Throws(new InstanceOfTypeConstraint(typeof(T)), code);
- }
-#endif
- #endregion
-
- #region DoesNotThrow
-
- /// <summary>
- /// Verifies that a delegate does not throw an exception
- /// </summary>
- /// <param name="code">A TestSnippet delegate</param>
- /// <param name="message">The message that will be displayed on failure</param>
- /// <param name="args">Arguments to be used in formatting the message</param>
- public static void DoesNotThrow(TestDelegate code, string message, params object[] args)
- {
- try
- {
- code();
- }
- catch (Exception ex)
- {
- TextMessageWriter writer = new TextMessageWriter(message, args);
- writer.WriteLine("Unexpected exception: {0}", ex.GetType());
- Assert.Fail(writer.ToString());
- }
- }
-
- /// <summary>
- /// Verifies that a delegate does not throw an exception.
- /// </summary>
- /// <param name="code">A TestSnippet delegate</param>
- /// <param name="message">The message that will be displayed on failure</param>
- public static void DoesNotThrow(TestDelegate code, string message)
- {
- DoesNotThrow(code, message, null);
- }
-
- /// <summary>
- /// Verifies that a delegate does not throw an exception.
- /// </summary>
- /// <param name="code">A TestSnippet delegate</param>
- public static void DoesNotThrow(TestDelegate code)
- {
- DoesNotThrow(code, string.Empty, null);
- }
-
- #endregion
-
- #endregion
-
- #region True
-
- /// <summary>
- /// Asserts that a condition is true. If the condition is false the method throws
- /// an <see cref="AssertionException"/>.
- /// </summary>
- /// <param name="condition">The evaluated condition</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void True(bool condition, string message, params object[] args)
- {
- Assert.That(condition, Is.True ,message, args);
- }
- /// <summary>
- /// Asserts that a condition is true. If the condition is false the method throws
- /// an <see cref="AssertionException"/>.
- /// </summary>
- /// <param name="condition">The evaluated condition</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void True(bool condition, string message)
- {
- Assert.That(condition, Is.True ,message, null);
- }
- /// <summary>
- /// Asserts that a condition is true. If the condition is false the method throws
- /// an <see cref="AssertionException"/>.
- /// </summary>
- /// <param name="condition">The evaluated condition</param>
- public static void True(bool condition)
- {
- Assert.That(condition, Is.True ,null, null);
- }
-
- /// <summary>
- /// Asserts that a condition is true. If the condition is false the method throws
- /// an <see cref="AssertionException"/>.
- /// </summary>
- /// <param name="condition">The evaluated condition</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void IsTrue(bool condition, string message, params object[] args)
- {
- Assert.That(condition, Is.True ,message, args);
- }
- /// <summary>
- /// Asserts that a condition is true. If the condition is false the method throws
- /// an <see cref="AssertionException"/>.
- /// </summary>
- /// <param name="condition">The evaluated condition</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void IsTrue(bool condition, string message)
- {
- Assert.That(condition, Is.True ,message, null);
- }
- /// <summary>
- /// Asserts that a condition is true. If the condition is false the method throws
- /// an <see cref="AssertionException"/>.
- /// </summary>
- /// <param name="condition">The evaluated condition</param>
- public static void IsTrue(bool condition)
- {
- Assert.That(condition, Is.True ,null, null);
- }
-
- #endregion
-
- #region False
-
- /// <summary>
- /// Asserts that a condition is false. If the condition is true the method throws
- /// an <see cref="AssertionException"/>.
- /// </summary>
- /// <param name="condition">The evaluated condition</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void False(bool condition, string message, params object[] args)
- {
- Assert.That(condition, Is.False ,message, args);
- }
- /// <summary>
- /// Asserts that a condition is false. If the condition is true the method throws
- /// an <see cref="AssertionException"/>.
- /// </summary>
- /// <param name="condition">The evaluated condition</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void False(bool condition, string message)
- {
- Assert.That(condition, Is.False ,message, null);
- }
- /// <summary>
- /// Asserts that a condition is false. If the condition is true the method throws
- /// an <see cref="AssertionException"/>.
- /// </summary>
- /// <param name="condition">The evaluated condition</param>
- public static void False(bool condition)
- {
- Assert.That(condition, Is.False ,null, null);
- }
-
- /// <summary>
- /// Asserts that a condition is false. If the condition is true the method throws
- /// an <see cref="AssertionException"/>.
- /// </summary>
- /// <param name="condition">The evaluated condition</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void IsFalse(bool condition, string message, params object[] args)
- {
- Assert.That(condition, Is.False ,message, args);
- }
- /// <summary>
- /// Asserts that a condition is false. If the condition is true the method throws
- /// an <see cref="AssertionException"/>.
- /// </summary>
- /// <param name="condition">The evaluated condition</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void IsFalse(bool condition, string message)
- {
- Assert.That(condition, Is.False ,message, null);
- }
- /// <summary>
- /// Asserts that a condition is false. If the condition is true the method throws
- /// an <see cref="AssertionException"/>.
- /// </summary>
- /// <param name="condition">The evaluated condition</param>
- public static void IsFalse(bool condition)
- {
- Assert.That(condition, Is.False ,null, null);
- }
-
- #endregion
-
- #region NotNull
-
- /// <summary>
- /// Verifies that the object that is passed in is not equal to <code>null</code>
- /// If the object is <code>null</code> then an <see cref="AssertionException"/>
- /// is thrown.
- /// </summary>
- /// <param name="anObject">The object that is to be tested</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void NotNull(object anObject, string message, params object[] args)
- {
- Assert.That(anObject, Is.Not.Null ,message, args);
- }
- /// <summary>
- /// Verifies that the object that is passed in is not equal to <code>null</code>
- /// If the object is <code>null</code> then an <see cref="AssertionException"/>
- /// is thrown.
- /// </summary>
- /// <param name="anObject">The object that is to be tested</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void NotNull(object anObject, string message)
- {
- Assert.That(anObject, Is.Not.Null ,message, null);
- }
- /// <summary>
- /// Verifies that the object that is passed in is not equal to <code>null</code>
- /// If the object is <code>null</code> then an <see cref="AssertionException"/>
- /// is thrown.
- /// </summary>
- /// <param name="anObject">The object that is to be tested</param>
- public static void NotNull(object anObject)
- {
- Assert.That(anObject, Is.Not.Null ,null, null);
- }
-
- /// <summary>
- /// Verifies that the object that is passed in is not equal to <code>null</code>
- /// If the object is <code>null</code> then an <see cref="AssertionException"/>
- /// is thrown.
- /// </summary>
- /// <param name="anObject">The object that is to be tested</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void IsNotNull(object anObject, string message, params object[] args)
- {
- Assert.That(anObject, Is.Not.Null ,message, args);
- }
- /// <summary>
- /// Verifies that the object that is passed in is not equal to <code>null</code>
- /// If the object is <code>null</code> then an <see cref="AssertionException"/>
- /// is thrown.
- /// </summary>
- /// <param name="anObject">The object that is to be tested</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void IsNotNull(object anObject, string message)
- {
- Assert.That(anObject, Is.Not.Null ,message, null);
- }
- /// <summary>
- /// Verifies that the object that is passed in is not equal to <code>null</code>
- /// If the object is <code>null</code> then an <see cref="AssertionException"/>
- /// is thrown.
- /// </summary>
- /// <param name="anObject">The object that is to be tested</param>
- public static void IsNotNull(object anObject)
- {
- Assert.That(anObject, Is.Not.Null ,null, null);
- }
-
- #endregion
-
- #region Null
-
- /// <summary>
- /// Verifies that the object that is passed in is equal to <code>null</code>
- /// If the object is not <code>null</code> then an <see cref="AssertionException"/>
- /// is thrown.
- /// </summary>
- /// <param name="anObject">The object that is to be tested</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void Null(object anObject, string message, params object[] args)
- {
- Assert.That(anObject, Is.Null ,message, args);
- }
- /// <summary>
- /// Verifies that the object that is passed in is equal to <code>null</code>
- /// If the object is not <code>null</code> then an <see cref="AssertionException"/>
- /// is thrown.
- /// </summary>
- /// <param name="anObject">The object that is to be tested</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void Null(object anObject, string message)
- {
- Assert.That(anObject, Is.Null ,message, null);
- }
- /// <summary>
- /// Verifies that the object that is passed in is equal to <code>null</code>
- /// If the object is not <code>null</code> then an <see cref="AssertionException"/>
- /// is thrown.
- /// </summary>
- /// <param name="anObject">The object that is to be tested</param>
- public static void Null(object anObject)
- {
- Assert.That(anObject, Is.Null ,null, null);
- }
-
- /// <summary>
- /// Verifies that the object that is passed in is equal to <code>null</code>
- /// If the object is not <code>null</code> then an <see cref="AssertionException"/>
- /// is thrown.
- /// </summary>
- /// <param name="anObject">The object that is to be tested</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void IsNull(object anObject, string message, params object[] args)
- {
- Assert.That(anObject, Is.Null ,message, args);
- }
- /// <summary>
- /// Verifies that the object that is passed in is equal to <code>null</code>
- /// If the object is not <code>null</code> then an <see cref="AssertionException"/>
- /// is thrown.
- /// </summary>
- /// <param name="anObject">The object that is to be tested</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void IsNull(object anObject, string message)
- {
- Assert.That(anObject, Is.Null ,message, null);
- }
- /// <summary>
- /// Verifies that the object that is passed in is equal to <code>null</code>
- /// If the object is not <code>null</code> then an <see cref="AssertionException"/>
- /// is thrown.
- /// </summary>
- /// <param name="anObject">The object that is to be tested</param>
- public static void IsNull(object anObject)
- {
- Assert.That(anObject, Is.Null ,null, null);
- }
-
- #endregion
-
- #region AreEqual
-
- #region Ints
-
- /// <summary>
- /// Verifies that two ints are equal. If they are not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void AreEqual(int expected, int actual, string message, params object[] args)
- {
- Assert.That(actual, Is.EqualTo(expected), message, args);
- }
- /// <summary>
- /// Verifies that two ints are equal. If they are not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void AreEqual(int expected, int actual, string message)
- {
- Assert.That(actual, Is.EqualTo(expected), message, null);
- }
- /// <summary>
- /// Verifies that two ints are equal. If they are not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- public static void AreEqual(int expected, int actual)
- {
- Assert.That(actual, Is.EqualTo(expected), null, null);
- }
-
- #endregion
-
- #region Longs
-
- /// <summary>
- /// Verifies that two longs are equal. If they are not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void AreEqual(long expected, long actual, string message, params object[] args)
- {
- Assert.That(actual, Is.EqualTo(expected), message, args);
- }
- /// <summary>
- /// Verifies that two longs are equal. If they are not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void AreEqual(long expected, long actual, string message)
- {
- Assert.That(actual, Is.EqualTo(expected), message, null);
- }
- /// <summary>
- /// Verifies that two longs are equal. If they are not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- public static void AreEqual(long expected, long actual)
- {
- Assert.That(actual, Is.EqualTo(expected), null, null);
- }
-
- #endregion
-
- #region Unsigned Ints
-
- /// <summary>
- /// Verifies that two unsigned ints are equal. If they are not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- [CLSCompliant(false)]
- public static void AreEqual(uint expected, uint actual, string message, params object[] args)
- {
- Assert.That(actual, Is.EqualTo(expected), message, args);
- }
- /// <summary>
- /// Verifies that two unsigned ints are equal. If they are not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- [CLSCompliant(false)]
- public static void AreEqual(uint expected, uint actual, string message)
- {
- Assert.That(actual, Is.EqualTo(expected), message, null);
- }
- /// <summary>
- /// Verifies that two unsigned ints are equal. If they are not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- [CLSCompliant(false)]
- public static void AreEqual(uint expected, uint actual)
- {
- Assert.That(actual, Is.EqualTo(expected), null, null);
- }
-
- #endregion
-
- #region Unsigned Longs
-
- /// <summary>
- /// Verifies that two unsigned longs are equal. If they are not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- [CLSCompliant(false)]
- public static void AreEqual(ulong expected, ulong actual, string message, params object[] args)
- {
- Assert.That(actual, Is.EqualTo(expected), message, args);
- }
- /// <summary>
- /// Verifies that two unsigned longs are equal. If they are not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- [CLSCompliant(false)]
- public static void AreEqual(ulong expected, ulong actual, string message)
- {
- Assert.That(actual, Is.EqualTo(expected), message, null);
- }
- /// <summary>
- /// Verifies that two unsigned longs are equal. If they are not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- [CLSCompliant(false)]
- public static void AreEqual(ulong expected, ulong actual)
- {
- Assert.That(actual, Is.EqualTo(expected), null, null);
- }
-
- #endregion
-
- #region Decimals
-
- /// <summary>
- /// Verifies that two decimals are equal. If they are not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void AreEqual(decimal expected, decimal actual, string message, params object[] args)
- {
- Assert.That(actual, Is.EqualTo(expected), message, args);
- }
- /// <summary>
- /// Verifies that two decimals are equal. If they are not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void AreEqual(decimal expected, decimal actual, string message)
- {
- Assert.That(actual, Is.EqualTo(expected), message, null);
- }
- /// <summary>
- /// Verifies that two decimals are equal. If they are not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- public static void AreEqual(decimal expected, decimal actual)
- {
- Assert.That(actual, Is.EqualTo(expected), null, null);
- }
-
- #endregion
-
- #region Doubles
-
- /// <summary>
- /// Verifies that two doubles are equal considering a delta. If the
- /// expected value is infinity then the delta value is ignored. If
- /// they are not equal then an <see cref="AssertionException"/> is
- /// thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="delta">The maximum acceptable difference between the
- /// the expected and the actual</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void AreEqual(double expected, double actual, double delta, string message, params object[] args)
- {
- AssertDoublesAreEqual(expected, actual, delta, message, args);
- }
- /// <summary>
- /// Verifies that two doubles are equal considering a delta. If the
- /// expected value is infinity then the delta value is ignored. If
- /// they are not equal then an <see cref="AssertionException"/> is
- /// thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="delta">The maximum acceptable difference between the
- /// the expected and the actual</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void AreEqual(double expected, double actual, double delta, string message)
- {
- AssertDoublesAreEqual(expected, actual, delta, message, null);
- }
- /// <summary>
- /// Verifies that two doubles are equal considering a delta. If the
- /// expected value is infinity then the delta value is ignored. If
- /// they are not equal then an <see cref="AssertionException"/> is
- /// thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="delta">The maximum acceptable difference between the
- /// the expected and the actual</param>
- public static void AreEqual(double expected, double actual, double delta)
- {
- AssertDoublesAreEqual(expected, actual, delta, null, null);
- }
-
-#if CLR_2_0 || CLR_4_0
- /// <summary>
- /// Verifies that two doubles are equal considering a delta. If the
- /// expected value is infinity then the delta value is ignored. If
- /// they are not equal then an <see cref="AssertionException"/> is
- /// thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="delta">The maximum acceptable difference between the
- /// the expected and the actual</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void AreEqual(double expected, double? actual, double delta, string message, params object[] args)
- {
- AssertDoublesAreEqual(expected, (double)actual, delta, message, args);
- }
- /// <summary>
- /// Verifies that two doubles are equal considering a delta. If the
- /// expected value is infinity then the delta value is ignored. If
- /// they are not equal then an <see cref="AssertionException"/> is
- /// thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="delta">The maximum acceptable difference between the
- /// the expected and the actual</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void AreEqual(double expected, double? actual, double delta, string message)
- {
- AssertDoublesAreEqual(expected, (double)actual, delta, message, null);
- }
- /// <summary>
- /// Verifies that two doubles are equal considering a delta. If the
- /// expected value is infinity then the delta value is ignored. If
- /// they are not equal then an <see cref="AssertionException"/> is
- /// thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="delta">The maximum acceptable difference between the
- /// the expected and the actual</param>
- public static void AreEqual(double expected, double? actual, double delta)
- {
- AssertDoublesAreEqual(expected, (double)actual, delta, null, null);
- }
-#endif
-
- #endregion
-
- #region Objects
-
- /// <summary>
- /// Verifies that two objects are equal. Two objects are considered
- /// equal if both are null, or if both have the same value. NUnit
- /// has special semantics for some object types.
- /// If they are not equal an <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The value that is expected</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void AreEqual(object expected, object actual, string message, params object[] args)
- {
- Assert.That(actual, Is.EqualTo(expected), message, args);
- }
- /// <summary>
- /// Verifies that two objects are equal. Two objects are considered
- /// equal if both are null, or if both have the same value. NUnit
- /// has special semantics for some object types.
- /// If they are not equal an <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The value that is expected</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void AreEqual(object expected, object actual, string message)
- {
- Assert.That(actual, Is.EqualTo(expected), message, null);
- }
- /// <summary>
- /// Verifies that two objects are equal. Two objects are considered
- /// equal if both are null, or if both have the same value. NUnit
- /// has special semantics for some object types.
- /// If they are not equal an <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The value that is expected</param>
- /// <param name="actual">The actual value</param>
- public static void AreEqual(object expected, object actual)
- {
- Assert.That(actual, Is.EqualTo(expected), null, null);
- }
-
- #endregion
-
- #endregion
-
- #region AreNotEqual
-
- #region Ints
-
- /// <summary>
- /// Verifies that two ints are not equal. If they are equal, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void AreNotEqual(int expected, int actual, string message, params object[] args)
- {
- Assert.That(actual, Is.Not.EqualTo(expected), message, args);
- }
- /// <summary>
- /// Verifies that two ints are not equal. If they are equal, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void AreNotEqual(int expected, int actual, string message)
- {
- Assert.That(actual, Is.Not.EqualTo(expected), message, null);
- }
- /// <summary>
- /// Verifies that two ints are not equal. If they are equal, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- public static void AreNotEqual(int expected, int actual)
- {
- Assert.That(actual, Is.Not.EqualTo(expected), null, null);
- }
-
- #endregion
-
- #region Longs
-
- /// <summary>
- /// Verifies that two longs are not equal. If they are equal, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void AreNotEqual(long expected, long actual, string message, params object[] args)
- {
- Assert.That(actual, Is.Not.EqualTo(expected), message, args);
- }
- /// <summary>
- /// Verifies that two longs are not equal. If they are equal, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void AreNotEqual(long expected, long actual, string message)
- {
- Assert.That(actual, Is.Not.EqualTo(expected), message, null);
- }
- /// <summary>
- /// Verifies that two longs are not equal. If they are equal, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- public static void AreNotEqual(long expected, long actual)
- {
- Assert.That(actual, Is.Not.EqualTo(expected), null, null);
- }
-
- #endregion
-
- #region Unsigned Ints
-
- /// <summary>
- /// Verifies that two unsigned ints are not equal. If they are equal, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- [CLSCompliant(false)]
- public static void AreNotEqual(uint expected, uint actual, string message, params object[] args)
- {
- Assert.That(actual, Is.Not.EqualTo(expected), message, args);
- }
- /// <summary>
- /// Verifies that two unsigned ints are not equal. If they are equal, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- [CLSCompliant(false)]
- public static void AreNotEqual(uint expected, uint actual, string message)
- {
- Assert.That(actual, Is.Not.EqualTo(expected), message, null);
- }
- /// <summary>
- /// Verifies that two unsigned ints are not equal. If they are equal, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- [CLSCompliant(false)]
- public static void AreNotEqual(uint expected, uint actual)
- {
- Assert.That(actual, Is.Not.EqualTo(expected), null, null);
- }
-
- #endregion
-
- #region Unsigned Longs
-
- /// <summary>
- /// Verifies that two unsigned longs are not equal. If they are equal, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- [CLSCompliant(false)]
- public static void AreNotEqual(ulong expected, ulong actual, string message, params object[] args)
- {
- Assert.That(actual, Is.Not.EqualTo(expected), message, args);
- }
- /// <summary>
- /// Verifies that two unsigned longs are not equal. If they are equal, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- [CLSCompliant(false)]
- public static void AreNotEqual(ulong expected, ulong actual, string message)
- {
- Assert.That(actual, Is.Not.EqualTo(expected), message, null);
- }
- /// <summary>
- /// Verifies that two unsigned longs are not equal. If they are equal, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- [CLSCompliant(false)]
- public static void AreNotEqual(ulong expected, ulong actual)
- {
- Assert.That(actual, Is.Not.EqualTo(expected), null, null);
- }
-
- #endregion
-
- #region Decimals
-
- /// <summary>
- /// Verifies that two decimals are not equal. If they are equal, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void AreNotEqual(decimal expected, decimal actual, string message, params object[] args)
- {
- Assert.That(actual, Is.Not.EqualTo(expected), message, args);
- }
- /// <summary>
- /// Verifies that two decimals are not equal. If they are equal, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void AreNotEqual(decimal expected, decimal actual, string message)
- {
- Assert.That(actual, Is.Not.EqualTo(expected), message, null);
- }
- /// <summary>
- /// Verifies that two decimals are not equal. If they are equal, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- public static void AreNotEqual(decimal expected, decimal actual)
- {
- Assert.That(actual, Is.Not.EqualTo(expected), null, null);
- }
-
- #endregion
-
- #region Floats
-
- /// <summary>
- /// Verifies that two floats are not equal. If they are equal, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void AreNotEqual(float expected, float actual, string message, params object[] args)
- {
- Assert.That(actual, Is.Not.EqualTo(expected), message, args);
- }
- /// <summary>
- /// Verifies that two floats are not equal. If they are equal, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void AreNotEqual(float expected, float actual, string message)
- {
- Assert.That(actual, Is.Not.EqualTo(expected), message, null);
- }
- /// <summary>
- /// Verifies that two floats are not equal. If they are equal, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- public static void AreNotEqual(float expected, float actual)
- {
- Assert.That(actual, Is.Not.EqualTo(expected), null, null);
- }
-
- #endregion
-
- #region Doubles
-
- /// <summary>
- /// Verifies that two doubles are not equal. If they are equal, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void AreNotEqual(double expected, double actual, string message, params object[] args)
- {
- Assert.That(actual, Is.Not.EqualTo(expected), message, args);
- }
- /// <summary>
- /// Verifies that two doubles are not equal. If they are equal, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void AreNotEqual(double expected, double actual, string message)
- {
- Assert.That(actual, Is.Not.EqualTo(expected), message, null);
- }
- /// <summary>
- /// Verifies that two doubles are not equal. If they are equal, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- public static void AreNotEqual(double expected, double actual)
- {
- Assert.That(actual, Is.Not.EqualTo(expected), null, null);
- }
-
- #endregion
-
- #region Objects
-
- /// <summary>
- /// Verifies that two objects are not equal. Two objects are considered
- /// equal if both are null, or if both have the same value. NUnit
- /// has special semantics for some object types.
- /// If they are equal an <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The value that is expected</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void AreNotEqual(object expected, object actual, string message, params object[] args)
- {
- Assert.That(actual, Is.Not.EqualTo(expected), message, args);
- }
- /// <summary>
- /// Verifies that two objects are not equal. Two objects are considered
- /// equal if both are null, or if both have the same value. NUnit
- /// has special semantics for some object types.
- /// If they are equal an <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The value that is expected</param>
- /// <param name="actual">The actual value</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void AreNotEqual(object expected, object actual, string message)
- {
- Assert.That(actual, Is.Not.EqualTo(expected), message, null);
- }
- /// <summary>
- /// Verifies that two objects are not equal. Two objects are considered
- /// equal if both are null, or if both have the same value. NUnit
- /// has special semantics for some object types.
- /// If they are equal an <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The value that is expected</param>
- /// <param name="actual">The actual value</param>
- public static void AreNotEqual(object expected, object actual)
- {
- Assert.That(actual, Is.Not.EqualTo(expected), null, null);
- }
-
- #endregion
-
- #endregion
-
- #region AreSame
-
- /// <summary>
- /// Asserts that two objects refer to the same object. If they
- /// are not the same an <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected object</param>
- /// <param name="actual">The actual object</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void AreSame(object expected, object actual, string message, params object[] args)
- {
- Assert.That(actual, Is.SameAs(expected), message, args);
- }
- /// <summary>
- /// Asserts that two objects refer to the same object. If they
- /// are not the same an <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected object</param>
- /// <param name="actual">The actual object</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void AreSame(object expected, object actual, string message)
- {
- Assert.That(actual, Is.SameAs(expected), message, null);
- }
- /// <summary>
- /// Asserts that two objects refer to the same object. If they
- /// are not the same an <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected object</param>
- /// <param name="actual">The actual object</param>
- public static void AreSame(object expected, object actual)
- {
- Assert.That(actual, Is.SameAs(expected), null, null);
- }
-
- #endregion
-
- #region AreNotSame
-
- /// <summary>
- /// Asserts that two objects do not refer to the same object. If they
- /// are the same an <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected object</param>
- /// <param name="actual">The actual object</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void AreNotSame(object expected, object actual, string message, params object[] args)
- {
- Assert.That(actual, Is.Not.SameAs(expected), message, args);
- }
- /// <summary>
- /// Asserts that two objects do not refer to the same object. If they
- /// are the same an <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected object</param>
- /// <param name="actual">The actual object</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void AreNotSame(object expected, object actual, string message)
- {
- Assert.That(actual, Is.Not.SameAs(expected), message, null);
- }
- /// <summary>
- /// Asserts that two objects do not refer to the same object. If they
- /// are the same an <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="expected">The expected object</param>
- /// <param name="actual">The actual object</param>
- public static void AreNotSame(object expected, object actual)
- {
- Assert.That(actual, Is.Not.SameAs(expected), null, null);
- }
-
- #endregion
-
-#if !NUnitLite
-
- #region IsNaN
-
- /// <summary>
- /// Verifies that the double that is passed in is an <code>NaN</code> value.
- /// If the object is not <code>NaN</code> then an <see cref="AssertionException"/>
- /// is thrown.
- /// </summary>
- /// <param name="aDouble">The value that is to be tested</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void IsNaN(double aDouble, string message, params object[] args)
- {
- Assert.That(aDouble, Is.NaN ,message, args);
- }
- /// <summary>
- /// Verifies that the double that is passed in is an <code>NaN</code> value.
- /// If the object is not <code>NaN</code> then an <see cref="AssertionException"/>
- /// is thrown.
- /// </summary>
- /// <param name="aDouble">The value that is to be tested</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void IsNaN(double aDouble, string message)
- {
- Assert.That(aDouble, Is.NaN ,message, null);
- }
- /// <summary>
- /// Verifies that the double that is passed in is an <code>NaN</code> value.
- /// If the object is not <code>NaN</code> then an <see cref="AssertionException"/>
- /// is thrown.
- /// </summary>
- /// <param name="aDouble">The value that is to be tested</param>
- public static void IsNaN(double aDouble)
- {
- Assert.That(aDouble, Is.NaN ,null, null);
- }
-
-#if CLR_2_0 || CLR_4_0
- /// <summary>
- /// Verifies that the double that is passed in is an <code>NaN</code> value.
- /// If the object is not <code>NaN</code> then an <see cref="AssertionException"/>
- /// is thrown.
- /// </summary>
- /// <param name="aDouble">The value that is to be tested</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void IsNaN(double? aDouble, string message, params object[] args)
- {
- Assert.That(aDouble, Is.NaN ,message, args);
- }
- /// <summary>
- /// Verifies that the double that is passed in is an <code>NaN</code> value.
- /// If the object is not <code>NaN</code> then an <see cref="AssertionException"/>
- /// is thrown.
- /// </summary>
- /// <param name="aDouble">The value that is to be tested</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void IsNaN(double? aDouble, string message)
- {
- Assert.That(aDouble, Is.NaN ,message, null);
- }
- /// <summary>
- /// Verifies that the double that is passed in is an <code>NaN</code> value.
- /// If the object is not <code>NaN</code> then an <see cref="AssertionException"/>
- /// is thrown.
- /// </summary>
- /// <param name="aDouble">The value that is to be tested</param>
- public static void IsNaN(double? aDouble)
- {
- Assert.That(aDouble, Is.NaN ,null, null);
- }
-#endif
-
- #endregion
-
- #region IsEmpty
-
- #region String
-
- /// <summary>
- /// Assert that a string is empty - that is equal to string.Empty
- /// </summary>
- /// <param name="aString">The string to be tested</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void IsEmpty(string aString, string message, params object[] args)
- {
- Assert.That(aString, new EmptyStringConstraint() ,message, args);
- }
- /// <summary>
- /// Assert that a string is empty - that is equal to string.Empty
- /// </summary>
- /// <param name="aString">The string to be tested</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void IsEmpty(string aString, string message)
- {
- Assert.That(aString, new EmptyStringConstraint() ,message, null);
- }
- /// <summary>
- /// Assert that a string is empty - that is equal to string.Empty
- /// </summary>
- /// <param name="aString">The string to be tested</param>
- public static void IsEmpty(string aString)
- {
- Assert.That(aString, new EmptyStringConstraint() ,null, null);
- }
-
- #endregion
-
- #region Collection
-
- /// <summary>
- /// Assert that an array, list or other collection is empty
- /// </summary>
- /// <param name="collection">An array, list or other collection implementing ICollection</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void IsEmpty(ICollection collection, string message, params object[] args)
- {
- Assert.That(collection, new EmptyCollectionConstraint() ,message, args);
- }
- /// <summary>
- /// Assert that an array, list or other collection is empty
- /// </summary>
- /// <param name="collection">An array, list or other collection implementing ICollection</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void IsEmpty(ICollection collection, string message)
- {
- Assert.That(collection, new EmptyCollectionConstraint() ,message, null);
- }
- /// <summary>
- /// Assert that an array, list or other collection is empty
- /// </summary>
- /// <param name="collection">An array, list or other collection implementing ICollection</param>
- public static void IsEmpty(ICollection collection)
- {
- Assert.That(collection, new EmptyCollectionConstraint() ,null, null);
- }
-
- #endregion
-
- #endregion
-
- #region IsNotEmpty
-
- #region String
-
- /// <summary>
- /// Assert that a string is not empty - that is not equal to string.Empty
- /// </summary>
- /// <param name="aString">The string to be tested</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void IsNotEmpty(string aString, string message, params object[] args)
- {
- Assert.That(aString, Is.Not.Empty ,message, args);
- }
- /// <summary>
- /// Assert that a string is not empty - that is not equal to string.Empty
- /// </summary>
- /// <param name="aString">The string to be tested</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void IsNotEmpty(string aString, string message)
- {
- Assert.That(aString, Is.Not.Empty ,message, null);
- }
- /// <summary>
- /// Assert that a string is not empty - that is not equal to string.Empty
- /// </summary>
- /// <param name="aString">The string to be tested</param>
- public static void IsNotEmpty(string aString)
- {
- Assert.That(aString, Is.Not.Empty ,null, null);
- }
-
- #endregion
-
- #region Collection
-
- /// <summary>
- /// Assert that an array, list or other collection is not empty
- /// </summary>
- /// <param name="collection">An array, list or other collection implementing ICollection</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void IsNotEmpty(ICollection collection, string message, params object[] args)
- {
- Assert.That(collection, Is.Not.Empty ,message, args);
- }
- /// <summary>
- /// Assert that an array, list or other collection is not empty
- /// </summary>
- /// <param name="collection">An array, list or other collection implementing ICollection</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void IsNotEmpty(ICollection collection, string message)
- {
- Assert.That(collection, Is.Not.Empty ,message, null);
- }
- /// <summary>
- /// Assert that an array, list or other collection is not empty
- /// </summary>
- /// <param name="collection">An array, list or other collection implementing ICollection</param>
- public static void IsNotEmpty(ICollection collection)
- {
- Assert.That(collection, Is.Not.Empty ,null, null);
- }
-
- #endregion
-
- #endregion
-
- #region IsNullOrEmpty
-
- /// <summary>
- /// Assert that a string is either null or equal to string.Empty
- /// </summary>
- /// <param name="aString">The string to be tested</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void IsNullOrEmpty(string aString, string message, params object[] args)
- {
- Assert.That(aString, new NullOrEmptyStringConstraint() ,message, args);
- }
- /// <summary>
- /// Assert that a string is either null or equal to string.Empty
- /// </summary>
- /// <param name="aString">The string to be tested</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void IsNullOrEmpty(string aString, string message)
- {
- Assert.That(aString, new NullOrEmptyStringConstraint() ,message, null);
- }
- /// <summary>
- /// Assert that a string is either null or equal to string.Empty
- /// </summary>
- /// <param name="aString">The string to be tested</param>
- public static void IsNullOrEmpty(string aString)
- {
- Assert.That(aString, new NullOrEmptyStringConstraint() ,null, null);
- }
-
- #endregion
-
- #region IsNotNullOrEmpty
-
- /// <summary>
- /// Assert that a string is not null or empty
- /// </summary>
- /// <param name="aString">The string to be tested</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void IsNotNullOrEmpty(string aString, string message, params object[] args)
- {
- Assert.That(aString, new NotConstraint( new NullOrEmptyStringConstraint()) ,message, args);
- }
- /// <summary>
- /// Assert that a string is not null or empty
- /// </summary>
- /// <param name="aString">The string to be tested</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void IsNotNullOrEmpty(string aString, string message)
- {
- Assert.That(aString, new NotConstraint( new NullOrEmptyStringConstraint()) ,message, null);
- }
- /// <summary>
- /// Assert that a string is not null or empty
- /// </summary>
- /// <param name="aString">The string to be tested</param>
- public static void IsNotNullOrEmpty(string aString)
- {
- Assert.That(aString, new NotConstraint( new NullOrEmptyStringConstraint()) ,null, null);
- }
-
- #endregion
-
- #region IsAssignableFrom
-
- /// <summary>
- /// Asserts that an object may be assigned a value of a given Type.
- /// </summary>
- /// <param name="expected">The expected Type.</param>
- /// <param name="actual">The object under examination</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void IsAssignableFrom(Type expected, object actual, string message, params object[] args)
- {
- Assert.That(actual, Is.AssignableFrom(expected) ,message, args);
- }
- /// <summary>
- /// Asserts that an object may be assigned a value of a given Type.
- /// </summary>
- /// <param name="expected">The expected Type.</param>
- /// <param name="actual">The object under examination</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void IsAssignableFrom(Type expected, object actual, string message)
- {
- Assert.That(actual, Is.AssignableFrom(expected) ,message, null);
- }
- /// <summary>
- /// Asserts that an object may be assigned a value of a given Type.
- /// </summary>
- /// <param name="expected">The expected Type.</param>
- /// <param name="actual">The object under examination</param>
- public static void IsAssignableFrom(Type expected, object actual)
- {
- Assert.That(actual, Is.AssignableFrom(expected) ,null, null);
- }
-
- #endregion
-
- #region IsAssignableFrom<T>
-
-#if CLR_2_0 || CLR_4_0
- /// <summary>
- /// Asserts that an object may be assigned a value of a given Type.
- /// </summary>
- /// <typeparam name="T">The expected Type.</typeparam>
- /// <param name="actual">The object under examination</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void IsAssignableFrom<T>(object actual, string message, params object[] args)
- {
- Assert.That(actual, Is.AssignableFrom(typeof(T)) ,message, args);
- }
- /// <summary>
- /// Asserts that an object may be assigned a value of a given Type.
- /// </summary>
- /// <typeparam name="T">The expected Type.</typeparam>
- /// <param name="actual">The object under examination</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void IsAssignableFrom<T>(object actual, string message)
- {
- Assert.That(actual, Is.AssignableFrom(typeof(T)) ,message, null);
- }
- /// <summary>
- /// Asserts that an object may be assigned a value of a given Type.
- /// </summary>
- /// <typeparam name="T">The expected Type.</typeparam>
- /// <param name="actual">The object under examination</param>
- public static void IsAssignableFrom<T>(object actual)
- {
- Assert.That(actual, Is.AssignableFrom(typeof(T)) ,null, null);
- }
-#endif
-
- #endregion
-
- #region IsNotAssignableFrom
-
- /// <summary>
- /// Asserts that an object may not be assigned a value of a given Type.
- /// </summary>
- /// <param name="expected">The expected Type.</param>
- /// <param name="actual">The object under examination</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void IsNotAssignableFrom(Type expected, object actual, string message, params object[] args)
- {
- Assert.That(actual, Is.Not.AssignableFrom(expected) ,message, args);
- }
- /// <summary>
- /// Asserts that an object may not be assigned a value of a given Type.
- /// </summary>
- /// <param name="expected">The expected Type.</param>
- /// <param name="actual">The object under examination</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void IsNotAssignableFrom(Type expected, object actual, string message)
- {
- Assert.That(actual, Is.Not.AssignableFrom(expected) ,message, null);
- }
- /// <summary>
- /// Asserts that an object may not be assigned a value of a given Type.
- /// </summary>
- /// <param name="expected">The expected Type.</param>
- /// <param name="actual">The object under examination</param>
- public static void IsNotAssignableFrom(Type expected, object actual)
- {
- Assert.That(actual, Is.Not.AssignableFrom(expected) ,null, null);
- }
-
- #endregion
-
- #region IsNotAssignableFrom<T>
-
-#if CLR_2_0 || CLR_4_0
- /// <summary>
- /// Asserts that an object may not be assigned a value of a given Type.
- /// </summary>
- /// <typeparam name="T">The expected Type.</typeparam>
- /// <param name="actual">The object under examination</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void IsNotAssignableFrom<T>(object actual, string message, params object[] args)
- {
- Assert.That(actual, Is.Not.AssignableFrom(typeof(T)) ,message, args);
- }
- /// <summary>
- /// Asserts that an object may not be assigned a value of a given Type.
- /// </summary>
- /// <typeparam name="T">The expected Type.</typeparam>
- /// <param name="actual">The object under examination</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void IsNotAssignableFrom<T>(object actual, string message)
- {
- Assert.That(actual, Is.Not.AssignableFrom(typeof(T)) ,message, null);
- }
- /// <summary>
- /// Asserts that an object may not be assigned a value of a given Type.
- /// </summary>
- /// <typeparam name="T">The expected Type.</typeparam>
- /// <param name="actual">The object under examination</param>
- public static void IsNotAssignableFrom<T>(object actual)
- {
- Assert.That(actual, Is.Not.AssignableFrom(typeof(T)) ,null, null);
- }
-#endif
-
- #endregion
-
- #region IsInstanceOf
-
- /// <summary>
- /// Asserts that an object is an instance of a given type.
- /// </summary>
- /// <param name="expected">The expected Type</param>
- /// <param name="actual">The object being examined</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void IsInstanceOf(Type expected, object actual, string message, params object[] args)
- {
- Assert.That(actual, Is.InstanceOf(expected) ,message, args);
- }
- /// <summary>
- /// Asserts that an object is an instance of a given type.
- /// </summary>
- /// <param name="expected">The expected Type</param>
- /// <param name="actual">The object being examined</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void IsInstanceOf(Type expected, object actual, string message)
- {
- Assert.That(actual, Is.InstanceOf(expected) ,message, null);
- }
- /// <summary>
- /// Asserts that an object is an instance of a given type.
- /// </summary>
- /// <param name="expected">The expected Type</param>
- /// <param name="actual">The object being examined</param>
- public static void IsInstanceOf(Type expected, object actual)
- {
- Assert.That(actual, Is.InstanceOf(expected) ,null, null);
- }
-
- #endregion
-
- #region IsInstanceOf<T>
-
-#if CLR_2_0 || CLR_4_0
- /// <summary>
- /// Asserts that an object is an instance of a given type.
- /// </summary>
- /// <typeparam name="T">The expected Type</typeparam>
- /// <param name="actual">The object being examined</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void IsInstanceOf<T>(object actual, string message, params object[] args)
- {
- Assert.That(actual, Is.InstanceOf(typeof(T)) ,message, args);
- }
- /// <summary>
- /// Asserts that an object is an instance of a given type.
- /// </summary>
- /// <typeparam name="T">The expected Type</typeparam>
- /// <param name="actual">The object being examined</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void IsInstanceOf<T>(object actual, string message)
- {
- Assert.That(actual, Is.InstanceOf(typeof(T)) ,message, null);
- }
- /// <summary>
- /// Asserts that an object is an instance of a given type.
- /// </summary>
- /// <typeparam name="T">The expected Type</typeparam>
- /// <param name="actual">The object being examined</param>
- public static void IsInstanceOf<T>(object actual)
- {
- Assert.That(actual, Is.InstanceOf(typeof(T)) ,null, null);
- }
-#endif
-
- #endregion
-
- #region IsNotInstanceOf
-
- /// <summary>
- /// Asserts that an object is not an instance of a given type.
- /// </summary>
- /// <param name="expected">The expected Type</param>
- /// <param name="actual">The object being examined</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void IsNotInstanceOf(Type expected, object actual, string message, params object[] args)
- {
- Assert.That(actual, Is.Not.InstanceOf(expected) ,message, args);
- }
- /// <summary>
- /// Asserts that an object is not an instance of a given type.
- /// </summary>
- /// <param name="expected">The expected Type</param>
- /// <param name="actual">The object being examined</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void IsNotInstanceOf(Type expected, object actual, string message)
- {
- Assert.That(actual, Is.Not.InstanceOf(expected) ,message, null);
- }
- /// <summary>
- /// Asserts that an object is not an instance of a given type.
- /// </summary>
- /// <param name="expected">The expected Type</param>
- /// <param name="actual">The object being examined</param>
- public static void IsNotInstanceOf(Type expected, object actual)
- {
- Assert.That(actual, Is.Not.InstanceOf(expected) ,null, null);
- }
-
- #endregion
-
- #region IsNotInstanceOf<T>
-
-#if CLR_2_0 || CLR_4_0
- /// <summary>
- /// Asserts that an object is not an instance of a given type.
- /// </summary>
- /// <typeparam name="T">The expected Type</typeparam>
- /// <param name="actual">The object being examined</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void IsNotInstanceOf<T>(object actual, string message, params object[] args)
- {
- Assert.That(actual, Is.Not.InstanceOf(typeof(T)) ,message, args);
- }
- /// <summary>
- /// Asserts that an object is not an instance of a given type.
- /// </summary>
- /// <typeparam name="T">The expected Type</typeparam>
- /// <param name="actual">The object being examined</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void IsNotInstanceOf<T>(object actual, string message)
- {
- Assert.That(actual, Is.Not.InstanceOf(typeof(T)) ,message, null);
- }
- /// <summary>
- /// Asserts that an object is not an instance of a given type.
- /// </summary>
- /// <typeparam name="T">The expected Type</typeparam>
- /// <param name="actual">The object being examined</param>
- public static void IsNotInstanceOf<T>(object actual)
- {
- Assert.That(actual, Is.Not.InstanceOf(typeof(T)) ,null, null);
- }
-#endif
-
- #endregion
-
- #region Greater
-
- #region Ints
-
- /// <summary>
- /// Verifies that the first int is greater than the second
- /// int. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void Greater(int arg1, int arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.GreaterThan(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first int is greater than the second
- /// int. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void Greater(int arg1, int arg2, string message)
- {
- Assert.That(arg1, Is.GreaterThan(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first int is greater than the second
- /// int. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- public static void Greater(int arg1, int arg2)
- {
- Assert.That(arg1, Is.GreaterThan(arg2) ,null, null);
- }
-
- #endregion
-
- #region Unsigned Ints
-
- /// <summary>
- /// Verifies that the first value is greater than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- [CLSCompliant(false)]
- public static void Greater(uint arg1, uint arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.GreaterThan(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is greater than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- [CLSCompliant(false)]
- public static void Greater(uint arg1, uint arg2, string message)
- {
- Assert.That(arg1, Is.GreaterThan(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is greater than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- [CLSCompliant(false)]
- public static void Greater(uint arg1, uint arg2)
- {
- Assert.That(arg1, Is.GreaterThan(arg2) ,null, null);
- }
-
- #endregion
-
- #region Longs
-
- /// <summary>
- /// Verifies that the first value is greater than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void Greater(long arg1, long arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.GreaterThan(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is greater than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void Greater(long arg1, long arg2, string message)
- {
- Assert.That(arg1, Is.GreaterThan(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is greater than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- public static void Greater(long arg1, long arg2)
- {
- Assert.That(arg1, Is.GreaterThan(arg2) ,null, null);
- }
-
- #endregion
-
- #region Unsigned Longs
-
- /// <summary>
- /// Verifies that the first value is greater than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- [CLSCompliant(false)]
- public static void Greater(ulong arg1, ulong arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.GreaterThan(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is greater than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- [CLSCompliant(false)]
- public static void Greater(ulong arg1, ulong arg2, string message)
- {
- Assert.That(arg1, Is.GreaterThan(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is greater than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- [CLSCompliant(false)]
- public static void Greater(ulong arg1, ulong arg2)
- {
- Assert.That(arg1, Is.GreaterThan(arg2) ,null, null);
- }
-
- #endregion
-
- #region Decimals
-
- /// <summary>
- /// Verifies that the first value is greater than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void Greater(decimal arg1, decimal arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.GreaterThan(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is greater than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void Greater(decimal arg1, decimal arg2, string message)
- {
- Assert.That(arg1, Is.GreaterThan(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is greater than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- public static void Greater(decimal arg1, decimal arg2)
- {
- Assert.That(arg1, Is.GreaterThan(arg2) ,null, null);
- }
-
- #endregion
-
- #region Doubles
-
- /// <summary>
- /// Verifies that the first value is greater than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void Greater(double arg1, double arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.GreaterThan(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is greater than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void Greater(double arg1, double arg2, string message)
- {
- Assert.That(arg1, Is.GreaterThan(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is greater than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- public static void Greater(double arg1, double arg2)
- {
- Assert.That(arg1, Is.GreaterThan(arg2) ,null, null);
- }
-
- #endregion
-
- #region Floats
-
- /// <summary>
- /// Verifies that the first value is greater than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void Greater(float arg1, float arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.GreaterThan(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is greater than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void Greater(float arg1, float arg2, string message)
- {
- Assert.That(arg1, Is.GreaterThan(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is greater than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- public static void Greater(float arg1, float arg2)
- {
- Assert.That(arg1, Is.GreaterThan(arg2) ,null, null);
- }
-
- #endregion
-
- #region IComparables
-
- /// <summary>
- /// Verifies that the first value is greater than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void Greater(IComparable arg1, IComparable arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.GreaterThan(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is greater than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void Greater(IComparable arg1, IComparable arg2, string message)
- {
- Assert.That(arg1, Is.GreaterThan(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is greater than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- public static void Greater(IComparable arg1, IComparable arg2)
- {
- Assert.That(arg1, Is.GreaterThan(arg2) ,null, null);
- }
-
- #endregion
-
- #endregion
-
- #region Less
-
- #region Ints
-
- /// <summary>
- /// Verifies that the first value is less than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void Less(int arg1, int arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.LessThan(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is less than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void Less(int arg1, int arg2, string message)
- {
- Assert.That(arg1, Is.LessThan(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is less than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- public static void Less(int arg1, int arg2)
- {
- Assert.That(arg1, Is.LessThan(arg2) ,null, null);
- }
-
- #endregion
-
- #region Unsigned Ints
-
- /// <summary>
- /// Verifies that the first value is less than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- [CLSCompliant(false)]
- public static void Less(uint arg1, uint arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.LessThan(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is less than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- [CLSCompliant(false)]
- public static void Less(uint arg1, uint arg2, string message)
- {
- Assert.That(arg1, Is.LessThan(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is less than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- [CLSCompliant(false)]
- public static void Less(uint arg1, uint arg2)
- {
- Assert.That(arg1, Is.LessThan(arg2) ,null, null);
- }
-
- #endregion
-
- #region Longs
-
- /// <summary>
- /// Verifies that the first value is less than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void Less(long arg1, long arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.LessThan(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is less than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void Less(long arg1, long arg2, string message)
- {
- Assert.That(arg1, Is.LessThan(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is less than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- public static void Less(long arg1, long arg2)
- {
- Assert.That(arg1, Is.LessThan(arg2) ,null, null);
- }
-
- #endregion
-
- #region Unsigned Longs
-
- /// <summary>
- /// Verifies that the first value is less than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- [CLSCompliant(false)]
- public static void Less(ulong arg1, ulong arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.LessThan(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is less than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- [CLSCompliant(false)]
- public static void Less(ulong arg1, ulong arg2, string message)
- {
- Assert.That(arg1, Is.LessThan(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is less than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- [CLSCompliant(false)]
- public static void Less(ulong arg1, ulong arg2)
- {
- Assert.That(arg1, Is.LessThan(arg2) ,null, null);
- }
-
-#endregion
-
- #region Decimals
-
- /// <summary>
- /// Verifies that the first value is less than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void Less(decimal arg1, decimal arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.LessThan(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is less than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void Less(decimal arg1, decimal arg2, string message)
- {
- Assert.That(arg1, Is.LessThan(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is less than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- public static void Less(decimal arg1, decimal arg2)
- {
- Assert.That(arg1, Is.LessThan(arg2) ,null, null);
- }
-
- #endregion
-
- #region Doubles
-
- /// <summary>
- /// Verifies that the first value is less than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void Less(double arg1, double arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.LessThan(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is less than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void Less(double arg1, double arg2, string message)
- {
- Assert.That(arg1, Is.LessThan(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is less than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- public static void Less(double arg1, double arg2)
- {
- Assert.That(arg1, Is.LessThan(arg2) ,null, null);
- }
-
- #endregion
-
- #region Floats
-
- /// <summary>
- /// Verifies that the first value is less than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void Less(float arg1, float arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.LessThan(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is less than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void Less(float arg1, float arg2, string message)
- {
- Assert.That(arg1, Is.LessThan(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is less than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- public static void Less(float arg1, float arg2)
- {
- Assert.That(arg1, Is.LessThan(arg2) ,null, null);
- }
-
- #endregion
-
- #region IComparables
-
- /// <summary>
- /// Verifies that the first value is less than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void Less(IComparable arg1, IComparable arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.LessThan(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is less than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void Less(IComparable arg1, IComparable arg2, string message)
- {
- Assert.That(arg1, Is.LessThan(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is less than the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- public static void Less(IComparable arg1, IComparable arg2)
- {
- Assert.That(arg1, Is.LessThan(arg2) ,null, null);
- }
-
- #endregion
-
- #endregion
-
- #region GreaterOrEqual
-
- #region Ints
-
- /// <summary>
- /// Verifies that the first value is greater than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void GreaterOrEqual(int arg1, int arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is greater than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void GreaterOrEqual(int arg1, int arg2, string message)
- {
- Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is greater than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- public static void GreaterOrEqual(int arg1, int arg2)
- {
- Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,null, null);
- }
-
- #endregion
-
- #region Unsigned Ints
-
- /// <summary>
- /// Verifies that the first value is greater than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- [CLSCompliant(false)]
- public static void GreaterOrEqual(uint arg1, uint arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is greater than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- [CLSCompliant(false)]
- public static void GreaterOrEqual(uint arg1, uint arg2, string message)
- {
- Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is greater than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- [CLSCompliant(false)]
- public static void GreaterOrEqual(uint arg1, uint arg2)
- {
- Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,null, null);
- }
-
- #endregion
-
- #region Longs
-
- /// <summary>
- /// Verifies that the first value is greater than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void GreaterOrEqual(long arg1, long arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is greater than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void GreaterOrEqual(long arg1, long arg2, string message)
- {
- Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is greater than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- public static void GreaterOrEqual(long arg1, long arg2)
- {
- Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,null, null);
- }
-
- #endregion
-
- #region Unsigned Longs
-
- /// <summary>
- /// Verifies that the first value is greater than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- [CLSCompliant(false)]
- public static void GreaterOrEqual(ulong arg1, ulong arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is greater than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- [CLSCompliant(false)]
- public static void GreaterOrEqual(ulong arg1, ulong arg2, string message)
- {
- Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is greater than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- [CLSCompliant(false)]
- public static void GreaterOrEqual(ulong arg1, ulong arg2)
- {
- Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,null, null);
- }
-
- #endregion
-
- #region Decimals
-
- /// <summary>
- /// Verifies that the first value is greater than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void GreaterOrEqual(decimal arg1, decimal arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is greater than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void GreaterOrEqual(decimal arg1, decimal arg2, string message)
- {
- Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is greater than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- public static void GreaterOrEqual(decimal arg1, decimal arg2)
- {
- Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,null, null);
- }
-
- #endregion
-
- #region Doubles
-
- /// <summary>
- /// Verifies that the first value is greater than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void GreaterOrEqual(double arg1, double arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is greater than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void GreaterOrEqual(double arg1, double arg2, string message)
- {
- Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is greater than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- public static void GreaterOrEqual(double arg1, double arg2)
- {
- Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,null, null);
- }
-
- #endregion
-
- #region Floats
-
- /// <summary>
- /// Verifies that the first value is greater than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void GreaterOrEqual(float arg1, float arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is greater than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void GreaterOrEqual(float arg1, float arg2, string message)
- {
- Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is greater than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- public static void GreaterOrEqual(float arg1, float arg2)
- {
- Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,null, null);
- }
-
- #endregion
-
- #region IComparables
-
- /// <summary>
- /// Verifies that the first value is greater than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void GreaterOrEqual(IComparable arg1, IComparable arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is greater than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void GreaterOrEqual(IComparable arg1, IComparable arg2, string message)
- {
- Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is greater than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be greater</param>
- /// <param name="arg2">The second value, expected to be less</param>
- public static void GreaterOrEqual(IComparable arg1, IComparable arg2)
- {
- Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,null, null);
- }
-
- #endregion
-
- #endregion
-
- #region LessOrEqual
-
- #region Ints
-
- /// <summary>
- /// Verifies that the first value is less than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void LessOrEqual(int arg1, int arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is less than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void LessOrEqual(int arg1, int arg2, string message)
- {
- Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is less than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- public static void LessOrEqual(int arg1, int arg2)
- {
- Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,null, null);
- }
-
- #endregion
-
- #region Unsigned Ints
-
- /// <summary>
- /// Verifies that the first value is less than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- [CLSCompliant(false)]
- public static void LessOrEqual(uint arg1, uint arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is less than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- [CLSCompliant(false)]
- public static void LessOrEqual(uint arg1, uint arg2, string message)
- {
- Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is less than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- [CLSCompliant(false)]
- public static void LessOrEqual(uint arg1, uint arg2)
- {
- Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,null, null);
- }
-
- #endregion
-
- #region Longs
-
- /// <summary>
- /// Verifies that the first value is less than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void LessOrEqual(long arg1, long arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is less than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void LessOrEqual(long arg1, long arg2, string message)
- {
- Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is less than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- public static void LessOrEqual(long arg1, long arg2)
- {
- Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,null, null);
- }
-
- #endregion
-
- #region Unsigned Longs
-
- /// <summary>
- /// Verifies that the first value is less than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- [CLSCompliant(false)]
- public static void LessOrEqual(ulong arg1, ulong arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is less than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- [CLSCompliant(false)]
- public static void LessOrEqual(ulong arg1, ulong arg2, string message)
- {
- Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is less than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- [CLSCompliant(false)]
- public static void LessOrEqual(ulong arg1, ulong arg2)
- {
- Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,null, null);
- }
-
- #endregion
-
- #region Decimals
-
- /// <summary>
- /// Verifies that the first value is less than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void LessOrEqual(decimal arg1, decimal arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is less than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void LessOrEqual(decimal arg1, decimal arg2, string message)
- {
- Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is less than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- public static void LessOrEqual(decimal arg1, decimal arg2)
- {
- Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,null, null);
- }
-
- #endregion
-
- #region Doubles
-
- /// <summary>
- /// Verifies that the first value is less than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void LessOrEqual(double arg1, double arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is less than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void LessOrEqual(double arg1, double arg2, string message)
- {
- Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is less than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- public static void LessOrEqual(double arg1, double arg2)
- {
- Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,null, null);
- }
-
- #endregion
-
- #region Floats
-
- /// <summary>
- /// Verifies that the first value is less than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void LessOrEqual(float arg1, float arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is less than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void LessOrEqual(float arg1, float arg2, string message)
- {
- Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is less than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- public static void LessOrEqual(float arg1, float arg2)
- {
- Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,null, null);
- }
-
- #endregion
-
- #region IComparables
-
- /// <summary>
- /// Verifies that the first value is less than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void LessOrEqual(IComparable arg1, IComparable arg2, string message, params object[] args)
- {
- Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, args);
- }
- /// <summary>
- /// Verifies that the first value is less than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void LessOrEqual(IComparable arg1, IComparable arg2, string message)
- {
- Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, null);
- }
- /// <summary>
- /// Verifies that the first value is less than or equal to the second
- /// value. If it is not, then an
- /// <see cref="AssertionException"/> is thrown.
- /// </summary>
- /// <param name="arg1">The first value, expected to be less</param>
- /// <param name="arg2">The second value, expected to be greater</param>
- public static void LessOrEqual(IComparable arg1, IComparable arg2)
- {
- Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,null, null);
- }
-
- #endregion
-
- #endregion
-
- #region Contains
-
- /// <summary>
- /// Asserts that an object is contained in a list.
- /// </summary>
- /// <param name="expected">The expected object</param>
- /// <param name="actual">The list to be examined</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- public static void Contains(object expected, ICollection actual, string message, params object[] args)
- {
- Assert.That(actual, new CollectionContainsConstraint(expected) ,message, args);
- }
- /// <summary>
- /// Asserts that an object is contained in a list.
- /// </summary>
- /// <param name="expected">The expected object</param>
- /// <param name="actual">The list to be examined</param>
- /// <param name="message">The message to display in case of failure</param>
- public static void Contains(object expected, ICollection actual, string message)
- {
- Assert.That(actual, new CollectionContainsConstraint(expected) ,message, null);
- }
- /// <summary>
- /// Asserts that an object is contained in a list.
- /// </summary>
- /// <param name="expected">The expected object</param>
- /// <param name="actual">The list to be examined</param>
- public static void Contains(object expected, ICollection actual)
- {
- Assert.That(actual, new CollectionContainsConstraint(expected) ,null, null);
- }
-
- #endregion
-
-#endif
-
- #region Helper Methods
- /// <summary>
- /// Helper for Assert.AreEqual(double expected, double actual, ...)
- /// allowing code generation to work consistently.
- /// </summary>
- /// <param name="expected">The expected value</param>
- /// <param name="actual">The actual value</param>
- /// <param name="delta">The maximum acceptable difference between the
- /// the expected and the actual</param>
- /// <param name="message">The message to display in case of failure</param>
- /// <param name="args">Array of objects to be used in formatting the message</param>
- protected static void AssertDoublesAreEqual(double expected, double actual, double delta, string message, object[] args)
- {
- if (double.IsNaN(expected) || double.IsInfinity(expected))
- Assert.That(actual, Is.EqualTo(expected), message, args);
- else
- Assert.That(actual, Is.EqualTo(expected).Within(delta), message, args);
- }
- #endregion
- }
-}
+// ***********************************************************************
+// Copyright (c) 2009 Charlie Poole
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// ***********************************************************************
+
+// ****************************************************************
+// Generated by the NUnit Syntax Generator
+//
+// Command Line: GenSyntax.exe Assert.cs
+//
+// DO NOT MODIFY THIS FILE DIRECTLY
+// ****************************************************************
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using NUnit.Framework.Api;
+using NUnit.Framework.Constraints;
+using NUnit.Framework.Internal;
+
+namespace NUnit.Framework
+{
+ /// <summary>
+ /// Delegate used by tests that execute code and
+ /// capture any thrown exception.
+ /// </summary>
+ public delegate void TestDelegate();
+
+ /// <summary>
+ /// The Assert class contains a collection of static methods that
+ /// implement the most common assertions used in NUnit.
+ /// </summary>
+ public class Assert
+ {
+ #region Constructor
+
+ /// <summary>
+ /// We don't actually want any instances of this object, but some people
+ /// like to inherit from it to add other static methods. Hence, the
+ /// protected constructor disallows any instances of this object.
+ /// </summary>
+ protected Assert() { }
+
+ #endregion
+
+ #region Equals and ReferenceEquals
+
+#if !NETCF
+ /// <summary>
+ /// The Equals method throws an AssertionException. This is done
+ /// to make sure there is no mistake by calling this function.
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="b"></param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static new bool Equals(object a, object b)
+ {
+ throw new InvalidOperationException("Assert.Equals should not be used for Assertions");
+ }
+
+ /// <summary>
+ /// override the default ReferenceEquals to throw an AssertionException. This
+ /// implementation makes sure there is no mistake in calling this function
+ /// as part of Assert.
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="b"></param>
+ public static new void ReferenceEquals(object a, object b)
+ {
+ throw new InvalidOperationException("Assert.ReferenceEquals should not be used for Assertions");
+ }
+#endif
+
+ #endregion
+
+ #region Utility Asserts
+
+ #region Pass
+
+ /// <summary>
+ /// Throws a <see cref="SuccessException"/> with the message and arguments
+ /// that are passed in. This allows a test to be cut short, with a result
+ /// of success returned to NUnit.
+ /// </summary>
+ /// <param name="message">The message to initialize the <see cref="AssertionException"/> with.</param>
+ /// <param name="args">Arguments to be used in formatting the message</param>
+ static public void Pass(string message, params object[] args)
+ {
+ if (message == null) message = string.Empty;
+ else if (args != null && args.Length > 0)
+ message = string.Format(message, args);
+
+ throw new SuccessException(message);
+ }
+
+ /// <summary>
+ /// Throws a <see cref="SuccessException"/> with the message and arguments
+ /// that are passed in. This allows a test to be cut short, with a result
+ /// of success returned to NUnit.
+ /// </summary>
+ /// <param name="message">The message to initialize the <see cref="AssertionException"/> with.</param>
+ static public void Pass(string message)
+ {
+ Assert.Pass(message, null);
+ }
+
+ /// <summary>
+ /// Throws a <see cref="SuccessException"/> with the message and arguments
+ /// that are passed in. This allows a test to be cut short, with a result
+ /// of success returned to NUnit.
+ /// </summary>
+ static public void Pass()
+ {
+ Assert.Pass(string.Empty, null);
+ }
+
+ #endregion
+
+ #region Fail
+
+ /// <summary>
+ /// Throws an <see cref="AssertionException"/> with the message and arguments
+ /// that are passed in. This is used by the other Assert functions.
+ /// </summary>
+ /// <param name="message">The message to initialize the <see cref="AssertionException"/> with.</param>
+ /// <param name="args">Arguments to be used in formatting the message</param>
+ static public void Fail(string message, params object[] args)
+ {
+ if (message == null) message = string.Empty;
+ else if (args != null && args.Length > 0)
+ message = string.Format(message, args);
+
+ throw new AssertionException(message);
+ }
+
+ /// <summary>
+ /// Throws an <see cref="AssertionException"/> with the message that is
+ /// passed in. This is used by the other Assert functions.
+ /// </summary>
+ /// <param name="message">The message to initialize the <see cref="AssertionException"/> with.</param>
+ static public void Fail(string message)
+ {
+ Assert.Fail(message, null);
+ }
+
+ /// <summary>
+ /// Throws an <see cref="AssertionException"/>.
+ /// This is used by the other Assert functions.
+ /// </summary>
+ static public void Fail()
+ {
+ Assert.Fail(string.Empty, null);
+ }
+
+ #endregion
+
+ #region Ignore
+
+ /// <summary>
+ /// Throws an <see cref="IgnoreException"/> with the message and arguments
+ /// that are passed in. This causes the test to be reported as ignored.
+ /// </summary>
+ /// <param name="message">The message to initialize the <see cref="AssertionException"/> with.</param>
+ /// <param name="args">Arguments to be used in formatting the message</param>
+ static public void Ignore(string message, params object[] args)
+ {
+ if (message == null) message = string.Empty;
+ else if (args != null && args.Length > 0)
+ message = string.Format(message, args);
+
+ throw new IgnoreException(message);
+ }
+
+ /// <summary>
+ /// Throws an <see cref="IgnoreException"/> with the message that is
+ /// passed in. This causes the test to be reported as ignored.
+ /// </summary>
+ /// <param name="message">The message to initialize the <see cref="AssertionException"/> with.</param>
+ static public void Ignore(string message)
+ {
+ Assert.Ignore(message, null);
+ }
+
+ /// <summary>
+ /// Throws an <see cref="IgnoreException"/>.
+ /// This causes the test to be reported as ignored.
+ /// </summary>
+ static public void Ignore()
+ {
+ Assert.Ignore(string.Empty, null);
+ }
+
+ #endregion
+
+ #region InConclusive
+
+ /// <summary>
+ /// Throws an <see cref="InconclusiveException"/> with the message and arguments
+ /// that are passed in. This causes the test to be reported as inconclusive.
+ /// </summary>
+ /// <param name="message">The message to initialize the <see cref="InconclusiveException"/> with.</param>
+ /// <param name="args">Arguments to be used in formatting the message</param>
+ static public void Inconclusive(string message, params object[] args)
+ {
+ if (message == null) message = string.Empty;
+ else if (args != null && args.Length > 0)
+ message = string.Format(message, args);
+
+ throw new InconclusiveException(message);
+ }
+
+ /// <summary>
+ /// Throws an <see cref="InconclusiveException"/> with the message that is
+ /// passed in. This causes the test to be reported as inconclusive.
+ /// </summary>
+ /// <param name="message">The message to initialize the <see cref="InconclusiveException"/> with.</param>
+ static public void Inconclusive(string message)
+ {
+ Assert.Inconclusive(message, null);
+ }
+
+ /// <summary>
+ /// Throws an <see cref="InconclusiveException"/>.
+ /// This causes the test to be reported as Inconclusive.
+ /// </summary>
+ static public void Inconclusive()
+ {
+ Assert.Inconclusive(string.Empty, null);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Assert.That
+
+ #region Object
+
+#if !CLR_2_0 && !CLR_4_0
+ /// <summary>
+ /// Apply a constraint to an actual value, succeeding if the constraint
+ /// is satisfied and throwing an assertion exception on failure.
+ /// </summary>
+ /// <param name="expression">A Constraint to be applied</param>
+ /// <param name="actual">The actual value to test</param>
+ static public void That(object actual, IResolveConstraint expression)
+ {
+ Assert.That(actual, expression, null, null);
+ }
+
+ /// <summary>
+ /// Apply a constraint to an actual value, succeeding if the constraint
+ /// is satisfied and throwing an assertion exception on failure.
+ /// </summary>
+ /// <param name="expression">A Constraint to be applied</param>
+ /// <param name="actual">The actual value to test</param>
+ /// <param name="message">The message that will be displayed on failure</param>
+ static public void That(object actual, IResolveConstraint expression, string message)
+ {
+ Assert.That(actual, expression, message, null);
+ }
+
+ /// <summary>
+ /// Apply a constraint to an actual value, succeeding if the constraint
+ /// is satisfied and throwing an assertion exception on failure.
+ /// </summary>
+ /// <param name="expression">A Constraint expression to be applied</param>
+ /// <param name="actual">The actual value to test</param>
+ /// <param name="message">The message that will be displayed on failure</param>
+ /// <param name="args">Arguments to be used in formatting the message</param>
+ static public void That(object actual, IResolveConstraint expression, string message, params object[] args)
+ {
+ Constraint constraint = expression.Resolve();
+
+ TestExecutionContext.CurrentContext.IncrementAssertCount();
+
+ ConstraintResult cr = constraint.Verify(actual);
+ if (cr.Result != ResultState.Success)
+ {
+ MessageWriter writer = new TextMessageWriter(message, args);
+ constraint.WriteMessageTo(writer);
+ throw new AssertionException(writer.ToString());
+ }
+ }
+#endif
+
+ #endregion
+
+ #region Boolean
+
+ /// <summary>
+ /// Asserts that a condition is true. If the condition is false the method throws
+ /// an <see cref="AssertionException"/>.
+ /// </summary>
+ /// <param name="condition">The evaluated condition</param>
+ /// <param name="message">The message to display if the condition is false</param>
+ /// <param name="args">Arguments to be used in formatting the message</param>
+ static public void That(bool condition, string message, params object[] args)
+ {
+ Assert.That(condition, Is.True, message, args);
+ }
+
+ /// <summary>
+ /// Asserts that a condition is true. If the condition is false the method throws
+ /// an <see cref="AssertionException"/>.
+ /// </summary>
+ /// <param name="condition">The evaluated condition</param>
+ /// <param name="message">The message to display if the condition is false</param>
+ static public void That(bool condition, string message)
+ {
+ Assert.That(condition, Is.True, message, null);
+ }
+
+ /// <summary>
+ /// Asserts that a condition is true. If the condition is false the method throws
+ /// an <see cref="AssertionException"/>.
+ /// </summary>
+ /// <param name="condition">The evaluated condition</param>
+ static public void That(bool condition)
+ {
+ Assert.That(condition, Is.True, null, null);
+ }
+
+ #endregion
+
+ #region ref Boolean
+
+#if !CLR_2_0 && !CLR_4_0
+ /// <summary>
+ /// Apply a constraint to a referenced boolean, succeeding if the constraint
+ /// is satisfied and throwing an assertion exception on failure.
+ /// </summary>
+ /// <param name="actual">The actual value to test</param>
+ /// <param name="expression">A Constraint to be applied</param>
+ static public void That(ref bool actual, IResolveConstraint expression)
+ {
+ Assert.That(ref actual, expression, null, null);
+ }
+
+ /// <summary>
+ /// Apply a constraint to a referenced value, succeeding if the constraint
+ /// is satisfied and throwing an assertion exception on failure.
+ /// </summary>
+ /// <param name="actual">The actual value to test</param>
+ /// <param name="expression">A Constraint to be applied</param>
+ /// <param name="message">The message that will be displayed on failure</param>
+ static public void That(ref bool actual, IResolveConstraint expression, string message)
+ {
+ Assert.That(ref actual, expression, message, null);
+ }
+
+ /// <summary>
+ /// Apply a constraint to a referenced value, succeeding if the constraint
+ /// is satisfied and throwing an assertion exception on failure.
+ /// </summary>
+ /// <param name="actual">The actual value to test</param>
+ /// <param name="expression">A Constraint to be applied</param>
+ /// <param name="message">The message that will be displayed on failure</param>
+ /// <param name="args">Arguments to be used in formatting the message</param>
+ static public void That(ref bool actual, IResolveConstraint expression, string message, params object[] args)
+ {
+ Constraint constraint = expression.Resolve();
+
+ TestExecutionContext.CurrentContext.IncrementAssertCount();
+
+ ConstraintResult cr = constraint.Verify(ref actual);
+ if (cr.Result != ResultState.Success)
+ {
+ MessageWriter writer = new TextMessageWriter(message, args);
+ constraint.WriteMessageTo(writer);
+ throw new AssertionException(writer.ToString());
+ }
+ }
+#endif
+
+ #endregion
+
+ #region ActualValueDelegate
+#if !NUNITLITE
+ /// <summary>
+ /// Apply a constraint to an actual value, succeeding if the constraint
+ /// is satisfied and throwing an assertion exception on failure.
+ /// </summary>
+ /// <param name="expr">A Constraint expression to be applied</param>
+ /// <param name="del">An ActualValueDelegate returning the value to be tested</param>
+ static public void That(ActualValueDelegate del, IResolveConstraint expr)
+ {
+ Assert.That(del, expr.Resolve(), null, null);
+ }
+
+ /// <summary>
+ /// Apply a constraint to an actual value, succeeding if the constraint
+ /// is satisfied and throwing an assertion exception on failure.
+ /// </summary>
+ /// <param name="expr">A Constraint expression to be applied</param>
+ /// <param name="del">An ActualValueDelegate returning the value to be tested</param>
+ /// <param name="message">The message that will be displayed on failure</param>
+ static public void That(ActualValueDelegate del, IResolveConstraint expr, string message)
+ {
+ Assert.That(del, expr.Resolve(), message, null);
+ }
+
+ /// <summary>
+ /// Apply a constraint to an actual value, succeeding if the constraint
+ /// is satisfied and throwing an assertion exception on failure.
+ /// </summary>
+ /// <param name="del">An ActualValueDelegate returning the value to be tested</param>
+ /// <param name="expr">A Constraint expression to be applied</param>
+ /// <param name="message">The message that will be displayed on failure</param>
+ /// <param name="args">Arguments to be used in formatting the message</param>
+ static public void That(ActualValueDelegate del, IResolveConstraint expr, string message, params object[] args)
+ {
+ Constraint constraint = expr.Resolve();
+
+ TestExecutionContext.CurrentContext.IncrementAssertCount();
+
+ ConstraintResult cr = constraint.Verify(del);
+ if (cr.Result != ResultState.Success)
+ {
+ MessageWriter writer = new TextMessageWriter(message, args);
+ constraint.WriteMessageTo(writer);
+ throw new AssertionException(writer.ToString());
+ }
+ }
+#endif
+ #endregion
+
+ #region TestDelegate
+
+ /// <summary>
+ /// Asserts that the code represented by a delegate throws an exception
+ /// that satisfies the constraint provided.
+ /// </summary>
+ /// <param name="code">A TestDelegate to be executed</param>
+ /// <param name="constraint">A ThrowsConstraint used in the test</param>
+ static public void That(TestDelegate code, IResolveConstraint constraint)
+ {
+ Assert.That((object)code, constraint);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Assert.That<T>
+
+#if CLR_2_0 || CLR_4_0
+ /// <summary>
+ /// Apply a constraint to an actual value, succeeding if the constraint
+ /// is satisfied and throwing an assertion exception on failure.
+ /// </summary>
+ /// <param name="expression">A Constraint to be applied</param>
+ /// <param name="actual">The actual value to test</param>
+ static public void That<T>(T actual, IResolveConstraint expression)
+ {
+ Assert.That(actual, expression, null, null);
+ }
+
+ /// <summary>
+ /// Apply a constraint to an actual value, succeeding if the constraint
+ /// is satisfied and throwing an assertion exception on failure.
+ /// </summary>
+ /// <param name="expression">A Constraint to be applied</param>
+ /// <param name="actual">The actual value to test</param>
+ /// <param name="message">The message that will be displayed on failure</param>
+ static public void That<T>(T actual, IResolveConstraint expression, string message)
+ {
+ Assert.That(actual, expression, message, null);
+ }
+
+ /// <summary>
+ /// Apply a constraint to an actual value, succeeding if the constraint
+ /// is satisfied and throwing an assertion exception on failure.
+ /// </summary>
+ /// <param name="expression">A Constraint expression to be applied</param>
+ /// <param name="actual">The actual value to test</param>
+ /// <param name="message">The message that will be displayed on failure</param>
+ /// <param name="args">Arguments to be used in formatting the message</param>
+ static public void That<T>(T actual, IResolveConstraint expression, string message, params object[] args)
+ {
+ Constraint constraint = expression.Resolve();
+
+ TestExecutionContext.CurrentContext.IncrementAssertCount();
+
+ ConstraintResult cr = constraint.Verify(ref actual);
+ if (cr.Result != ResultState.Success)
+ {
+ MessageWriter writer = new TextMessageWriter(message, args);
+ constraint.WriteMessageTo(writer);
+ throw new AssertionException(writer.ToString());
+ }
+ }
+
+ /// <summary>
+ /// Apply a constraint to a referenced value, succeeding if the constraint
+ /// is satisfied and throwing an assertion exception on failure.
+ /// </summary>
+ /// <param name="actual">The actual value to test</param>
+ /// <param name="expression">A Constraint to be applied</param>
+ static public void That<T>(ref T actual, IResolveConstraint expression)
+ {
+ Assert.That(ref actual, expression, null, null);
+ }
+
+ /// <summary>
+ /// Apply a constraint to a referenced value, succeeding if the constraint
+ /// is satisfied and throwing an assertion exception on failure.
+ /// </summary>
+ /// <param name="actual">The actual value to test</param>
+ /// <param name="expression">A Constraint to be applied</param>
+ /// <param name="message">The message that will be displayed on failure</param>
+ static public void That<T>(ref T actual, IResolveConstraint expression, string message)
+ {
+ Assert.That(ref actual, expression, message, null);
+ }
+
+ /// <summary>
+ /// Apply a constraint to a referenced value, succeeding if the constraint
+ /// is satisfied and throwing an assertion exception on failure.
+ /// </summary>
+ /// <param name="actual">The actual value to test</param>
+ /// <param name="expression">A Constraint to be applied</param>
+ /// <param name="message">The message that will be displayed on failure</param>
+ /// <param name="args">Arguments to be used in formatting the message</param>
+ static public void That<T>(ref T actual, IResolveConstraint expression, string message, params object[] args)
+ {
+ Constraint constraint = expression.Resolve();
+
+ TestExecutionContext.CurrentContext.IncrementAssertCount();
+
+ ConstraintResult cr = constraint.Verify(ref actual);
+ if (cr.Result != ResultState.Success)
+ {
+ MessageWriter writer = new TextMessageWriter(message, args);
+ constraint.WriteMessageTo(writer);
+ throw new AssertionException(writer.ToString());
+ }
+ }
+#endif
+
+ #endregion
+
+ #region Throws, Catch and DoesNotThrow
+
+ #region Throws
+ /// <summary>
+ /// Verifies that a delegate throws a particular exception when called.
+ /// </summary>
+ /// <param name="expression">A constraint to be satisfied by the exception</param>
+ /// <param name="code">A TestSnippet delegate</param>
+ /// <param name="message">The message that will be displayed on failure</param>
+ /// <param name="args">Arguments to be used in formatting the message</param>
+ public static Exception Throws(IResolveConstraint expression, TestDelegate code, string message, params object[] args)
+ {
+ Exception caughtException = null;
+
+ try
+ {
+ code();
+ }
+ catch (Exception ex)
+ {
+ caughtException = ex;
+ }
+
+ Assert.That(caughtException, expression, message, args);
+
+ return caughtException;
+ }
+
+ /// <summary>
+ /// Verifies that a delegate throws a particular exception when called.
+ /// </summary>
+ /// <param name="expression">A constraint to be satisfied by the exception</param>
+ /// <param name="code">A TestSnippet delegate</param>
+ /// <param name="message">The message that will be displayed on failure</param>
+ public static Exception Throws(IResolveConstraint expression, TestDelegate code, string message)
+ {
+ return Throws(expression, code, message, null);
+ }
+
+ /// <summary>
+ /// Verifies that a delegate throws a particular exception when called.
+ /// </summary>
+ /// <param name="expression">A constraint to be satisfied by the exception</param>
+ /// <param name="code">A TestSnippet delegate</param>
+ public static Exception Throws(IResolveConstraint expression, TestDelegate code)
+ {
+ return Throws(expression, code, string.Empty, null);
+ }
+
+ /// <summary>
+ /// Verifies that a delegate throws a particular exception when called.
+ /// </summary>
+ /// <param name="expectedExceptionType">The exception Type expected</param>
+ /// <param name="code">A TestSnippet delegate</param>
+ /// <param name="message">The message that will be displayed on failure</param>
+ /// <param name="args">Arguments to be used in formatting the message</param>
+ public static Exception Throws(Type expectedExceptionType, TestDelegate code, string message, params object[] args)
+ {
+ return Throws(new ExactTypeConstraint(expectedExceptionType), code, message, args);
+ }
+
+ /// <summary>
+ /// Verifies that a delegate throws a particular exception when called.
+ /// </summary>
+ /// <param name="expectedExceptionType">The exception Type expected</param>
+ /// <param name="code">A TestSnippet delegate</param>
+ /// <param name="message">The message that will be displayed on failure</param>
+ public static Exception Throws(Type expectedExceptionType, TestDelegate code, string message)
+ {
+ return Throws(new ExactTypeConstraint(expectedExceptionType), code, message, null);
+ }
+
+ /// <summary>
+ /// Verifies that a delegate throws a particular exception when called.
+ /// </summary>
+ /// <param name="expectedExceptionType">The exception Type expected</param>
+ /// <param name="code">A TestSnippet delegate</param>
+ public static Exception Throws(Type expectedExceptionType, TestDelegate code)
+ {
+ return Throws(new ExactTypeConstraint(expectedExceptionType), code, string.Empty, null);
+ }
+
+ #endregion
+
+ #region Throws<T>
+#if CLR_2_0 || CLR_4_0
+ /// <summary>
+ /// Verifies that a delegate throws a particular exception when called.
+ /// </summary>
+ /// <typeparam name="T">Type of the expected exception</typeparam>
+ /// <param name="code">A TestSnippet delegate</param>
+ /// <param name="message">The message that will be displayed on failure</param>
+ /// <param name="args">Arguments to be used in formatting the message</param>
+ public static T Throws<T>(TestDelegate code, string message, params object[] args) where T : Exception
+ {
+ return (T)Throws(typeof(T), code, message, args);
+ }
+
+ /// <summary>
+ /// Verifies that a delegate throws a particular exception when called.
+ /// </summary>
+ /// <typeparam name="T">Type of the expected exception</typeparam>
+ /// <param name="code">A TestSnippet delegate</param>
+ /// <param name="message">The message that will be displayed on failure</param>
+ public static T Throws<T>(TestDelegate code, string message) where T : Exception
+ {
+ return Throws<T>(code, message, null);
+ }
+
+ /// <summary>
+ /// Verifies that a delegate throws a particular exception when called.
+ /// </summary>
+ /// <typeparam name="T">Type of the expected exception</typeparam>
+ /// <param name="code">A TestSnippet delegate</param>
+ public static T Throws<T>(TestDelegate code) where T : Exception
+ {
+ return Throws<T>(code, string.Empty, null);
+ }
+#endif
+ #endregion
+
+ #region Catch
+ /// <summary>
+ /// Verifies that a delegate throws an exception when called
+ /// and returns it.
+ /// </summary>
+ /// <param name="code">A TestDelegate</param>
+ /// <param name="message">The message that will be displayed on failure</param>
+ /// <param name="args">Arguments to be used in formatting the message</param>
+ public static Exception Catch(TestDelegate code, string message, params object[] args)
+ {
+ return Throws(new InstanceOfTypeConstraint(typeof(Exception)), code, message, args);
+ }
+
+ /// <summary>
+ /// Verifies that a delegate throws an exception when called
+ /// and returns it.
+ /// </summary>
+ /// <param name="code">A TestDelegate</param>
+ /// <param name="message">The message that will be displayed on failure</param>
+ public static Exception Catch(TestDelegate code, string message)
+ {
+ return Throws(new InstanceOfTypeConstraint(typeof(Exception)), code, message);
+ }
+
+ /// <summary>
+ /// Verifies that a delegate throws an exception when called
+ /// and returns it.
+ /// </summary>
+ /// <param name="code">A TestDelegate</param>
+ public static Exception Catch(TestDelegate code)
+ {
+ return Throws(new InstanceOfTypeConstraint(typeof(Exception)), code);
+ }
+
+ /// <summary>
+ /// Verifies that a delegate throws an exception of a certain Type
+ /// or one derived from it when called and returns it.
+ /// </summary>
+ /// <param name="expectedExceptionType">The expected Exception Type</param>
+ /// <param name="code">A TestDelegate</param>
+ /// <param name="message">The message that will be displayed on failure</param>
+ /// <param name="args">Arguments to be used in formatting the message</param>
+ public static Exception Catch(Type expectedExceptionType, TestDelegate code, string message, params object[] args)
+ {
+ return Throws(new InstanceOfTypeConstraint(expectedExceptionType), code, message, args);
+ }
+
+ /// <summary>
+ /// Verifies that a delegate throws an exception of a certain Type
+ /// or one derived from it when called and returns it.
+ /// </summary>
+ /// <param name="expectedExceptionType">The expected Exception Type</param>
+ /// <param name="code">A TestDelegate</param>
+ /// <param name="message">The message that will be displayed on failure</param>
+ public static Exception Catch(Type expectedExceptionType, TestDelegate code, string message)
+ {
+ return Throws(new InstanceOfTypeConstraint(expectedExceptionType), code, message);
+ }
+
+ /// <summary>
+ /// Verifies that a delegate throws an exception of a certain Type
+ /// or one derived from it when called and returns it.
+ /// </summary>
+ /// <param name="expectedExceptionType">The expected Exception Type</param>
+ /// <param name="code">A TestDelegate</param>
+ public static Exception Catch(Type expectedExceptionType, TestDelegate code)
+ {
+ return Throws(new InstanceOfTypeConstraint(expectedExceptionType), code);
+ }
+ #endregion
+
+ #region Catch<T>
+#if CLR_2_0 || CLR_4_0
+ /// <summary>
+ /// Verifies that a delegate throws an exception of a certain Type
+ /// or one derived from it when called and returns it.
+ /// </summary>
+ /// <param name="code">A TestDelegate</param>
+ /// <param name="message">The message that will be displayed on failure</param>
+ /// <param name="args">Arguments to be used in formatting the message</param>
+ public static T Catch<T>(TestDelegate code, string message, params object[] args) where T : System.Exception
+ {
+ return (T)Throws(new InstanceOfTypeConstraint(typeof(T)), code, message, args);
+ }
+
+ /// <summary>
+ /// Verifies that a delegate throws an exception of a certain Type
+ /// or one derived from it when called and returns it.
+ /// </summary>
+ /// <param name="code">A TestDelegate</param>
+ /// <param name="message">The message that will be displayed on failure</param>
+ public static T Catch<T>(TestDelegate code, string message) where T : System.Exception
+ {
+ return (T)Throws(new InstanceOfTypeConstraint(typeof(T)), code, message);
+ }
+
+ /// <summary>
+ /// Verifies that a delegate throws an exception of a certain Type
+ /// or one derived from it when called and returns it.
+ /// </summary>
+ /// <param name="code">A TestDelegate</param>
+ public static T Catch<T>(TestDelegate code) where T : System.Exception
+ {
+ return (T)Throws(new InstanceOfTypeConstraint(typeof(T)), code);
+ }
+#endif
+ #endregion
+
+ #region DoesNotThrow
+
+ /// <summary>
+ /// Verifies that a delegate does not throw an exception
+ /// </summary>
+ /// <param name="code">A TestSnippet delegate</param>
+ /// <param name="message">The message that will be displayed on failure</param>
+ /// <param name="args">Arguments to be used in formatting the message</param>
+ public static void DoesNotThrow(TestDelegate code, string message, params object[] args)
+ {
+ try
+ {
+ code();
+ }
+ catch (Exception ex)
+ {
+ TextMessageWriter writer = new TextMessageWriter(message, args);
+ writer.WriteLine("Unexpected exception: {0}", ex.GetType());
+ Assert.Fail(writer.ToString());
+ }
+ }
+
+ /// <summary>
+ /// Verifies that a delegate does not throw an exception.
+ /// </summary>
+ /// <param name="code">A TestSnippet delegate</param>
+ /// <param name="message">The message that will be displayed on failure</param>
+ public static void DoesNotThrow(TestDelegate code, string message)
+ {
+ DoesNotThrow(code, message, null);
+ }
+
+ /// <summary>
+ /// Verifies that a delegate does not throw an exception.
+ /// </summary>
+ /// <param name="code">A TestSnippet delegate</param>
+ public static void DoesNotThrow(TestDelegate code)
+ {
+ DoesNotThrow(code, string.Empty, null);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region True
+
+ /// <summary>
+ /// Asserts that a condition is true. If the condition is false the method throws
+ /// an <see cref="AssertionException"/>.
+ /// </summary>
+ /// <param name="condition">The evaluated condition</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void True(bool condition, string message, params object[] args)
+ {
+ Assert.That(condition, Is.True ,message, args);
+ }
+ /// <summary>
+ /// Asserts that a condition is true. If the condition is false the method throws
+ /// an <see cref="AssertionException"/>.
+ /// </summary>
+ /// <param name="condition">The evaluated condition</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void True(bool condition, string message)
+ {
+ Assert.That(condition, Is.True ,message, null);
+ }
+ /// <summary>
+ /// Asserts that a condition is true. If the condition is false the method throws
+ /// an <see cref="AssertionException"/>.
+ /// </summary>
+ /// <param name="condition">The evaluated condition</param>
+ public static void True(bool condition)
+ {
+ Assert.That(condition, Is.True ,null, null);
+ }
+
+ /// <summary>
+ /// Asserts that a condition is true. If the condition is false the method throws
+ /// an <see cref="AssertionException"/>.
+ /// </summary>
+ /// <param name="condition">The evaluated condition</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void IsTrue(bool condition, string message, params object[] args)
+ {
+ Assert.That(condition, Is.True ,message, args);
+ }
+ /// <summary>
+ /// Asserts that a condition is true. If the condition is false the method throws
+ /// an <see cref="AssertionException"/>.
+ /// </summary>
+ /// <param name="condition">The evaluated condition</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void IsTrue(bool condition, string message)
+ {
+ Assert.That(condition, Is.True ,message, null);
+ }
+ /// <summary>
+ /// Asserts that a condition is true. If the condition is false the method throws
+ /// an <see cref="AssertionException"/>.
+ /// </summary>
+ /// <param name="condition">The evaluated condition</param>
+ public static void IsTrue(bool condition)
+ {
+ Assert.That(condition, Is.True ,null, null);
+ }
+
+ #endregion
+
+ #region False
+
+ /// <summary>
+ /// Asserts that a condition is false. If the condition is true the method throws
+ /// an <see cref="AssertionException"/>.
+ /// </summary>
+ /// <param name="condition">The evaluated condition</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void False(bool condition, string message, params object[] args)
+ {
+ Assert.That(condition, Is.False ,message, args);
+ }
+ /// <summary>
+ /// Asserts that a condition is false. If the condition is true the method throws
+ /// an <see cref="AssertionException"/>.
+ /// </summary>
+ /// <param name="condition">The evaluated condition</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void False(bool condition, string message)
+ {
+ Assert.That(condition, Is.False ,message, null);
+ }
+ /// <summary>
+ /// Asserts that a condition is false. If the condition is true the method throws
+ /// an <see cref="AssertionException"/>.
+ /// </summary>
+ /// <param name="condition">The evaluated condition</param>
+ public static void False(bool condition)
+ {
+ Assert.That(condition, Is.False ,null, null);
+ }
+
+ /// <summary>
+ /// Asserts that a condition is false. If the condition is true the method throws
+ /// an <see cref="AssertionException"/>.
+ /// </summary>
+ /// <param name="condition">The evaluated condition</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void IsFalse(bool condition, string message, params object[] args)
+ {
+ Assert.That(condition, Is.False ,message, args);
+ }
+ /// <summary>
+ /// Asserts that a condition is false. If the condition is true the method throws
+ /// an <see cref="AssertionException"/>.
+ /// </summary>
+ /// <param name="condition">The evaluated condition</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void IsFalse(bool condition, string message)
+ {
+ Assert.That(condition, Is.False ,message, null);
+ }
+ /// <summary>
+ /// Asserts that a condition is false. If the condition is true the method throws
+ /// an <see cref="AssertionException"/>.
+ /// </summary>
+ /// <param name="condition">The evaluated condition</param>
+ public static void IsFalse(bool condition)
+ {
+ Assert.That(condition, Is.False ,null, null);
+ }
+
+ #endregion
+
+ #region NotNull
+
+ /// <summary>
+ /// Verifies that the object that is passed in is not equal to <code>null</code>
+ /// If the object is <code>null</code> then an <see cref="AssertionException"/>
+ /// is thrown.
+ /// </summary>
+ /// <param name="anObject">The object that is to be tested</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void NotNull(object anObject, string message, params object[] args)
+ {
+ Assert.That(anObject, Is.Not.Null ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the object that is passed in is not equal to <code>null</code>
+ /// If the object is <code>null</code> then an <see cref="AssertionException"/>
+ /// is thrown.
+ /// </summary>
+ /// <param name="anObject">The object that is to be tested</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void NotNull(object anObject, string message)
+ {
+ Assert.That(anObject, Is.Not.Null ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the object that is passed in is not equal to <code>null</code>
+ /// If the object is <code>null</code> then an <see cref="AssertionException"/>
+ /// is thrown.
+ /// </summary>
+ /// <param name="anObject">The object that is to be tested</param>
+ public static void NotNull(object anObject)
+ {
+ Assert.That(anObject, Is.Not.Null ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the object that is passed in is not equal to <code>null</code>
+ /// If the object is <code>null</code> then an <see cref="AssertionException"/>
+ /// is thrown.
+ /// </summary>
+ /// <param name="anObject">The object that is to be tested</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void IsNotNull(object anObject, string message, params object[] args)
+ {
+ Assert.That(anObject, Is.Not.Null ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the object that is passed in is not equal to <code>null</code>
+ /// If the object is <code>null</code> then an <see cref="AssertionException"/>
+ /// is thrown.
+ /// </summary>
+ /// <param name="anObject">The object that is to be tested</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void IsNotNull(object anObject, string message)
+ {
+ Assert.That(anObject, Is.Not.Null ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the object that is passed in is not equal to <code>null</code>
+ /// If the object is <code>null</code> then an <see cref="AssertionException"/>
+ /// is thrown.
+ /// </summary>
+ /// <param name="anObject">The object that is to be tested</param>
+ public static void IsNotNull(object anObject)
+ {
+ Assert.That(anObject, Is.Not.Null ,null, null);
+ }
+
+ #endregion
+
+ #region Null
+
+ /// <summary>
+ /// Verifies that the object that is passed in is equal to <code>null</code>
+ /// If the object is not <code>null</code> then an <see cref="AssertionException"/>
+ /// is thrown.
+ /// </summary>
+ /// <param name="anObject">The object that is to be tested</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void Null(object anObject, string message, params object[] args)
+ {
+ Assert.That(anObject, Is.Null ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the object that is passed in is equal to <code>null</code>
+ /// If the object is not <code>null</code> then an <see cref="AssertionException"/>
+ /// is thrown.
+ /// </summary>
+ /// <param name="anObject">The object that is to be tested</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void Null(object anObject, string message)
+ {
+ Assert.That(anObject, Is.Null ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the object that is passed in is equal to <code>null</code>
+ /// If the object is not <code>null</code> then an <see cref="AssertionException"/>
+ /// is thrown.
+ /// </summary>
+ /// <param name="anObject">The object that is to be tested</param>
+ public static void Null(object anObject)
+ {
+ Assert.That(anObject, Is.Null ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the object that is passed in is equal to <code>null</code>
+ /// If the object is not <code>null</code> then an <see cref="AssertionException"/>
+ /// is thrown.
+ /// </summary>
+ /// <param name="anObject">The object that is to be tested</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void IsNull(object anObject, string message, params object[] args)
+ {
+ Assert.That(anObject, Is.Null ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the object that is passed in is equal to <code>null</code>
+ /// If the object is not <code>null</code> then an <see cref="AssertionException"/>
+ /// is thrown.
+ /// </summary>
+ /// <param name="anObject">The object that is to be tested</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void IsNull(object anObject, string message)
+ {
+ Assert.That(anObject, Is.Null ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the object that is passed in is equal to <code>null</code>
+ /// If the object is not <code>null</code> then an <see cref="AssertionException"/>
+ /// is thrown.
+ /// </summary>
+ /// <param name="anObject">The object that is to be tested</param>
+ public static void IsNull(object anObject)
+ {
+ Assert.That(anObject, Is.Null ,null, null);
+ }
+
+ #endregion
+
+ #region IsNaN
+
+#if !NUNITLITE
+ /// <summary>
+ /// Verifies that the double that is passed in is an <code>NaN</code> value.
+ /// If the object is not <code>NaN</code> then an <see cref="AssertionException"/>
+ /// is thrown.
+ /// </summary>
+ /// <param name="aDouble">The value that is to be tested</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void IsNaN(double aDouble, string message, params object[] args)
+ {
+ Assert.That(aDouble, Is.NaN ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the double that is passed in is an <code>NaN</code> value.
+ /// If the object is not <code>NaN</code> then an <see cref="AssertionException"/>
+ /// is thrown.
+ /// </summary>
+ /// <param name="aDouble">The value that is to be tested</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void IsNaN(double aDouble, string message)
+ {
+ Assert.That(aDouble, Is.NaN ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the double that is passed in is an <code>NaN</code> value.
+ /// If the object is not <code>NaN</code> then an <see cref="AssertionException"/>
+ /// is thrown.
+ /// </summary>
+ /// <param name="aDouble">The value that is to be tested</param>
+ public static void IsNaN(double aDouble)
+ {
+ Assert.That(aDouble, Is.NaN ,null, null);
+ }
+
+#if CLR_2_0 || CLR_4_0
+ /// <summary>
+ /// Verifies that the double that is passed in is an <code>NaN</code> value.
+ /// If the object is not <code>NaN</code> then an <see cref="AssertionException"/>
+ /// is thrown.
+ /// </summary>
+ /// <param name="aDouble">The value that is to be tested</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void IsNaN(double? aDouble, string message, params object[] args)
+ {
+ Assert.That(aDouble, Is.NaN ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the double that is passed in is an <code>NaN</code> value.
+ /// If the object is not <code>NaN</code> then an <see cref="AssertionException"/>
+ /// is thrown.
+ /// </summary>
+ /// <param name="aDouble">The value that is to be tested</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void IsNaN(double? aDouble, string message)
+ {
+ Assert.That(aDouble, Is.NaN ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the double that is passed in is an <code>NaN</code> value.
+ /// If the object is not <code>NaN</code> then an <see cref="AssertionException"/>
+ /// is thrown.
+ /// </summary>
+ /// <param name="aDouble">The value that is to be tested</param>
+ public static void IsNaN(double? aDouble)
+ {
+ Assert.That(aDouble, Is.NaN ,null, null);
+ }
+#endif
+#endif
+
+ #endregion
+
+ #region IsEmpty
+
+#if !NUNITLITE
+ /// <summary>
+ /// Assert that a string is empty - that is equal to string.Empty
+ /// </summary>
+ /// <param name="aString">The string to be tested</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void IsEmpty(string aString, string message, params object[] args)
+ {
+ Assert.That(aString, new EmptyStringConstraint() ,message, args);
+ }
+ /// <summary>
+ /// Assert that a string is empty - that is equal to string.Empty
+ /// </summary>
+ /// <param name="aString">The string to be tested</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void IsEmpty(string aString, string message)
+ {
+ Assert.That(aString, new EmptyStringConstraint() ,message, null);
+ }
+ /// <summary>
+ /// Assert that a string is empty - that is equal to string.Empty
+ /// </summary>
+ /// <param name="aString">The string to be tested</param>
+ public static void IsEmpty(string aString)
+ {
+ Assert.That(aString, new EmptyStringConstraint() ,null, null);
+ }
+#endif
+
+ #endregion
+
+ #region IsEmpty
+
+#if !NUNITLITE
+ /// <summary>
+ /// Assert that an array, list or other collection is empty
+ /// </summary>
+ /// <param name="collection">An array, list or other collection implementing ICollection</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void IsEmpty(ICollection collection, string message, params object[] args)
+ {
+ Assert.That(collection, new EmptyCollectionConstraint() ,message, args);
+ }
+ /// <summary>
+ /// Assert that an array, list or other collection is empty
+ /// </summary>
+ /// <param name="collection">An array, list or other collection implementing ICollection</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void IsEmpty(ICollection collection, string message)
+ {
+ Assert.That(collection, new EmptyCollectionConstraint() ,message, null);
+ }
+ /// <summary>
+ /// Assert that an array, list or other collection is empty
+ /// </summary>
+ /// <param name="collection">An array, list or other collection implementing ICollection</param>
+ public static void IsEmpty(ICollection collection)
+ {
+ Assert.That(collection, new EmptyCollectionConstraint() ,null, null);
+ }
+#endif
+
+ #endregion
+
+ #region IsNotEmpty
+
+#if !NUNITLITE
+ /// <summary>
+ /// Assert that a string is not empty - that is not equal to string.Empty
+ /// </summary>
+ /// <param name="aString">The string to be tested</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void IsNotEmpty(string aString, string message, params object[] args)
+ {
+ Assert.That(aString, Is.Not.Empty ,message, args);
+ }
+ /// <summary>
+ /// Assert that a string is not empty - that is not equal to string.Empty
+ /// </summary>
+ /// <param name="aString">The string to be tested</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void IsNotEmpty(string aString, string message)
+ {
+ Assert.That(aString, Is.Not.Empty ,message, null);
+ }
+ /// <summary>
+ /// Assert that a string is not empty - that is not equal to string.Empty
+ /// </summary>
+ /// <param name="aString">The string to be tested</param>
+ public static void IsNotEmpty(string aString)
+ {
+ Assert.That(aString, Is.Not.Empty ,null, null);
+ }
+#endif
+
+ #endregion
+
+ #region IsNotEmpty
+
+#if !NUNITLITE
+ /// <summary>
+ /// Assert that an array, list or other collection is not empty
+ /// </summary>
+ /// <param name="collection">An array, list or other collection implementing ICollection</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void IsNotEmpty(ICollection collection, string message, params object[] args)
+ {
+ Assert.That(collection, Is.Not.Empty ,message, args);
+ }
+ /// <summary>
+ /// Assert that an array, list or other collection is not empty
+ /// </summary>
+ /// <param name="collection">An array, list or other collection implementing ICollection</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void IsNotEmpty(ICollection collection, string message)
+ {
+ Assert.That(collection, Is.Not.Empty ,message, null);
+ }
+ /// <summary>
+ /// Assert that an array, list or other collection is not empty
+ /// </summary>
+ /// <param name="collection">An array, list or other collection implementing ICollection</param>
+ public static void IsNotEmpty(ICollection collection)
+ {
+ Assert.That(collection, Is.Not.Empty ,null, null);
+ }
+#endif
+
+ #endregion
+
+ #region IsNullOrEmpty
+
+#if !NUNITLITE
+ /// <summary>
+ /// Assert that a string is either null or equal to string.Empty
+ /// </summary>
+ /// <param name="aString">The string to be tested</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void IsNullOrEmpty(string aString, string message, params object[] args)
+ {
+ Assert.That(aString, new NullOrEmptyStringConstraint() ,message, args);
+ }
+ /// <summary>
+ /// Assert that a string is either null or equal to string.Empty
+ /// </summary>
+ /// <param name="aString">The string to be tested</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void IsNullOrEmpty(string aString, string message)
+ {
+ Assert.That(aString, new NullOrEmptyStringConstraint() ,message, null);
+ }
+ /// <summary>
+ /// Assert that a string is either null or equal to string.Empty
+ /// </summary>
+ /// <param name="aString">The string to be tested</param>
+ public static void IsNullOrEmpty(string aString)
+ {
+ Assert.That(aString, new NullOrEmptyStringConstraint() ,null, null);
+ }
+#endif
+
+ #endregion
+
+ #region IsNotNullOrEmpty
+
+#if !NUNITLITE
+ /// <summary>
+ /// Assert that a string is not null or empty
+ /// </summary>
+ /// <param name="aString">The string to be tested</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void IsNotNullOrEmpty(string aString, string message, params object[] args)
+ {
+ Assert.That(aString, new NotConstraint( new NullOrEmptyStringConstraint()) ,message, args);
+ }
+ /// <summary>
+ /// Assert that a string is not null or empty
+ /// </summary>
+ /// <param name="aString">The string to be tested</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void IsNotNullOrEmpty(string aString, string message)
+ {
+ Assert.That(aString, new NotConstraint( new NullOrEmptyStringConstraint()) ,message, null);
+ }
+ /// <summary>
+ /// Assert that a string is not null or empty
+ /// </summary>
+ /// <param name="aString">The string to be tested</param>
+ public static void IsNotNullOrEmpty(string aString)
+ {
+ Assert.That(aString, new NotConstraint( new NullOrEmptyStringConstraint()) ,null, null);
+ }
+#endif
+
+ #endregion
+
+ #region IsAssignableFrom
+
+#if !NUNITLITE
+ /// <summary>
+ /// Asserts that an object may be assigned a value of a given Type.
+ /// </summary>
+ /// <param name="expected">The expected Type.</param>
+ /// <param name="actual">The object under examination</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void IsAssignableFrom(Type expected, object actual, string message, params object[] args)
+ {
+ Assert.That(actual, Is.AssignableFrom(expected) ,message, args);
+ }
+ /// <summary>
+ /// Asserts that an object may be assigned a value of a given Type.
+ /// </summary>
+ /// <param name="expected">The expected Type.</param>
+ /// <param name="actual">The object under examination</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void IsAssignableFrom(Type expected, object actual, string message)
+ {
+ Assert.That(actual, Is.AssignableFrom(expected) ,message, null);
+ }
+ /// <summary>
+ /// Asserts that an object may be assigned a value of a given Type.
+ /// </summary>
+ /// <param name="expected">The expected Type.</param>
+ /// <param name="actual">The object under examination</param>
+ public static void IsAssignableFrom(Type expected, object actual)
+ {
+ Assert.That(actual, Is.AssignableFrom(expected) ,null, null);
+ }
+#endif
+
+ #endregion
+
+ #region IsAssignableFrom<T>
+
+#if !NUNITLITE
+#if CLR_2_0 || CLR_4_0
+ /// <summary>
+ /// Asserts that an object may be assigned a value of a given Type.
+ /// </summary>
+ /// <typeparam name="T">The expected Type.</typeparam>
+ /// <param name="actual">The object under examination</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void IsAssignableFrom<T>(object actual, string message, params object[] args)
+ {
+ Assert.That(actual, Is.AssignableFrom(typeof(T)) ,message, args);
+ }
+ /// <summary>
+ /// Asserts that an object may be assigned a value of a given Type.
+ /// </summary>
+ /// <typeparam name="T">The expected Type.</typeparam>
+ /// <param name="actual">The object under examination</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void IsAssignableFrom<T>(object actual, string message)
+ {
+ Assert.That(actual, Is.AssignableFrom(typeof(T)) ,message, null);
+ }
+ /// <summary>
+ /// Asserts that an object may be assigned a value of a given Type.
+ /// </summary>
+ /// <typeparam name="T">The expected Type.</typeparam>
+ /// <param name="actual">The object under examination</param>
+ public static void IsAssignableFrom<T>(object actual)
+ {
+ Assert.That(actual, Is.AssignableFrom(typeof(T)) ,null, null);
+ }
+#endif
+#endif
+
+ #endregion
+
+ #region IsNotAssignableFrom
+
+#if !NUNITLITE
+ /// <summary>
+ /// Asserts that an object may not be assigned a value of a given Type.
+ /// </summary>
+ /// <param name="expected">The expected Type.</param>
+ /// <param name="actual">The object under examination</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void IsNotAssignableFrom(Type expected, object actual, string message, params object[] args)
+ {
+ Assert.That(actual, Is.Not.AssignableFrom(expected) ,message, args);
+ }
+ /// <summary>
+ /// Asserts that an object may not be assigned a value of a given Type.
+ /// </summary>
+ /// <param name="expected">The expected Type.</param>
+ /// <param name="actual">The object under examination</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void IsNotAssignableFrom(Type expected, object actual, string message)
+ {
+ Assert.That(actual, Is.Not.AssignableFrom(expected) ,message, null);
+ }
+ /// <summary>
+ /// Asserts that an object may not be assigned a value of a given Type.
+ /// </summary>
+ /// <param name="expected">The expected Type.</param>
+ /// <param name="actual">The object under examination</param>
+ public static void IsNotAssignableFrom(Type expected, object actual)
+ {
+ Assert.That(actual, Is.Not.AssignableFrom(expected) ,null, null);
+ }
+#endif
+
+ #endregion
+
+ #region IsNotAssignableFrom<T>
+
+#if !NUNITLITE
+#if CLR_2_0 || CLR_4_0
+ /// <summary>
+ /// Asserts that an object may not be assigned a value of a given Type.
+ /// </summary>
+ /// <typeparam name="T">The expected Type.</typeparam>
+ /// <param name="actual">The object under examination</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void IsNotAssignableFrom<T>(object actual, string message, params object[] args)
+ {
+ Assert.That(actual, Is.Not.AssignableFrom(typeof(T)) ,message, args);
+ }
+ /// <summary>
+ /// Asserts that an object may not be assigned a value of a given Type.
+ /// </summary>
+ /// <typeparam name="T">The expected Type.</typeparam>
+ /// <param name="actual">The object under examination</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void IsNotAssignableFrom<T>(object actual, string message)
+ {
+ Assert.That(actual, Is.Not.AssignableFrom(typeof(T)) ,message, null);
+ }
+ /// <summary>
+ /// Asserts that an object may not be assigned a value of a given Type.
+ /// </summary>
+ /// <typeparam name="T">The expected Type.</typeparam>
+ /// <param name="actual">The object under examination</param>
+ public static void IsNotAssignableFrom<T>(object actual)
+ {
+ Assert.That(actual, Is.Not.AssignableFrom(typeof(T)) ,null, null);
+ }
+#endif
+#endif
+
+ #endregion
+
+ #region IsInstanceOf
+
+#if !NUNITLITE
+ /// <summary>
+ /// Asserts that an object is an instance of a given type.
+ /// </summary>
+ /// <param name="expected">The expected Type</param>
+ /// <param name="actual">The object being examined</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void IsInstanceOf(Type expected, object actual, string message, params object[] args)
+ {
+ Assert.That(actual, Is.InstanceOf(expected) ,message, args);
+ }
+ /// <summary>
+ /// Asserts that an object is an instance of a given type.
+ /// </summary>
+ /// <param name="expected">The expected Type</param>
+ /// <param name="actual">The object being examined</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void IsInstanceOf(Type expected, object actual, string message)
+ {
+ Assert.That(actual, Is.InstanceOf(expected) ,message, null);
+ }
+ /// <summary>
+ /// Asserts that an object is an instance of a given type.
+ /// </summary>
+ /// <param name="expected">The expected Type</param>
+ /// <param name="actual">The object being examined</param>
+ public static void IsInstanceOf(Type expected, object actual)
+ {
+ Assert.That(actual, Is.InstanceOf(expected) ,null, null);
+ }
+#endif
+
+ #endregion
+
+ #region IsInstanceOf<T>
+
+#if !NUNITLITE
+#if CLR_2_0 || CLR_4_0
+ /// <summary>
+ /// Asserts that an object is an instance of a given type.
+ /// </summary>
+ /// <typeparam name="T">The expected Type</typeparam>
+ /// <param name="actual">The object being examined</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void IsInstanceOf<T>(object actual, string message, params object[] args)
+ {
+ Assert.That(actual, Is.InstanceOf(typeof(T)) ,message, args);
+ }
+ /// <summary>
+ /// Asserts that an object is an instance of a given type.
+ /// </summary>
+ /// <typeparam name="T">The expected Type</typeparam>
+ /// <param name="actual">The object being examined</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void IsInstanceOf<T>(object actual, string message)
+ {
+ Assert.That(actual, Is.InstanceOf(typeof(T)) ,message, null);
+ }
+ /// <summary>
+ /// Asserts that an object is an instance of a given type.
+ /// </summary>
+ /// <typeparam name="T">The expected Type</typeparam>
+ /// <param name="actual">The object being examined</param>
+ public static void IsInstanceOf<T>(object actual)
+ {
+ Assert.That(actual, Is.InstanceOf(typeof(T)) ,null, null);
+ }
+#endif
+#endif
+
+ #endregion
+
+ #region IsNotInstanceOf
+
+#if !NUNITLITE
+ /// <summary>
+ /// Asserts that an object is not an instance of a given type.
+ /// </summary>
+ /// <param name="expected">The expected Type</param>
+ /// <param name="actual">The object being examined</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void IsNotInstanceOf(Type expected, object actual, string message, params object[] args)
+ {
+ Assert.That(actual, Is.Not.InstanceOf(expected) ,message, args);
+ }
+ /// <summary>
+ /// Asserts that an object is not an instance of a given type.
+ /// </summary>
+ /// <param name="expected">The expected Type</param>
+ /// <param name="actual">The object being examined</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void IsNotInstanceOf(Type expected, object actual, string message)
+ {
+ Assert.That(actual, Is.Not.InstanceOf(expected) ,message, null);
+ }
+ /// <summary>
+ /// Asserts that an object is not an instance of a given type.
+ /// </summary>
+ /// <param name="expected">The expected Type</param>
+ /// <param name="actual">The object being examined</param>
+ public static void IsNotInstanceOf(Type expected, object actual)
+ {
+ Assert.That(actual, Is.Not.InstanceOf(expected) ,null, null);
+ }
+#endif
+
+ #endregion
+
+ #region IsNotInstanceOf<T>
+
+#if !NUNITLITE
+#if CLR_2_0 || CLR_4_0
+ /// <summary>
+ /// Asserts that an object is not an instance of a given type.
+ /// </summary>
+ /// <typeparam name="T">The expected Type</typeparam>
+ /// <param name="actual">The object being examined</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void IsNotInstanceOf<T>(object actual, string message, params object[] args)
+ {
+ Assert.That(actual, Is.Not.InstanceOf(typeof(T)) ,message, args);
+ }
+ /// <summary>
+ /// Asserts that an object is not an instance of a given type.
+ /// </summary>
+ /// <typeparam name="T">The expected Type</typeparam>
+ /// <param name="actual">The object being examined</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void IsNotInstanceOf<T>(object actual, string message)
+ {
+ Assert.That(actual, Is.Not.InstanceOf(typeof(T)) ,message, null);
+ }
+ /// <summary>
+ /// Asserts that an object is not an instance of a given type.
+ /// </summary>
+ /// <typeparam name="T">The expected Type</typeparam>
+ /// <param name="actual">The object being examined</param>
+ public static void IsNotInstanceOf<T>(object actual)
+ {
+ Assert.That(actual, Is.Not.InstanceOf(typeof(T)) ,null, null);
+ }
+#endif
+#endif
+
+ #endregion
+
+ #region AreEqual
+
+ /// <summary>
+ /// Verifies that two values are equal. If they are not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void AreEqual(int expected, int actual, string message, params object[] args)
+ {
+ Assert.That(actual, Is.EqualTo(expected) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that two values are equal. If they are not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void AreEqual(int expected, int actual, string message)
+ {
+ Assert.That(actual, Is.EqualTo(expected) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that two values are equal. If they are not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ public static void AreEqual(int expected, int actual)
+ {
+ Assert.That(actual, Is.EqualTo(expected) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that two values are equal. If they are not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void AreEqual(long expected, long actual, string message, params object[] args)
+ {
+ Assert.That(actual, Is.EqualTo(expected) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that two values are equal. If they are not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void AreEqual(long expected, long actual, string message)
+ {
+ Assert.That(actual, Is.EqualTo(expected) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that two values are equal. If they are not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ public static void AreEqual(long expected, long actual)
+ {
+ Assert.That(actual, Is.EqualTo(expected) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that two values are equal. If they are not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ [CLSCompliant(false)]
+ public static void AreEqual(uint expected, uint actual, string message, params object[] args)
+ {
+ Assert.That(actual, Is.EqualTo(expected) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that two values are equal. If they are not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ [CLSCompliant(false)]
+ public static void AreEqual(uint expected, uint actual, string message)
+ {
+ Assert.That(actual, Is.EqualTo(expected) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that two values are equal. If they are not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ [CLSCompliant(false)]
+ public static void AreEqual(uint expected, uint actual)
+ {
+ Assert.That(actual, Is.EqualTo(expected) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that two values are equal. If they are not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ [CLSCompliant(false)]
+ public static void AreEqual(ulong expected, ulong actual, string message, params object[] args)
+ {
+ Assert.That(actual, Is.EqualTo(expected) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that two values are equal. If they are not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ [CLSCompliant(false)]
+ public static void AreEqual(ulong expected, ulong actual, string message)
+ {
+ Assert.That(actual, Is.EqualTo(expected) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that two values are equal. If they are not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ [CLSCompliant(false)]
+ public static void AreEqual(ulong expected, ulong actual)
+ {
+ Assert.That(actual, Is.EqualTo(expected) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that two values are equal. If they are not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void AreEqual(decimal expected, decimal actual, string message, params object[] args)
+ {
+ Assert.That(actual, Is.EqualTo(expected) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that two values are equal. If they are not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void AreEqual(decimal expected, decimal actual, string message)
+ {
+ Assert.That(actual, Is.EqualTo(expected) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that two values are equal. If they are not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ public static void AreEqual(decimal expected, decimal actual)
+ {
+ Assert.That(actual, Is.EqualTo(expected) ,null, null);
+ }
+
+ #endregion
+
+ #region AreEqual
+
+ /// <summary>
+ /// Verifies that two doubles are equal considering a delta. If the
+ /// expected value is infinity then the delta value is ignored. If
+ /// they are not equal then an <see cref="AssertionException"/> is
+ /// thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="delta">The maximum acceptable difference between the
+ /// the expected and the actual</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void AreEqual(double expected, double actual, double delta, string message, params object[] args)
+ {
+ AssertDoublesAreEqual(expected, actual, delta ,message, args);
+ }
+ /// <summary>
+ /// Verifies that two doubles are equal considering a delta. If the
+ /// expected value is infinity then the delta value is ignored. If
+ /// they are not equal then an <see cref="AssertionException"/> is
+ /// thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="delta">The maximum acceptable difference between the
+ /// the expected and the actual</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void AreEqual(double expected, double actual, double delta, string message)
+ {
+ AssertDoublesAreEqual(expected, actual, delta ,message, null);
+ }
+ /// <summary>
+ /// Verifies that two doubles are equal considering a delta. If the
+ /// expected value is infinity then the delta value is ignored. If
+ /// they are not equal then an <see cref="AssertionException"/> is
+ /// thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="delta">The maximum acceptable difference between the
+ /// the expected and the actual</param>
+ public static void AreEqual(double expected, double actual, double delta)
+ {
+ AssertDoublesAreEqual(expected, actual, delta ,null, null);
+ }
+
+#if CLR_2_0 || CLR_4_0
+ /// <summary>
+ /// Verifies that two doubles are equal considering a delta. If the
+ /// expected value is infinity then the delta value is ignored. If
+ /// they are not equal then an <see cref="AssertionException"/> is
+ /// thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="delta">The maximum acceptable difference between the
+ /// the expected and the actual</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void AreEqual(double expected, double? actual, double delta, string message, params object[] args)
+ {
+ AssertDoublesAreEqual(expected, (double)actual, delta ,message, args);
+ }
+ /// <summary>
+ /// Verifies that two doubles are equal considering a delta. If the
+ /// expected value is infinity then the delta value is ignored. If
+ /// they are not equal then an <see cref="AssertionException"/> is
+ /// thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="delta">The maximum acceptable difference between the
+ /// the expected and the actual</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void AreEqual(double expected, double? actual, double delta, string message)
+ {
+ AssertDoublesAreEqual(expected, (double)actual, delta ,message, null);
+ }
+ /// <summary>
+ /// Verifies that two doubles are equal considering a delta. If the
+ /// expected value is infinity then the delta value is ignored. If
+ /// they are not equal then an <see cref="AssertionException"/> is
+ /// thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="delta">The maximum acceptable difference between the
+ /// the expected and the actual</param>
+ public static void AreEqual(double expected, double? actual, double delta)
+ {
+ AssertDoublesAreEqual(expected, (double)actual, delta ,null, null);
+ }
+#endif
+
+ #endregion
+
+ #region AreEqual
+
+ /// <summary>
+ /// Verifies that two objects are equal. Two objects are considered
+ /// equal if both are null, or if both have the same value. NUnit
+ /// has special semantics for some object types.
+ /// If they are not equal an <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The value that is expected</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void AreEqual(object expected, object actual, string message, params object[] args)
+ {
+ Assert.That(actual, Is.EqualTo(expected) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that two objects are equal. Two objects are considered
+ /// equal if both are null, or if both have the same value. NUnit
+ /// has special semantics for some object types.
+ /// If they are not equal an <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The value that is expected</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void AreEqual(object expected, object actual, string message)
+ {
+ Assert.That(actual, Is.EqualTo(expected) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that two objects are equal. Two objects are considered
+ /// equal if both are null, or if both have the same value. NUnit
+ /// has special semantics for some object types.
+ /// If they are not equal an <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The value that is expected</param>
+ /// <param name="actual">The actual value</param>
+ public static void AreEqual(object expected, object actual)
+ {
+ Assert.That(actual, Is.EqualTo(expected) ,null, null);
+ }
+
+ #endregion
+
+ #region AreNotEqual
+
+ /// <summary>
+ /// Verifies that two values are not equal. If they are equal, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void AreNotEqual(int expected, int actual, string message, params object[] args)
+ {
+ Assert.That(actual, Is.Not.EqualTo(expected) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that two values are not equal. If they are equal, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void AreNotEqual(int expected, int actual, string message)
+ {
+ Assert.That(actual, Is.Not.EqualTo(expected) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that two values are not equal. If they are equal, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ public static void AreNotEqual(int expected, int actual)
+ {
+ Assert.That(actual, Is.Not.EqualTo(expected) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that two values are not equal. If they are equal, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void AreNotEqual(long expected, long actual, string message, params object[] args)
+ {
+ Assert.That(actual, Is.Not.EqualTo(expected) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that two values are not equal. If they are equal, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void AreNotEqual(long expected, long actual, string message)
+ {
+ Assert.That(actual, Is.Not.EqualTo(expected) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that two values are not equal. If they are equal, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ public static void AreNotEqual(long expected, long actual)
+ {
+ Assert.That(actual, Is.Not.EqualTo(expected) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that two values are not equal. If they are equal, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ [CLSCompliant(false)]
+ public static void AreNotEqual(uint expected, uint actual, string message, params object[] args)
+ {
+ Assert.That(actual, Is.Not.EqualTo(expected) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that two values are not equal. If they are equal, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ [CLSCompliant(false)]
+ public static void AreNotEqual(uint expected, uint actual, string message)
+ {
+ Assert.That(actual, Is.Not.EqualTo(expected) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that two values are not equal. If they are equal, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ [CLSCompliant(false)]
+ public static void AreNotEqual(uint expected, uint actual)
+ {
+ Assert.That(actual, Is.Not.EqualTo(expected) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that two values are not equal. If they are equal, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ [CLSCompliant(false)]
+ public static void AreNotEqual(ulong expected, ulong actual, string message, params object[] args)
+ {
+ Assert.That(actual, Is.Not.EqualTo(expected) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that two values are not equal. If they are equal, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ [CLSCompliant(false)]
+ public static void AreNotEqual(ulong expected, ulong actual, string message)
+ {
+ Assert.That(actual, Is.Not.EqualTo(expected) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that two values are not equal. If they are equal, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ [CLSCompliant(false)]
+ public static void AreNotEqual(ulong expected, ulong actual)
+ {
+ Assert.That(actual, Is.Not.EqualTo(expected) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that two values are not equal. If they are equal, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void AreNotEqual(decimal expected, decimal actual, string message, params object[] args)
+ {
+ Assert.That(actual, Is.Not.EqualTo(expected) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that two values are not equal. If they are equal, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void AreNotEqual(decimal expected, decimal actual, string message)
+ {
+ Assert.That(actual, Is.Not.EqualTo(expected) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that two values are not equal. If they are equal, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ public static void AreNotEqual(decimal expected, decimal actual)
+ {
+ Assert.That(actual, Is.Not.EqualTo(expected) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that two values are not equal. If they are equal, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void AreNotEqual(float expected, float actual, string message, params object[] args)
+ {
+ Assert.That(actual, Is.Not.EqualTo(expected) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that two values are not equal. If they are equal, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void AreNotEqual(float expected, float actual, string message)
+ {
+ Assert.That(actual, Is.Not.EqualTo(expected) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that two values are not equal. If they are equal, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ public static void AreNotEqual(float expected, float actual)
+ {
+ Assert.That(actual, Is.Not.EqualTo(expected) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that two values are not equal. If they are equal, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void AreNotEqual(double expected, double actual, string message, params object[] args)
+ {
+ Assert.That(actual, Is.Not.EqualTo(expected) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that two values are not equal. If they are equal, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void AreNotEqual(double expected, double actual, string message)
+ {
+ Assert.That(actual, Is.Not.EqualTo(expected) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that two values are not equal. If they are equal, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ public static void AreNotEqual(double expected, double actual)
+ {
+ Assert.That(actual, Is.Not.EqualTo(expected) ,null, null);
+ }
+
+ #endregion
+
+ #region AreNotEqual
+
+ /// <summary>
+ /// Verifies that two objects are not equal. Two objects are considered
+ /// equal if both are null, or if both have the same value. NUnit
+ /// has special semantics for some object types.
+ /// If they are equal an <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The value that is expected</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void AreNotEqual(object expected, object actual, string message, params object[] args)
+ {
+ Assert.That(actual, Is.Not.EqualTo(expected) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that two objects are not equal. Two objects are considered
+ /// equal if both are null, or if both have the same value. NUnit
+ /// has special semantics for some object types.
+ /// If they are equal an <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The value that is expected</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void AreNotEqual(object expected, object actual, string message)
+ {
+ Assert.That(actual, Is.Not.EqualTo(expected) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that two objects are not equal. Two objects are considered
+ /// equal if both are null, or if both have the same value. NUnit
+ /// has special semantics for some object types.
+ /// If they are equal an <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The value that is expected</param>
+ /// <param name="actual">The actual value</param>
+ public static void AreNotEqual(object expected, object actual)
+ {
+ Assert.That(actual, Is.Not.EqualTo(expected) ,null, null);
+ }
+
+ #endregion
+
+ #region AreSame
+
+ /// <summary>
+ /// Asserts that two objects refer to the same object. If they
+ /// are not the same an <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected object</param>
+ /// <param name="actual">The actual object</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void AreSame(object expected, object actual, string message, params object[] args)
+ {
+ Assert.That(actual, Is.SameAs(expected) ,message, args);
+ }
+ /// <summary>
+ /// Asserts that two objects refer to the same object. If they
+ /// are not the same an <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected object</param>
+ /// <param name="actual">The actual object</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void AreSame(object expected, object actual, string message)
+ {
+ Assert.That(actual, Is.SameAs(expected) ,message, null);
+ }
+ /// <summary>
+ /// Asserts that two objects refer to the same object. If they
+ /// are not the same an <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected object</param>
+ /// <param name="actual">The actual object</param>
+ public static void AreSame(object expected, object actual)
+ {
+ Assert.That(actual, Is.SameAs(expected) ,null, null);
+ }
+
+ #endregion
+
+ #region AreNotSame
+
+ /// <summary>
+ /// Asserts that two objects do not refer to the same object. If they
+ /// are the same an <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected object</param>
+ /// <param name="actual">The actual object</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void AreNotSame(object expected, object actual, string message, params object[] args)
+ {
+ Assert.That(actual, Is.Not.SameAs(expected) ,message, args);
+ }
+ /// <summary>
+ /// Asserts that two objects do not refer to the same object. If they
+ /// are the same an <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected object</param>
+ /// <param name="actual">The actual object</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void AreNotSame(object expected, object actual, string message)
+ {
+ Assert.That(actual, Is.Not.SameAs(expected) ,message, null);
+ }
+ /// <summary>
+ /// Asserts that two objects do not refer to the same object. If they
+ /// are the same an <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="expected">The expected object</param>
+ /// <param name="actual">The actual object</param>
+ public static void AreNotSame(object expected, object actual)
+ {
+ Assert.That(actual, Is.Not.SameAs(expected) ,null, null);
+ }
+
+ #endregion
+
+ #region Greater
+
+#if !NUNITLITE
+ /// <summary>
+ /// Verifies that the first value is greater than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void Greater(int arg1, int arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.GreaterThan(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void Greater(int arg1, int arg2, string message)
+ {
+ Assert.That(arg1, Is.GreaterThan(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ public static void Greater(int arg1, int arg2)
+ {
+ Assert.That(arg1, Is.GreaterThan(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is greater than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ [CLSCompliant(false)]
+ public static void Greater(uint arg1, uint arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.GreaterThan(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ [CLSCompliant(false)]
+ public static void Greater(uint arg1, uint arg2, string message)
+ {
+ Assert.That(arg1, Is.GreaterThan(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ [CLSCompliant(false)]
+ public static void Greater(uint arg1, uint arg2)
+ {
+ Assert.That(arg1, Is.GreaterThan(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is greater than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void Greater(long arg1, long arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.GreaterThan(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void Greater(long arg1, long arg2, string message)
+ {
+ Assert.That(arg1, Is.GreaterThan(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ public static void Greater(long arg1, long arg2)
+ {
+ Assert.That(arg1, Is.GreaterThan(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is greater than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ [CLSCompliant(false)]
+ public static void Greater(ulong arg1, ulong arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.GreaterThan(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ [CLSCompliant(false)]
+ public static void Greater(ulong arg1, ulong arg2, string message)
+ {
+ Assert.That(arg1, Is.GreaterThan(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ [CLSCompliant(false)]
+ public static void Greater(ulong arg1, ulong arg2)
+ {
+ Assert.That(arg1, Is.GreaterThan(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is greater than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void Greater(decimal arg1, decimal arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.GreaterThan(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void Greater(decimal arg1, decimal arg2, string message)
+ {
+ Assert.That(arg1, Is.GreaterThan(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ public static void Greater(decimal arg1, decimal arg2)
+ {
+ Assert.That(arg1, Is.GreaterThan(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is greater than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void Greater(double arg1, double arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.GreaterThan(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void Greater(double arg1, double arg2, string message)
+ {
+ Assert.That(arg1, Is.GreaterThan(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ public static void Greater(double arg1, double arg2)
+ {
+ Assert.That(arg1, Is.GreaterThan(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is greater than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void Greater(float arg1, float arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.GreaterThan(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void Greater(float arg1, float arg2, string message)
+ {
+ Assert.That(arg1, Is.GreaterThan(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ public static void Greater(float arg1, float arg2)
+ {
+ Assert.That(arg1, Is.GreaterThan(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is greater than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void Greater(IComparable arg1, IComparable arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.GreaterThan(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void Greater(IComparable arg1, IComparable arg2, string message)
+ {
+ Assert.That(arg1, Is.GreaterThan(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ public static void Greater(IComparable arg1, IComparable arg2)
+ {
+ Assert.That(arg1, Is.GreaterThan(arg2) ,null, null);
+ }
+#endif
+
+ #endregion
+
+ #region Less
+
+#if !NUNITLITE
+ /// <summary>
+ /// Verifies that the first value is less than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void Less(int arg1, int arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.LessThan(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void Less(int arg1, int arg2, string message)
+ {
+ Assert.That(arg1, Is.LessThan(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ public static void Less(int arg1, int arg2)
+ {
+ Assert.That(arg1, Is.LessThan(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is less than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ [CLSCompliant(false)]
+ public static void Less(uint arg1, uint arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.LessThan(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ [CLSCompliant(false)]
+ public static void Less(uint arg1, uint arg2, string message)
+ {
+ Assert.That(arg1, Is.LessThan(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ [CLSCompliant(false)]
+ public static void Less(uint arg1, uint arg2)
+ {
+ Assert.That(arg1, Is.LessThan(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is less than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void Less(long arg1, long arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.LessThan(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void Less(long arg1, long arg2, string message)
+ {
+ Assert.That(arg1, Is.LessThan(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ public static void Less(long arg1, long arg2)
+ {
+ Assert.That(arg1, Is.LessThan(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is less than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ [CLSCompliant(false)]
+ public static void Less(ulong arg1, ulong arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.LessThan(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ [CLSCompliant(false)]
+ public static void Less(ulong arg1, ulong arg2, string message)
+ {
+ Assert.That(arg1, Is.LessThan(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ [CLSCompliant(false)]
+ public static void Less(ulong arg1, ulong arg2)
+ {
+ Assert.That(arg1, Is.LessThan(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is less than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void Less(decimal arg1, decimal arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.LessThan(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void Less(decimal arg1, decimal arg2, string message)
+ {
+ Assert.That(arg1, Is.LessThan(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ public static void Less(decimal arg1, decimal arg2)
+ {
+ Assert.That(arg1, Is.LessThan(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is less than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void Less(double arg1, double arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.LessThan(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void Less(double arg1, double arg2, string message)
+ {
+ Assert.That(arg1, Is.LessThan(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ public static void Less(double arg1, double arg2)
+ {
+ Assert.That(arg1, Is.LessThan(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is less than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void Less(float arg1, float arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.LessThan(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void Less(float arg1, float arg2, string message)
+ {
+ Assert.That(arg1, Is.LessThan(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ public static void Less(float arg1, float arg2)
+ {
+ Assert.That(arg1, Is.LessThan(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is less than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void Less(IComparable arg1, IComparable arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.LessThan(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void Less(IComparable arg1, IComparable arg2, string message)
+ {
+ Assert.That(arg1, Is.LessThan(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ public static void Less(IComparable arg1, IComparable arg2)
+ {
+ Assert.That(arg1, Is.LessThan(arg2) ,null, null);
+ }
+#endif
+
+ #endregion
+
+ #region GreaterOrEqual
+
+#if !NUNITLITE
+ /// <summary>
+ /// Verifies that the first value is greater than or equal tothe second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void GreaterOrEqual(int arg1, int arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than or equal tothe second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void GreaterOrEqual(int arg1, int arg2, string message)
+ {
+ Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than or equal tothe second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ public static void GreaterOrEqual(int arg1, int arg2)
+ {
+ Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is greater than or equal tothe second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ [CLSCompliant(false)]
+ public static void GreaterOrEqual(uint arg1, uint arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than or equal tothe second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ [CLSCompliant(false)]
+ public static void GreaterOrEqual(uint arg1, uint arg2, string message)
+ {
+ Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than or equal tothe second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ [CLSCompliant(false)]
+ public static void GreaterOrEqual(uint arg1, uint arg2)
+ {
+ Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is greater than or equal tothe second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void GreaterOrEqual(long arg1, long arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than or equal tothe second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void GreaterOrEqual(long arg1, long arg2, string message)
+ {
+ Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than or equal tothe second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ public static void GreaterOrEqual(long arg1, long arg2)
+ {
+ Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is greater than or equal tothe second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ [CLSCompliant(false)]
+ public static void GreaterOrEqual(ulong arg1, ulong arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than or equal tothe second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ [CLSCompliant(false)]
+ public static void GreaterOrEqual(ulong arg1, ulong arg2, string message)
+ {
+ Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than or equal tothe second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ [CLSCompliant(false)]
+ public static void GreaterOrEqual(ulong arg1, ulong arg2)
+ {
+ Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is greater than or equal tothe second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void GreaterOrEqual(decimal arg1, decimal arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than or equal tothe second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void GreaterOrEqual(decimal arg1, decimal arg2, string message)
+ {
+ Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than or equal tothe second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ public static void GreaterOrEqual(decimal arg1, decimal arg2)
+ {
+ Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is greater than or equal tothe second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void GreaterOrEqual(double arg1, double arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than or equal tothe second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void GreaterOrEqual(double arg1, double arg2, string message)
+ {
+ Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than or equal tothe second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ public static void GreaterOrEqual(double arg1, double arg2)
+ {
+ Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is greater than or equal tothe second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void GreaterOrEqual(float arg1, float arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than or equal tothe second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void GreaterOrEqual(float arg1, float arg2, string message)
+ {
+ Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than or equal tothe second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ public static void GreaterOrEqual(float arg1, float arg2)
+ {
+ Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is greater than or equal tothe second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void GreaterOrEqual(IComparable arg1, IComparable arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than or equal tothe second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void GreaterOrEqual(IComparable arg1, IComparable arg2, string message)
+ {
+ Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is greater than or equal tothe second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be greater</param>
+ /// <param name="arg2">The second value, expected to be less</param>
+ public static void GreaterOrEqual(IComparable arg1, IComparable arg2)
+ {
+ Assert.That(arg1, Is.GreaterThanOrEqualTo(arg2) ,null, null);
+ }
+#endif
+
+ #endregion
+
+ #region LessOrEqual
+
+#if !NUNITLITE
+ /// <summary>
+ /// Verifies that the first value is less than or equal to the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void LessOrEqual(int arg1, int arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than or equal to the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void LessOrEqual(int arg1, int arg2, string message)
+ {
+ Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than or equal to the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ public static void LessOrEqual(int arg1, int arg2)
+ {
+ Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is less than or equal to the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ [CLSCompliant(false)]
+ public static void LessOrEqual(uint arg1, uint arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than or equal to the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ [CLSCompliant(false)]
+ public static void LessOrEqual(uint arg1, uint arg2, string message)
+ {
+ Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than or equal to the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ [CLSCompliant(false)]
+ public static void LessOrEqual(uint arg1, uint arg2)
+ {
+ Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is less than or equal to the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void LessOrEqual(long arg1, long arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than or equal to the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void LessOrEqual(long arg1, long arg2, string message)
+ {
+ Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than or equal to the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ public static void LessOrEqual(long arg1, long arg2)
+ {
+ Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is less than or equal to the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ [CLSCompliant(false)]
+ public static void LessOrEqual(ulong arg1, ulong arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than or equal to the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ [CLSCompliant(false)]
+ public static void LessOrEqual(ulong arg1, ulong arg2, string message)
+ {
+ Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than or equal to the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ [CLSCompliant(false)]
+ public static void LessOrEqual(ulong arg1, ulong arg2)
+ {
+ Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is less than or equal to the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void LessOrEqual(decimal arg1, decimal arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than or equal to the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void LessOrEqual(decimal arg1, decimal arg2, string message)
+ {
+ Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than or equal to the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ public static void LessOrEqual(decimal arg1, decimal arg2)
+ {
+ Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is less than or equal to the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void LessOrEqual(double arg1, double arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than or equal to the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void LessOrEqual(double arg1, double arg2, string message)
+ {
+ Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than or equal to the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ public static void LessOrEqual(double arg1, double arg2)
+ {
+ Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is less than or equal to the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void LessOrEqual(float arg1, float arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than or equal to the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void LessOrEqual(float arg1, float arg2, string message)
+ {
+ Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than or equal to the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ public static void LessOrEqual(float arg1, float arg2)
+ {
+ Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,null, null);
+ }
+
+ /// <summary>
+ /// Verifies that the first value is less than or equal to the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void LessOrEqual(IComparable arg1, IComparable arg2, string message, params object[] args)
+ {
+ Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, args);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than or equal to the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void LessOrEqual(IComparable arg1, IComparable arg2, string message)
+ {
+ Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,message, null);
+ }
+ /// <summary>
+ /// Verifies that the first value is less than or equal to the second
+ /// value. If it is not, then an
+ /// <see cref="AssertionException"/> is thrown.
+ /// </summary>
+ /// <param name="arg1">The first value, expected to be less</param>
+ /// <param name="arg2">The second value, expected to be greater</param>
+ public static void LessOrEqual(IComparable arg1, IComparable arg2)
+ {
+ Assert.That(arg1, Is.LessThanOrEqualTo(arg2) ,null, null);
+ }
+#endif
+
+ #endregion
+
+ #region Contains
+
+#if !NUNITLITE
+ /// <summary>
+ /// Asserts that an object is contained in a list.
+ /// </summary>
+ /// <param name="expected">The expected object</param>
+ /// <param name="actual">The list to be examined</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ public static void Contains(object expected, ICollection actual, string message, params object[] args)
+ {
+ Assert.That(actual, new CollectionContainsConstraint(expected) ,message, args);
+ }
+ /// <summary>
+ /// Asserts that an object is contained in a list.
+ /// </summary>
+ /// <param name="expected">The expected object</param>
+ /// <param name="actual">The list to be examined</param>
+ /// <param name="message">The message to display in case of failure</param>
+ public static void Contains(object expected, ICollection actual, string message)
+ {
+ Assert.That(actual, new CollectionContainsConstraint(expected) ,message, null);
+ }
+ /// <summary>
+ /// Asserts that an object is contained in a list.
+ /// </summary>
+ /// <param name="expected">The expected object</param>
+ /// <param name="actual">The list to be examined</param>
+ public static void Contains(object expected, ICollection actual)
+ {
+ Assert.That(actual, new CollectionContainsConstraint(expected) ,null, null);
+ }
+#endif
+
+ #endregion
+
+
+ #region Helper Methods
+ /// <summary>
+ /// Helper for Assert.AreEqual(double expected, double actual, ...)
+ /// allowing code generation to work consistently.
+ /// </summary>
+ /// <param name="expected">The expected value</param>
+ /// <param name="actual">The actual value</param>
+ /// <param name="delta">The maximum acceptable difference between the
+ /// the expected and the actual</param>
+ /// <param name="message">The message to display in case of failure</param>
+ /// <param name="args">Array of objects to be used in formatting the message</param>
+ protected static void AssertDoublesAreEqual(double expected, double actual, double delta, string message, object[] args)
+ {
+ if (double.IsNaN(expected) || double.IsInfinity(expected))
+ Assert.That(actual, Is.EqualTo(expected), message, args);
+ else
+ Assert.That(actual, Is.EqualTo(expected).Within(delta), message, args);
+ }
+ #endregion
+ }
+}
=== modified file 'src/framework/AssertionHelper.cs'
--- src/framework/AssertionHelper.cs 2010-08-02 02:42:35 +0000
+++ src/framework/AssertionHelper.cs 2011-05-12 00:38:23 +0000
@@ -51,7 +51,7 @@
/// <summary>
/// Apply a constraint to an actual value, succeeding if the constraint
/// is satisfied and throwing an assertion exception on failure. Works
- /// identically to <see cref="NUnit.Framework.Assert.That(object, IResolveConstraint)"/>
+ /// identically to <see cref="NUnit.Framework.Assert.That{T}(T, IResolveConstraint)"/>
/// </summary>
/// <param name="constraint">A Constraint to be applied</param>
/// <param name="actual">The actual value to test</param>
@@ -63,7 +63,7 @@
/// <summary>
/// Apply a constraint to an actual value, succeeding if the constraint
/// is satisfied and throwing an assertion exception on failure. Works
- /// identically to <see cref="NUnit.Framework.Assert.That(object, IResolveConstraint, string)"/>
+ /// identically to <see cref="NUnit.Framework.Assert.That{T}(T, IResolveConstraint, string)"/>
/// </summary>
/// <param name="constraint">A Constraint to be applied</param>
/// <param name="actual">The actual value to test</param>
@@ -76,7 +76,7 @@
/// <summary>
/// Apply a constraint to an actual value, succeeding if the constraint
/// is satisfied and throwing an assertion exception on failure. Works
- /// identically to <see cref="NUnit.Framework.Assert.That(object, IResolveConstraint, string, object[])"/>
+ /// identically to <see cref="NUnit.Framework.Assert.That{T}(T, IResolveConstraint, string, object[])"/>
/// </summary>
/// <param name="constraint">A Constraint to be applied</param>
/// <param name="actual">The actual value to test</param>
=== modified file 'src/framework/Assume.cs'
--- src/framework/Assume.cs 2010-08-02 02:42:35 +0000
+++ src/framework/Assume.cs 2011-05-12 00:38:23 +0000
@@ -24,6 +24,7 @@
#if !NUNITLITE
using System;
using System.ComponentModel;
+using NUnit.Framework.Api;
using NUnit.Framework.Constraints;
using NUnit.Framework.Internal;
@@ -104,7 +105,8 @@
{
Constraint constraint = expression.Resolve();
- if (!constraint.Matches(actual))
+ ConstraintResult cr = constraint.Verify(actual);
+ if (cr.Result != ResultState.Success)
{
MessageWriter writer = new TextMessageWriter(message, args);
constraint.WriteMessageTo(writer);
@@ -149,7 +151,8 @@
{
Constraint constraint = expr.Resolve();
- if (!constraint.Matches(del))
+ ConstraintResult cr = constraint.Verify(del);
+ if (cr.Result != ResultState.Success)
{
MessageWriter writer = new TextMessageWriter(message, args);
constraint.WriteMessageTo(writer);
@@ -195,7 +198,8 @@
{
Constraint constraint = expression.Resolve();
- if (!constraint.Matches(ref actual))
+ ConstraintResult cr = constraint.Verify(ref actual);
+ if (cr.Result != ResultState.Success)
{
MessageWriter writer = new TextMessageWriter(message, args);
constraint.WriteMessageTo(writer);
@@ -237,8 +241,9 @@
static public void That(ref bool actual, IResolveConstraint expression, string message, params object[] args)
{
Constraint constraint = expression.Resolve();
-
- if (!constraint.Matches(ref actual))
+
+ ConstraintResult cr = constraint.Verify(ref actual);
+ if (cr.Result != VerificationResult.True)
{
MessageWriter writer = new TextMessageWriter(message, args);
constraint.WriteMessageTo(writer);
=== modified file 'src/framework/Constraints/AllItemsConstraint.cs'
--- src/framework/Constraints/AllItemsConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/AllItemsConstraint.cs 2011-05-12 00:38:23 +0000
@@ -23,6 +23,7 @@
using System;
using System.Collections;
+using NUnit.Framework.Api;
namespace NUnit.Framework.Constraints
{
@@ -42,13 +43,13 @@
this.DisplayName = "all";
}
- /// <summary>
- /// Apply the item constraint to each item in the collection,
- /// failing if any item fails.
- /// </summary>
- /// <param name="actual"></param>
- /// <returns></returns>
- public override bool Matches(object actual)
+ /// <summary>
+ /// Apply the item constraint to each item in the collection,
+ /// failing if any item fails.
+ /// </summary>
+ /// <param name="actual"></param>
+ /// <returns></returns>
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
@@ -56,10 +57,10 @@
throw new ArgumentException( "The actual value must be an IEnumerable", "actual" );
foreach(object item in (IEnumerable)actual)
- if (!baseConstraint.Matches(item))
- return false;
+ if (baseConstraint.Verify(item).Result != ResultState.Success)
+ return new ConstraintResult(false);
- return true;
+ return new ConstraintResult(true);
}
/// <summary>
=== modified file 'src/framework/Constraints/AndConstraint.cs'
--- src/framework/Constraints/AndConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/AndConstraint.cs 2011-05-12 00:38:23 +0000
@@ -21,6 +21,8 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************
+using NUnit.Framework.Api;
+
namespace NUnit.Framework.Constraints
{
/// <summary>
@@ -50,17 +52,18 @@
/// </summary>
/// <param name="actual">The actual value</param>
/// <returns>True if the constraints both succeeded</returns>
- public override bool Matches(object actual)
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
- failurePoint = Left.Matches(actual)
- ? Right.Matches(actual)
+ // Temporary now result with ActualCanNotBeVerified does not exits in this stage of the refactoring
+ failurePoint = Left.Verify(actual).Result == ResultState.Success
+ ? Right.Verify(actual).Result == ResultState.Success
? FailurePoint.None
: FailurePoint.Right
: FailurePoint.Left;
- return failurePoint == FailurePoint.None;
+ return new ConstraintResult(failurePoint == FailurePoint.None);
}
/// <summary>
=== modified file 'src/framework/Constraints/AssignableFromConstraint.cs'
--- src/framework/Constraints/AssignableFromConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/AssignableFromConstraint.cs 2011-05-12 00:38:23 +0000
@@ -42,10 +42,10 @@
/// </summary>
/// <param name="actual">The object to be tested</param>
/// <returns>True if the object can be assigned a value of the expected Type, otherwise false.</returns>
- public override bool Matches(object actual)
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
- return actual != null && actual.GetType().IsAssignableFrom(expectedType);
+ return new ConstraintResult(actual != null && actual.GetType().IsAssignableFrom(expectedType));
}
/// <summary>
=== modified file 'src/framework/Constraints/AssignableToConstraint.cs'
--- src/framework/Constraints/AssignableToConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/AssignableToConstraint.cs 2011-05-12 00:38:23 +0000
@@ -42,10 +42,10 @@
/// </summary>
/// <param name="actual">The object to be tested</param>
/// <returns>True if the object can be assigned a value of the expected Type, otherwise false.</returns>
- public override bool Matches(object actual)
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
- return actual != null && expectedType.IsAssignableFrom(actual.GetType());
+ return new ConstraintResult(actual != null && expectedType.IsAssignableFrom(actual.GetType()));
}
/// <summary>
=== modified file 'src/framework/Constraints/AttributeConstraint.cs'
--- src/framework/Constraints/AttributeConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/AttributeConstraint.cs 2011-05-12 00:38:23 +0000
@@ -56,7 +56,7 @@
/// expected attribute and if its value matches the
/// additional constraint specified.
/// </summary>
- public override bool Matches(object actual)
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
System.Reflection.ICustomAttributeProvider attrProvider =
@@ -70,7 +70,7 @@
throw new ArgumentException(string.Format("Attribute {0} was not found", expectedType), "actual");
this.attrFound = attrs[0];
- return baseConstraint.Matches(attrFound);
+ return baseConstraint.Verify(attrFound);
}
/// <summary>
=== modified file 'src/framework/Constraints/AttributeExistsConstraint.cs'
--- src/framework/Constraints/AttributeExistsConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/AttributeExistsConstraint.cs 2011-05-12 00:38:23 +0000
@@ -52,7 +52,7 @@
/// </summary>
/// <param name="actual">A Type, MethodInfo, or other ICustomAttributeProvider</param>
/// <returns>True if the expected attribute is present, otherwise false</returns>
- public override bool Matches(object actual)
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
System.Reflection.ICustomAttributeProvider attrProvider =
@@ -61,7 +61,7 @@
if (attrProvider == null)
throw new ArgumentException(string.Format("Actual value {0} does not implement ICustomAttributeProvider", actual), "actual");
- return attrProvider.GetCustomAttributes(expectedType, true).Length > 0;
+ return new ConstraintResult(attrProvider.GetCustomAttributes(expectedType, true).Length > 0);
}
/// <summary>
=== removed file 'src/framework/Constraints/BasicConstraint.cs'
--- src/framework/Constraints/BasicConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/BasicConstraint.cs 1970-01-01 00:00:00 +0000
@@ -1,75 +0,0 @@
-// ***********************************************************************
-// Copyright (c) 2008 Charlie Poole
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-// ***********************************************************************
-
-using System;
-
-namespace NUnit.Framework.Constraints
-{
- /// <summary>
- /// BasicConstraint is the abstract base for constraints that
- /// perform a simple comparison to a constant value.
- /// </summary>
- public abstract class BasicConstraint : Constraint
- {
- private readonly object expected;
- private readonly string description;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="T:BasicConstraint"/> class.
- /// </summary>
- /// <param name="expected">The expected.</param>
- /// <param name="description">The description.</param>
- protected BasicConstraint(object expected, string description)
- {
- this.expected = expected;
- this.description = description;
- }
-
- /// <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>
- public override bool Matches(object actual)
- {
- this.actual = actual;
-
- if (actual == null && expected == null)
- return true;
-
- if (actual == null || expected == null)
- return false;
-
- return expected.Equals(actual);
- }
-
- /// <summary>
- /// Write the constraint description to a MessageWriter
- /// </summary>
- /// <param name="writer">The writer on which the description is displayed</param>
- public override void WriteDescriptionTo(MessageWriter writer)
- {
- writer.Write(description);
- }
- }
-}
\ No newline at end of file
=== modified file 'src/framework/Constraints/BinarySerializableConstraint.cs'
--- src/framework/Constraints/BinarySerializableConstraint.cs 2010-09-19 16:45:44 +0000
+++ src/framework/Constraints/BinarySerializableConstraint.cs 2011-05-12 00:38:23 +0000
@@ -42,7 +42,7 @@
/// </summary>
/// <param name="actual">The value to be tested</param>
/// <returns>True for success, false for failure</returns>
- public override bool Matches(object actual)
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
@@ -59,11 +59,11 @@
object value = serializer.Deserialize(stream);
- return value != null;
+ return new ConstraintResult(value != null);
}
catch (SerializationException)
{
- return false;
+ return new ConstraintResult(false);
}
}
=== modified file 'src/framework/Constraints/CollectionConstraint.cs'
--- src/framework/Constraints/CollectionConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/CollectionConstraint.cs 2011-05-12 00:38:23 +0000
@@ -59,12 +59,12 @@
return !enumerable.GetEnumerator().MoveNext();
}
- /// <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>
- public override bool Matches(object actual)
+ /// <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>
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
@@ -72,7 +72,7 @@
if ( enumerable == null )
throw new ArgumentException( "The actual value must be an IEnumerable", "actual" );
- return doMatch( enumerable );
+ return new ConstraintResult(doMatch( enumerable ));
}
/// <summary>
=== added file 'src/framework/Constraints/ComparisonConstraint.cs'
--- src/framework/Constraints/ComparisonConstraint.cs 1970-01-01 00:00:00 +0000
+++ src/framework/Constraints/ComparisonConstraint.cs 2011-05-12 00:38:23 +0000
@@ -0,0 +1,324 @@
+// ***********************************************************************
+// Copyright (c) 2011 Charlie Poole
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// ***********************************************************************
+
+#if CLR_2_0 || CLR_4_0
+using System.Collections.Generic;
+#endif
+
+using System;
+using System.Collections;
+using System.Reflection;
+using NUnit.Framework.Api;
+using NUnitProposal.NUnit.Framework.Constraints.Helpers;
+
+
+namespace NUnit.Framework.Constraints
+{
+ /// <summary>
+ /// Abstract base class for constraints that compare values to
+ /// determine if one is greater than, equal to or less than
+ /// the other.
+ /// </summary>
+ public abstract class ComparisonConstraint : Constraint
+ {
+ /// <summary>Flag used to indicate if actual should pass the constraint check if it is less, equal or greater than expected.</summary>
+ [Flags]
+ protected enum ComparisonResults
+ {
+ /// <summary>If set indicate that less values should pass the constraint check.</summary>
+ Less = 0x1,
+ /// <summary>If set indicate that equal values should pass the constraint check.</summary>
+ Equal = 0x2,
+ /// <summary>If set indicate that greater values should pass the constraint check.</summary>
+ Greater = 0x4
+ }
+
+ /// <summary>
+ /// The value against which a comparison is to be made
+ /// </summary>
+ private readonly object expected;
+ /// <summary>
+ /// If true, less than returns success
+ /// </summary>
+ private readonly bool lessComparisonResult;
+ /// <summary>
+ /// If true, equal returns success
+ /// </summary>
+ private readonly bool equalComparisonResult;
+ /// <summary>
+ /// If true, greater than returns success
+ /// </summary>
+ private readonly bool greaterComparisonResult;
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="expected">The value against which to make a comparison.</param>
+ /// <param name="comparisonResults">Determines what Verify should return when actual is less, equal or greater than expected.</param>
+ protected ComparisonConstraint(object expected, ComparisonResults comparisonResults)
+ : base(expected)
+ {
+ if (ReferenceEquals(expected, null))
+ throw new ArgumentNullException("expected", string.Format(constructorExceptionMessageFormat, GetType().Name, "argument expected is null."));
+ if (HasNoComparisonInterface(expected))
+ throw new ArgumentException(string.Format(constructorExceptionMessageFormat, GetType().Name, "expected argument has no comparison interface."), "expected");
+
+ this.expected = expected;
+ lessComparisonResult = (comparisonResults & ComparisonResults.Less) != 0;
+ equalComparisonResult = (comparisonResults & ComparisonResults.Equal) != 0;
+ greaterComparisonResult = (comparisonResults & ComparisonResults.Greater) != 0;
+ }
+
+
+ /// <summary>
+ /// Verifies an actual value against the constraint.
+ /// </summary>
+ /// <param name="actual">The actual value to verify against the constraint.</param>
+ /// <returns>The outcome of the verification of actual value against the constraint.</returns>
+ public override ConstraintResult Verify(object actual)
+ {
+ this.actual = actual;
+ if (ReferenceEquals(actual, null))
+ throw new ArgumentNullException("actual", string.Format(verifyExceptionMessageFormat, GetType().Name, "actual is null."));
+
+ // Since we are using the comparison operators on expected the meaning of the result is reversed from actual's perspective
+ // result < 0 indicates that actual is greater than expected and result > 0 indicates that actual is less than expected.
+ int result = DoNumericComparison(actual) ? UseNumericComparison(actual) : UseStandardComparison(actual);
+ ResultState state = ResultState.Failure;
+ if ((result > 0 && lessComparisonResult) || (result == 0 && equalComparisonResult) || (result < 0 && greaterComparisonResult))
+ state = ResultState.Success;
+
+ return new ConstraintResult(state, Name, string.Empty, actual, expected);
+ }
+
+
+ /// <summary>
+ /// Write the constraint description to a MessageWriter
+ /// </summary>
+ /// <param name="writer">The writer on which the description is displayed</param>
+ public override void WriteDescriptionTo(MessageWriter writer)
+ {
+ writer.WritePredicate(Name);
+ writer.WriteExpectedValue(expected);
+ }
+
+
+ private static bool HasNoComparisonInterface(object expected)
+ {
+ Type expectedType = expected == null ? null : expected.GetType();
+ if (expectedType == null)
+ return false;
+
+ Type[] expectedInterfaces = expectedType.GetInterfaces();
+ Type[] comparisonInterfaces = new [] { typeof(IComparer), typeof(IComparable), typeof(IComparer<>), typeof(IComparable<>) };
+ foreach (Type comparisonInterface in comparisonInterfaces)
+ {
+ foreach (Type expectedInterface in expectedInterfaces)
+ {
+ if (comparisonInterface.IsGenericType)
+ {
+ if (expectedInterface.IsGenericType && expectedInterface.GetGenericTypeDefinition() == comparisonInterface)
+ return false;
+ }
+ else
+ {
+ if (comparisonInterface == expectedInterface)
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+
+ private bool DoNumericComparison(object actual)
+ {
+ return NumericComparison.IsNumericComparisonPossible(expected, actual);
+ }
+
+ private int UseNumericComparison(object actual)
+ {
+ return NumericComparison.Compare(expected, actual);
+ }
+
+
+ private int UseStandardComparison(object actual)
+ {
+ ComparisonResult result = new ComparisonResult();
+ result.ComparableResult = GetComparableResult(expected, actual);
+ result.ComparerResult = GetComparerResult(expected, actual);
+#if CLR_2_0 || CLR_4_0
+ result.GenericComparableResult = GetGenericComparableResult(expected, actual);
+ result.GenericComparerResult = GetGenericComparerResult(expected, actual);
+#endif
+
+ try
+ {
+ int comparisonResult = GetFirstComparisonResult(result);
+ ThrowIfAmbiguousExistBetweenComparisonMethods(comparisonResult, actual, result);
+ return comparisonResult;
+ }
+ catch (NotSupportedException)
+ {
+ string causeOfException = "the expected " + expected + " value has no comparision interfaces for the actual " + actual + "value.";
+ throw new ArgumentException(string.Format(verifyExceptionMessageFormat, GetType().Name, causeOfException), "actual");
+ }
+ }
+
+
+ private void ThrowIfAmbiguousExistBetweenComparisonMethods(int baseComparisionValue, object actual, ComparisonResult result)
+ {
+ bool hasConflictingResult = HasConflictingResult(baseComparisionValue, result);
+ if (!hasConflictingResult)
+ return;
+
+ List<string> interfaceAndValue = new List<string>();
+ if (result.ComparableResult.HasValue)
+ interfaceAndValue.Add("IComparable.CompareTo (" + result.ComparableResult.Value + ")");
+ if (result.ComparerResult.HasValue)
+ interfaceAndValue.Add("IComparer.Compare (" + result.ComparerResult.Value + ")");
+#if CLR_2_0 || CLR_4_0
+ if (result.GenericComparableResult.HasValue)
+ interfaceAndValue.Add("IComparable<T>.CompareTo (" + result.GenericComparableResult.Value + ")");
+ if (result.GenericComparerResult.HasValue)
+ interfaceAndValue.Add("IComparer<T>.Compare (" + result.GenericComparerResult.Value + ")");
+#endif
+
+ string interfaceConflicts = StringConverterHelper.ConvertCollectionToString(interfaceAndValue, ", ", " and ");
+
+ string causeOfException = "the comparision between expected " + expected + " and actual " + actual +
+ " value has ambiguities between comparison interfaces: " + interfaceConflicts;
+ throw new ArgumentException(string.Format(verifyExceptionMessageFormat, GetType().Name, causeOfException), "actual");
+ }
+
+
+ private static bool HasConflictingResult(int resultBase, ComparisonResult result)
+ {
+ int?[] resultArray = new[]
+ {
+ result.ComparableResult, result.ComparerResult,
+#if CLR_2_0 || CLR_4_0
+ result.GenericComparableResult, result.GenericComparerResult
+#endif
+ };
+
+ foreach (int? val in resultArray)
+ {
+ if (resultBase == 0)
+ if (val.HasValue && val.Value != 0)
+ return true;
+ if (resultBase < 0)
+ if (val.HasValue && !(val.Value < 0))
+ return true;
+ if (resultBase > 0)
+ if (val.HasValue && !(val.Value > 0))
+ return true;
+ }
+
+ return false;
+ }
+
+
+ /// <summary>Return the first result found. Don't check for any ambiguous between the result.</summary>
+ /// <param name="result"></param>
+ /// <returns></returns>
+ private static int GetFirstComparisonResult(ComparisonResult result)
+ {
+ if (result.ComparableResult.HasValue)
+ return result.ComparableResult.Value;
+ if (result.ComparerResult.HasValue)
+ return result.ComparerResult.Value;
+#if CLR_2_0 || CLR_4_0
+ if (result.GenericComparableResult.HasValue)
+ return result.GenericComparableResult.Value;
+ if (result.GenericComparerResult.HasValue)
+ return result.GenericComparerResult.Value;
+#endif
+
+ // Should never happen
+ throw new NotSupportedException("No comparison result is set.");
+ }
+
+
+ /// <summary>Return null if no expected doesn't implement IComparable interface.</summary>
+ private static int? GetComparableResult(object expected, object actual)
+ {
+ IComparable comparable = expected as IComparable;
+ if (comparable == null)
+ return null;
+
+ return comparable.CompareTo(actual);
+ }
+
+ /// <summary>Return null if no expected doesn't implement IComparer interface.</summary>
+ private static int? GetComparerResult(object expected, object actual)
+ {
+ IComparer comparer = expected as IComparer;
+ if (comparer == null)
+ return null;
+
+ return comparer.Compare(expected, actual);
+ }
+
+
+#if CLR_2_0 || CLR_4_0
+ /// <summary>Return null if expected doesn't implement IComparer<T> interface where
+ /// the actual is assignalbe to the type implemented.</summary>
+ private static int? GetGenericComparableResult(object expected, object actual)
+ {
+ Type expectedType = expected.GetType();
+ Type actualType = actual.GetType();
+ MethodInfo method = expectedType.GetMethod("CompareTo", new[] { actualType });
+ if (method == null)
+ return null;
+
+ return (int)method.Invoke(expected, new[] { actual });
+ }
+
+ /// <summary>Return null if expected doesn't implement IComparer<T> interface where
+ /// the actual is assignalbe to the type implemented.</summary>
+ private static int? GetGenericComparerResult(object expected, object actual)
+ {
+ Type expectedType = expected.GetType();
+ Type actualType = actual.GetType();
+ MethodInfo method = expectedType.GetMethod("Compare", new[] { expectedType, actualType });
+ if (method == null)
+ return null;
+
+ return (int)method.Invoke(expected, new[] { expected, actual });
+ }
+#endif
+
+
+ private class ComparisonResult
+ {
+ public int? ComparableResult { get; set; }
+ public int? ComparerResult { get; set; }
+#if CLR_2_0 || CLR_4_0
+ public int? GenericComparableResult { get; set; }
+ public int? GenericComparerResult { get; set; }
+#endif
+ }
+ }
+}
\ No newline at end of file
=== removed file 'src/framework/Constraints/ComparisonConstraint.cs'
--- src/framework/Constraints/ComparisonConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/ComparisonConstraint.cs 1970-01-01 00:00:00 +0000
@@ -1,142 +0,0 @@
-// ***********************************************************************
-// Copyright (c) 2007 Charlie Poole
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-// ***********************************************************************
-
-using System;
-using System.Collections;
-#if CLR_2_0 || CLR_4_0
-using System.Collections.Generic;
-#endif
-
-namespace NUnit.Framework.Constraints
-{
- /// <summary>
- /// Abstract base class for constraints that compare values to
- /// determine if one is greater than, equal to or less than
- /// the other.
- /// </summary>
- public abstract class ComparisonConstraint : Constraint
- {
- /// <summary>
- /// The value against which a comparison is to be made
- /// </summary>
- protected object expected;
- /// <summary>
- /// If true, less than returns success
- /// </summary>
- protected bool lessComparisonResult = false;
- /// <summary>
- /// if true, equal returns success
- /// </summary>
- protected bool equalComparisonResult = false;
- /// <summary>
- /// if true, greater than returns success
- /// </summary>
- protected bool greaterComparisonResult = false;
- /// <summary>
- /// The predicate used as a part of the description
- /// </summary>
- private readonly string predicate;
-
- /// <summary>
- /// ComparisonAdapter to be used in making the comparison
- /// </summary>
- private ComparisonAdapter comparer = ComparisonAdapter.Default;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="T:ComparisonConstraint"/> class.
- /// </summary>
- /// <param name="value">The value against which to make a comparison.</param>
- /// <param name="lessComparisonResult">if set to <c>true</c> less succeeds.</param>
- /// <param name="equalComparisonResult">if set to <c>true</c> equal succeeds.</param>
- /// <param name="greaterComparisonResult">if set to <c>true</c> greater succeeds.</param>
- /// <param name="predicate">String used in describing the constraint.</param>
- protected ComparisonConstraint(object value, bool lessComparisonResult, bool equalComparisonResult, bool greaterComparisonResult, string predicate)
- : base(value)
- {
- this.expected = value;
- this.lessComparisonResult = lessComparisonResult;
- this.equalComparisonResult = equalComparisonResult;
- this.greaterComparisonResult = greaterComparisonResult;
- this.predicate = predicate;
- }
-
- /// <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>
- public override bool Matches(object actual)
- {
- this.actual = actual;
-
- if (expected == null)
- throw new ArgumentException("Cannot compare using a null reference", "expected");
-
- if (actual == null)
- throw new ArgumentException("Cannot compare to null reference", "actual");
-
- int icomp = comparer.Compare(expected, actual);
-
- return icomp < 0 && greaterComparisonResult || icomp == 0 && equalComparisonResult || icomp > 0 && lessComparisonResult;
- }
-
- /// <summary>
- /// Write the constraint description to a MessageWriter
- /// </summary>
- /// <param name="writer">The writer on which the description is displayed</param>
- public override void WriteDescriptionTo(MessageWriter writer)
- {
- writer.WritePredicate(predicate);
- writer.WriteExpectedValue(expected);
- }
-
- /// <summary>
- /// Modifies the constraint to use an IComparer and returns self
- /// </summary>
- public ComparisonConstraint Using(IComparer comparer)
- {
- this.comparer = ComparisonAdapter.For(comparer);
- return this;
- }
-
-#if CLR_2_0 || CLR_4_0
- /// <summary>
- /// Modifies the constraint to use an IComparer<T> and returns self
- /// </summary>
- public ComparisonConstraint Using<T>(IComparer<T> comparer)
- {
- this.comparer = ComparisonAdapter.For(comparer);
- return this;
- }
-
- /// <summary>
- /// Modifies the constraint to use a Comparison<T> and returns self
- /// </summary>
- public ComparisonConstraint Using<T>(Comparison<T> comparer)
- {
- this.comparer = ComparisonAdapter.For(comparer);
- return this;
- }
-#endif
- }
-}
\ No newline at end of file
=== modified file 'src/framework/Constraints/Constraint.cs'
--- src/framework/Constraints/Constraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/Constraint.cs 2011-05-12 00:38:23 +0000
@@ -22,6 +22,11 @@
// ***********************************************************************
using System.Collections;
+#if CLR_2_0 || CLR_4_0
+using System.Collections.Generic;
+using System;
+#endif
+
namespace NUnit.Framework.Constraints
{
@@ -30,7 +35,7 @@
/// to be used in evaluating a constraint
/// </summary>
public delegate object ActualValueDelegate();
-
+
/// <summary>
/// The Constraint class is the base of all built-in constraints
/// within NUnit. It provides the operator overloads used to combine
@@ -38,52 +43,24 @@
/// </summary>
public abstract class Constraint : IResolveConstraint
{
- #region UnsetObject Class
- /// <summary>
- /// Class used to detect any derived constraints
- /// that fail to set the actual value in their
- /// Matches override.
- /// </summary>
- private class UnsetObject
- {
- public override string ToString()
- {
- return "UNSET";
- }
- }
- #endregion
-
- #region Static and Instance Fields
- /// <summary>
- /// Static UnsetObject used to detect derived constraints
- /// failing to set the actual value.
- /// </summary>
- protected static object UNSET = new UnsetObject();
-
- /// <summary>
- /// The actual value being tested against a constraint
- /// </summary>
- protected object actual = UNSET;
-
- /// <summary>
- /// The display name of this Constraint for use by ToString()
- /// </summary>
- private string displayName;
-
- /// <summary>
- /// Argument fields used by ToString();
- /// </summary>
- private readonly int argcnt;
- private readonly object arg1;
- private readonly object arg2;
+#if CLR_2_0 || CLR_4_0
+ private static Dictionary<Type, string> constraintNameLookupTable = new Dictionary<Type, string>();
+ private static object nameLookupTableLock = new object();
+#endif
+ /// <summary>Message format that should be used for exceptions thrown in the construct.
+ /// The first argument should be the type name (use GetType().Name) and the second argument
+ /// should be the cause of the exception.</summary>
+ protected readonly string constructorExceptionMessageFormat = "{0} can't be setup since {1}";
+ /// <summary>Message format that should be used for exceptions thrown when the Verify method is called.
+ /// The first argument should be the type name (use GetType().Name) and the second argument
+ /// should be the cause of the exception.</summary>
+ protected readonly string verifyExceptionMessageFormat = "{0} Verify method can't be performed since {1}";
/// <summary>
/// The builder holding this constraint
/// </summary>
private ConstraintBuilder builder;
- #endregion
- #region Constructors
/// <summary>
/// Construct a constraint with no arguments
/// </summary>
@@ -92,85 +69,42 @@
argcnt = 0;
}
- /// <summary>
- /// Construct a constraint with one argument
- /// </summary>
- protected Constraint(object arg)
- {
- argcnt = 1;
- this.arg1 = arg;
- }
-
- /// <summary>
- /// Construct a constraint with two arguments
- /// </summary>
- protected Constraint(object arg1, object arg2)
- {
- argcnt = 2;
- this.arg1 = arg1;
- this.arg2 = arg2;
- }
- #endregion
-
- #region Set Containing ConstraintBuilder
- /// <summary>
- /// Sets the ConstraintBuilder holding this constraint
- /// </summary>
- internal void SetBuilder(ConstraintBuilder builder)
- {
- this.builder = builder;
- }
- #endregion
-
- #region Properties
- /// <summary>
- /// The display name of this Constraint for use by ToString().
- /// The default value is the name of the constraint with
- /// trailing "Constraint" removed. Derived classes may set
- /// this to another name in their constructors.
- /// </summary>
- public string DisplayName
+
+ /// <summary>
+ /// The name of the Constraint.
+ /// </summary>
+ public virtual string Name
{
get
{
- if (displayName == null)
+#if CLR_2_0 || CLR_4_0
+ Type thisType = this.GetType();
+ if (!constraintNameLookupTable.ContainsKey(thisType))
{
- displayName = this.GetType().Name.ToLower();
- if (displayName.EndsWith("`1") || displayName.EndsWith("`2"))
- displayName = displayName.Substring(0, displayName.Length - 2);
- if (displayName.EndsWith("constraint"))
- displayName = displayName.Substring(0, displayName.Length - 10);
+ // Using the double-checked locking pattern.
+ lock (nameLookupTableLock)
+ {
+ if (!constraintNameLookupTable.ContainsKey(thisType))
+ {
+ constraintNameLookupTable.Add(thisType, CreateConstraintName(thisType));
+ }
+ }
}
- return displayName;
+ return constraintNameLookupTable[thisType];
+#else
+ return CreateConstraintName(this.GetType());
+#endif
}
-
- set { displayName = value; }
- }
- #endregion
-
- #region Abstract and Virtual Methods
- /// <summary>
- /// Write the failure message to the MessageWriter provided
- /// as an argument. The default implementation simply passes
- /// the constraint and the actual value to the writer, which
- /// then displays the constraint description and the value.
- ///
- /// Constraints that need to provide additional details,
- /// such as where the error occured can override this.
- /// </summary>
- /// <param name="writer">The MessageWriter on which to display the message</param>
- public virtual void WriteMessageTo(MessageWriter writer)
- {
- writer.DisplayDifferences(this);
- }
-
- /// <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>
- public abstract bool Matches(object actual);
+ }
+
+
+ /// <summary>
+ /// Verifies an actual value against the constraint.
+ /// </summary>
+ /// <param name="actual">The actual value to verify against the constraint.</param>
+ /// <returns>The outcome of the verification of actual value against the constraint.</returns>
+ public abstract ConstraintResult Verify(object actual);
/// <summary>
/// Test whether the constraint is satisfied by an
@@ -181,9 +115,9 @@
/// </summary>
/// <param name="del">An ActualValueDelegate</param>
/// <returns>True for success, false for failure</returns>
- public virtual bool Matches(ActualValueDelegate del)
+ public virtual ConstraintResult Verify(ActualValueDelegate del)
{
- return Matches(del());
+ return Verify(del());
}
#if CLR_2_0 || CLR_4_0
@@ -194,9 +128,9 @@
/// </summary>
/// <param name="actual">A reference to the value to be tested</param>
/// <returns>True for success, false for failure</returns>
- public virtual bool Matches<T>(ref T actual)
+ public virtual ConstraintResult Verify<T>(ref T actual)
{
- return Matches(actual);
+ return Verify(actual);
}
#else
/// <summary>
@@ -206,31 +140,82 @@
/// </summary>
/// <param name="actual">A reference to the value to be tested</param>
/// <returns>True for success, false for failure</returns>
- public virtual bool Matches(ref bool actual)
- {
- return Matches(actual);
- }
-#endif
-
- /// <summary>
- /// Write the constraint description to a MessageWriter
- /// </summary>
- /// <param name="writer">The writer on which the description is displayed</param>
- public abstract void WriteDescriptionTo(MessageWriter writer);
-
- /// <summary>
- /// Write the actual value for a failing constraint test to a
- /// MessageWriter. The default implementation simply writes
- /// the raw value of actual, leaving it to the writer to
- /// perform any formatting.
- /// </summary>
- /// <param name="writer">The writer on which the actual value is displayed</param>
- public virtual void WriteActualValueTo(MessageWriter writer)
- {
- writer.WriteActualValue( actual );
- }
- #endregion
-
+ public virtual ConstraintResult Matches(ref bool actual)
+ {
+ return Verify(actual);
+ }
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ private static string CreateConstraintName(Type type)
+ {
+ const string constraint = "Constraint";
+
+ string name = type.Name;
+ if (name.EndsWith(constraint))
+ name = name.Substring(0, name.Length - constraint.Length);
+
+
+ int[] upperIndexes = GetUpperCharIndexes(name);
+ // i > 0 ignores the first element in uppderIndex based on the assumption that the
+ // first index contains the index to the first char in name
+ for (int i = upperIndexes.Length - 1; i > 0; --i)
+ {
+ name = name.Insert(upperIndexes[i], " ");
+ }
+
+ return name.ToLower();
+ }
+
+ private static int[] GetUpperCharIndexes(string input)
+ {
+#if CLR_2_0 || CLR_4_0
+ int index = 0;
+ List<int> indexes = new List<int>();
+ foreach (char c in input)
+ {
+ if (char.IsUpper(c))
+ indexes.Add(index);
+
+ ++index;
+ }
+
+ return indexes.ToArray();
+#else
+ int index = 0;
+ ArrayList list = new ArrayList();
+ foreach (char c in input)
+ {
+ if (char.IsUpper(c))
+ list.Add(index);
+
+ ++index;
+ }
+
+ int[] indexes = new int[list.Count];
+ for (int i = 0; i < list.Count; ++i)
+ {
+ indexes[i] = (int)list[i];
+ }
+
+ return indexes;
+#endif
+ }
+
+
+
#region ToString Override
/// <summary>
/// Default override of ToString returns the constraint DisplayName
@@ -271,6 +256,10 @@
}
#endregion
+
+
+
+
#region Operator Overloads
/// <summary>
/// This operator creates a constraint that is satisfied only if both
@@ -397,5 +386,151 @@
return builder == null ? this : builder.Resolve();
}
#endregion
+
+
+
+
+ //TODO: Remove region when Constraint class redesign is completed.
+ #region Marked For Deletion - Will be deleted when the redesign is completed
+
+ #region UnsetObject Class
+ /// <summary>
+ /// Class used to detect any derived constraints
+ /// that fail to set the actual value in their
+ /// Matches override.
+ /// </summary>
+ private class UnsetObject
+ {
+ public override string ToString()
+ {
+ return "UNSET";
+ }
+ }
+ #endregion
+
+ #region Static and Instance Fields
+ /// <summary>
+ /// Static UnsetObject used to detect derived constraints
+ /// failing to set the actual value.
+ /// </summary>
+ protected static object UNSET = new UnsetObject();
+
+ /// <summary>
+ /// The actual value being tested against a constraint
+ /// </summary>
+ protected object actual = UNSET;
+
+ /// <summary>
+ /// The display name of this Constraint for use by ToString()
+ /// </summary>
+ private string displayName;
+
+ /// <summary>
+ /// Argument fields used by ToString();
+ /// </summary>
+ private readonly int argcnt;
+ private readonly object arg1;
+ private readonly object arg2;
+
+ #endregion
+
+ #region Constructors
+
+ /// <summary>
+ /// Construct a constraint with one argument
+ /// </summary>
+ protected Constraint(object arg)
+ {
+ argcnt = 1;
+ this.arg1 = arg;
+ }
+
+ /// <summary>
+ /// Construct a constraint with two arguments
+ /// </summary>
+ protected Constraint(object arg1, object arg2)
+ {
+ argcnt = 2;
+ this.arg1 = arg1;
+ this.arg2 = arg2;
+ }
+ #endregion
+
+ #region Set Containing ConstraintBuilder
+ /// <summary>
+ /// Sets the ConstraintBuilder holding this constraint
+ /// </summary>
+ internal void SetBuilder(ConstraintBuilder builder)
+ {
+ this.builder = builder;
+ }
+ #endregion
+
+ #region Properties
+ /// <summary>
+ /// The display name of this Constraint for use by ToString().
+ /// The default value is the name of the constraint with
+ /// trailing "Constraint" removed. Derived classes may set
+ /// this to another name in their constructors.
+ /// </summary>
+ public string DisplayName
+ {
+ get
+ {
+ if (displayName == null)
+ {
+ displayName = GetType().Name.ToLower();
+ if (displayName.EndsWith("`1") || displayName.EndsWith("`2"))
+ displayName = displayName.Substring(0, displayName.Length - 2);
+ if (displayName.EndsWith("constraint"))
+ displayName = displayName.Substring(0, displayName.Length - 10);
+ }
+
+ return displayName;
+ }
+
+ set { displayName = value; }
+ }
+ #endregion
+
+ #region Abstract and Virtual Methods
+ /// <summary>
+ /// Write the failure message to the MessageWriter provided
+ /// as an argument. The default implementation simply passes
+ /// the constraint and the actual value to the writer, which
+ /// then displays the constraint description and the value.
+ ///
+ /// Constraints that need to provide additional details,
+ /// such as where the error occured can override this.
+ /// </summary>
+ /// <param name="writer">The MessageWriter on which to display the message</param>
+ public virtual void WriteMessageTo(MessageWriter writer)
+ {
+ writer.DisplayDifferences(this);
+ }
+
+
+
+
+ /// <summary>
+ /// Write the constraint description to a MessageWriter
+ /// </summary>
+ /// <param name="writer">The writer on which the description is displayed</param>
+ public abstract void WriteDescriptionTo(MessageWriter writer);
+
+ /// <summary>
+ /// Write the actual value for a failing constraint test to a
+ /// MessageWriter. The default implementation simply writes
+ /// the raw value of actual, leaving it to the writer to
+ /// perform any formatting.
+ /// </summary>
+ /// <param name="writer">The writer on which the actual value is displayed</param>
+ public virtual void WriteActualValueTo(MessageWriter writer)
+ {
+ writer.WriteActualValue(actual);
+ }
+ #endregion
+
+ #endregion
}
}
\ No newline at end of file
=== added file 'src/framework/Constraints/ConstraintResult.cs'
--- src/framework/Constraints/ConstraintResult.cs 1970-01-01 00:00:00 +0000
+++ src/framework/Constraints/ConstraintResult.cs 2011-05-12 00:38:23 +0000
@@ -0,0 +1,109 @@
+// ***********************************************************************
+// Copyright (c) 2010 Charlie Poole
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// ***********************************************************************
+
+using System;
+using NUnit.Framework.Api;
+
+namespace NUnit.Framework.Constraints
+{
+ /// <summary>
+ /// Immutable class that stores the result of an actual object verified against a Constraint.
+ /// </summary>
+ public sealed class ConstraintResult
+ {
+ private readonly ResultState result;
+ private readonly string name;
+ private readonly string description;
+ private readonly object actual;
+ private readonly object expected;
+
+ /// <summary>
+ /// Only added to allowed easier refactoring of Matches to make it return a ConstraintResult class.
+ /// This constructor will be removed when the refactoring of constraint class is completed.
+ /// </summary>
+ /// <param name="result"></param>
+ public ConstraintResult(bool result)
+ {
+ this.result = result ? ResultState.Success : ResultState.Failure;
+ name = string.Empty;
+ description = string.Empty;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="T:ConstraintResult"/> class.
+ /// </summary>
+ /// <param name="result">The outcome of an actual value verified against a Constraint.</param>
+ /// <param name="name">The name of the Constraint that actual was verified against.</param>
+ /// <param name="description">Additional description of the reason why an actual value didn't satisfied the Constraint.</param>
+ /// <param name="actual">The actual value being verified.</param>
+ /// <param name="expected">The expected value of actual.</param>
+ public ConstraintResult(ResultState result, string name, string description, object actual, object expected)
+ {
+ if (result == null)
+ throw new ArgumentNullException("result");
+ if (name == null)
+ throw new ArgumentNullException("name");
+ if (name.Length == 0)
+ throw new ArgumentException("name can't be set to an empty string.", "name");
+ if (description == null)
+ throw new ArgumentNullException("description");
+
+ this.result = result;
+ this.name = name;
+ this.description = description;
+ this.actual = actual;
+ this.expected = expected;
+ }
+
+ /// <summary>The outcome of an actual value verified against a Constraint.</summary>
+ public ResultState Result
+ {
+ get { return result; }
+ }
+
+ /// <summary>The name of the Constraint that actual was verified against.</summary>
+ public string Name
+ {
+ get { return name; }
+ }
+
+ /// <summary>Additional description of the reason why an actual value didn't satisfied the Constraint.</summary>
+ /// <remarks>Can be empty if.</remarks>
+ public string Description
+ {
+ get { return description; }
+ }
+
+ /// <summary>The actual value being verified.</summary>
+ public object Actual
+ {
+ get { return actual; }
+ }
+
+ /// <summary>The expected value of actual.</summary>
+ public object Expected
+ {
+ get { return expected; }
+ }
+ }
+}
\ No newline at end of file
=== modified file 'src/framework/Constraints/ContainsConstraint.cs'
--- src/framework/Constraints/ContainsConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/ContainsConstraint.cs 2011-05-12 00:38:23 +0000
@@ -81,15 +81,15 @@
get { this.ignoreCase = true; return this; }
}
- /// <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>
- public override bool Matches(object actual)
+ /// <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>
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
- return this.RealConstraint.Matches( actual );
+ return this.RealConstraint.Verify( actual );
}
/// <summary>
=== modified file 'src/framework/Constraints/DelayedConstraint.cs'
--- src/framework/Constraints/DelayedConstraint.cs 2010-08-02 02:42:35 +0000
+++ src/framework/Constraints/DelayedConstraint.cs 2011-05-12 00:38:23 +0000
@@ -24,6 +24,7 @@
#if !NUNITLITE
using System;
using System.Threading;
+using NUnit.Framework.Api;
namespace NUnit.Framework.Constraints
{
@@ -66,11 +67,11 @@
/// </summary>
/// <param name="actual">The value to be tested</param>
/// <returns>True for if the base constraint fails, false if it succeeds</returns>
- public override bool Matches(object actual)
+ public override ConstraintResult Verify(object actual)
{
Thread.Sleep(delayInMilliseconds);
this.actual = actual;
- return baseConstraint.Matches(actual);
+ return baseConstraint.Verify(actual);
}
/// <summary>
@@ -78,7 +79,7 @@
/// </summary>
/// <param name="del">The delegate whose value is to be tested</param>
/// <returns>True for if the base constraint fails, false if it succeeds</returns>
- public override bool Matches(ActualValueDelegate del)
+ public override ConstraintResult Verify(ActualValueDelegate del)
{
int remainingDelay = delayInMilliseconds;
@@ -87,14 +88,14 @@
remainingDelay -= pollingInterval;
Thread.Sleep(pollingInterval);
this.actual = del();
- if (baseConstraint.Matches(actual))
- return true;
+ if (baseConstraint.Verify(actual).Result == ResultState.Success)
+ return new ConstraintResult(true);
}
if ( remainingDelay > 0 )
Thread.Sleep(remainingDelay);
this.actual = del();
- return baseConstraint.Matches(actual);
+ return baseConstraint.Verify(actual);
}
#if CLR_2_0 || CLR_4_0
@@ -105,7 +106,7 @@
/// </summary>
/// <param name="actual">A reference to the value to be tested</param>
/// <returns>True for success, false for failure</returns>
- public override bool Matches<T>(ref T actual)
+ public override ConstraintResult Verify<T>(ref T actual)
{
int remainingDelay = delayInMilliseconds;
@@ -114,14 +115,14 @@
remainingDelay -= pollingInterval;
Thread.Sleep(pollingInterval);
this.actual = actual;
- if (baseConstraint.Matches(actual))
- return true;
+ if (baseConstraint.Verify(actual).Result == ResultState.Success)
+ return new ConstraintResult(true);
}
if ( remainingDelay > 0 )
Thread.Sleep(remainingDelay);
this.actual = actual;
- return baseConstraint.Matches(actual);
+ return baseConstraint.Verify(actual);
}
#else
/// <summary>
@@ -131,7 +132,7 @@
/// </summary>
/// <param name="actual">A reference to the value to be tested</param>
/// <returns>True for success, false for failure</returns>
- public override bool Matches(ref bool actual)
+ public override bool Verify(ref bool actual)
{
int remainingDelay = delayInMilliseconds;
@@ -140,14 +141,14 @@
remainingDelay -= pollingInterval;
Thread.Sleep(pollingInterval);
this.actual = actual;
- if (baseConstraint.Matches(actual))
+ if (baseConstraint.Verify(actual))
return true;
}
if ( remainingDelay > 0 )
Thread.Sleep(remainingDelay);
this.actual = actual;
- return baseConstraint.Matches(actual);
+ return baseConstraint.Verify(actual);
}
#endif
=== modified file 'src/framework/Constraints/EmptyConstraint.cs'
--- src/framework/Constraints/EmptyConstraint.cs 2010-07-17 13:44:46 +0000
+++ src/framework/Constraints/EmptyConstraint.cs 2011-05-12 00:38:23 +0000
@@ -45,17 +45,17 @@
return new EmptyCollectionConstraint();
}
}
-
- /// <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>
- public override bool Matches(object actual)
+
+ /// <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>
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
- return this.RealConstraint.Matches( actual );
+ return this.RealConstraint.Verify( actual );
}
/// <summary>
=== modified file 'src/framework/Constraints/EmptyDirectoryConstraint.cs'
--- src/framework/Constraints/EmptyDirectoryConstraint.cs 2010-07-17 13:44:46 +0000
+++ src/framework/Constraints/EmptyDirectoryConstraint.cs 2011-05-12 00:38:23 +0000
@@ -39,7 +39,7 @@
/// </summary>
/// <param name="actual">The value to be tested</param>
/// <returns>True for success, false for failure</returns>
- public override bool Matches(object actual)
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
@@ -50,7 +50,7 @@
files = dirInfo.GetFiles().Length;
subdirs = dirInfo.GetDirectories().Length;
- return files == 0 && subdirs == 0;
+ return new ConstraintResult(files == 0 && subdirs == 0);
}
/// <summary>
=== modified file 'src/framework/Constraints/EmptyStringConstraint.cs'
--- src/framework/Constraints/EmptyStringConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/EmptyStringConstraint.cs 2011-05-12 00:38:23 +0000
@@ -33,14 +33,14 @@
/// </summary>
/// <param name="actual">The value to be tested</param>
/// <returns>True for success, false for failure</returns>
- public override bool Matches(object actual)
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
if (!(actual is string))
- return false;
+ return new ConstraintResult(false);
- return (string)actual == string.Empty;
+ return new ConstraintResult((string)actual == string.Empty);
}
/// <summary>
=== modified file 'src/framework/Constraints/EndsWithConstraint.cs'
--- src/framework/Constraints/EndsWithConstraint.cs 2011-04-20 16:40:19 +0000
+++ src/framework/Constraints/EndsWithConstraint.cs 2011-05-12 00:38:23 +0000
@@ -1,67 +1,65 @@
-// ***********************************************************************
-// Copyright (c) 2007 Charlie Poole
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-// ***********************************************************************
-
-namespace NUnit.Framework.Constraints
-{
- /// <summary>
- /// EndsWithConstraint can test whether a string ends
- /// with an expected substring.
- /// </summary>
- public class EndsWithConstraint : StringConstraint
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="T:EndsWithConstraint"/> class.
- /// </summary>
- /// <param name="expected">The expected string</param>
- public EndsWithConstraint(string expected) : base(expected) { }
-
- /// <summary>
- /// Test whether the constraint is matched by the actual value.
- /// This is a template method, which calls the IsMatch method
- /// of the derived class.
- /// </summary>
- /// <param name="actual"></param>
- /// <returns></returns>
- protected override bool Matches(string actual)
- {
- //this.actual = actual;
-
- if (this.caseInsensitive)
- return actual.ToLower().EndsWith(expected.ToLower());
- else
- return actual.EndsWith(expected);
- }
-
- /// <summary>
- /// Write the constraint description to a MessageWriter
- /// </summary>
- /// <param name="writer">The writer on which the description is displayed</param>
- public override void WriteDescriptionTo(MessageWriter writer)
- {
- writer.WritePredicate("String ending with");
- writer.WriteExpectedValue(expected);
- if ( this.caseInsensitive )
- writer.WriteModifier( "ignoring case" );
- }
- }
+// ***********************************************************************
+// Copyright (c) 2007 Charlie Poole
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// ***********************************************************************
+
+namespace NUnit.Framework.Constraints
+{
+ /// <summary>
+ /// EndsWithConstraint can test whether a string ends
+ /// with an expected substring.
+ /// </summary>
+ public class EndsWithConstraint : StringConstraint
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="T:EndsWithConstraint"/> class.
+ /// </summary>
+ /// <param name="expected">The expected string</param>
+ public EndsWithConstraint(string expected) : base(expected) { }
+
+ /// <summary>
+ /// Test whether the constraint is matched by the actual value.
+ /// This is a template method, which calls the IsMatch method
+ /// of the derived class.
+ /// </summary>
+ /// <param name="actual"></param>
+ /// <returns></returns>
+ protected override ConstraintResult Verify(string actual)
+ {
+ if (this.caseInsensitive)
+ return new ConstraintResult(actual.ToLower().EndsWith(expected.ToLower()));
+ else
+ return new ConstraintResult(actual.EndsWith(expected));
+ }
+
+ /// <summary>
+ /// Write the constraint description to a MessageWriter
+ /// </summary>
+ /// <param name="writer">The writer on which the description is displayed</param>
+ public override void WriteDescriptionTo(MessageWriter writer)
+ {
+ writer.WritePredicate("String ending with");
+ writer.WriteExpectedValue(expected);
+ if (this.caseInsensitive)
+ writer.WriteModifier("ignoring case");
+ }
+ }
}
\ No newline at end of file
=== modified file 'src/framework/Constraints/EqualConstraint.cs'
--- src/framework/Constraints/EqualConstraint.cs 2010-08-02 02:42:35 +0000
+++ src/framework/Constraints/EqualConstraint.cs 2011-05-12 00:38:23 +0000
@@ -312,16 +312,17 @@
#endregion
#region Public Methods
+
/// <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>
- public override bool Matches(object actual)
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
- return comparer.ObjectsEqual(expected, actual);
+ return new ConstraintResult(comparer.ObjectsEqual(expected, actual));
}
/// <summary>
=== modified file 'src/framework/Constraints/ExactTypeConstraint.cs'
--- src/framework/Constraints/ExactTypeConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/ExactTypeConstraint.cs 2011-05-12 00:38:23 +0000
@@ -46,10 +46,10 @@
/// </summary>
/// <param name="actual">The actual value.</param>
/// <returns>True if the tested object is of the exact type provided, otherwise false.</returns>
- public override bool Matches(object actual)
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
- return actual != null && actual.GetType() == this.expectedType;
+ return new ConstraintResult(actual != null && actual.GetType() == this.expectedType);
}
/// <summary>
=== modified file 'src/framework/Constraints/FalseConstraint.cs'
--- src/framework/Constraints/FalseConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/FalseConstraint.cs 2011-05-12 00:38:23 +0000
@@ -21,16 +21,51 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************
+using System;
+using NUnit.Framework.Api;
+
namespace NUnit.Framework.Constraints
{
/// <summary>
/// FalseConstraint tests that the actual value is false
/// </summary>
- public class FalseConstraint : BasicConstraint
+ public class FalseConstraint : Constraint
{
- /// <summary>
- /// Initializes a new instance of the <see cref="T:FalseConstraint"/> class.
- /// </summary>
- public FalseConstraint() : base(false, "False") { }
+
+ /// <summary>
+ /// The name of the Constraint.
+ /// </summary>
+ public override string Name
+ {
+ get { return "False"; }
+ }
+
+
+ /// <summary>
+ /// Verifies an actual value against the constraint.
+ /// </summary>
+ /// <param name="actual">The actual value to verify against the constraint.</param>
+ /// <returns>The outcome of the verification of actual value against the constraint.</returns>
+ public override ConstraintResult Verify(object actual)
+ {
+ this.actual = actual;
+ //if (actual == null)
+ // throw new ArgumentNullException("actual", string.Format(verifyExceptionMessageFormat, GetType(), "actual is null."));
+ //if (actual.GetType() == typeof(bool))
+ // throw new ArgumentException(string.Format(verifyExceptionMessageFormat, GetType(), "actual must be of type bool."), "actual");
+
+ ResultState state = false.Equals(actual) ? ResultState.Success : ResultState.Failure;
+ return new ConstraintResult(state, Name, string.Empty, actual, null);
+ }
+
+
+ /// <summary>
+ /// Write the constraint description to a MessageWriter
+ /// </summary>
+ /// <param name="writer">The writer on which the description is displayed</param>
+ public override void WriteDescriptionTo(MessageWriter writer)
+ {
+ writer.Write(Name);
+ }
}
}
\ No newline at end of file
=== modified file 'src/framework/Constraints/GreaterThanConstraint.cs'
--- src/framework/Constraints/GreaterThanConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/GreaterThanConstraint.cs 2011-05-12 00:38:23 +0000
@@ -25,13 +25,13 @@
{
/// <summary>
/// Tests whether a value is greater than the value supplied to its constructor
- /// </summary>
+ /// </summary>
public class GreaterThanConstraint : ComparisonConstraint
{
/// <summary>
/// Initializes a new instance of the <see cref="T:GreaterThanConstraint"/> class.
/// </summary>
/// <param name="expected">The expected value.</param>
- public GreaterThanConstraint(object expected) : base(expected, false, false, true, "greater than") { }
+ public GreaterThanConstraint(object expected) : base(expected, ComparisonResults.Greater) { }
}
}
\ No newline at end of file
=== modified file 'src/framework/Constraints/GreaterThanOrEqualConstraint.cs'
--- src/framework/Constraints/GreaterThanOrEqualConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/GreaterThanOrEqualConstraint.cs 2011-05-12 00:38:23 +0000
@@ -25,13 +25,21 @@
{
/// <summary>
/// Tests whether a value is greater than or equal to the value supplied to its constructor
- /// </summary>
+ /// </summary>
public class GreaterThanOrEqualConstraint : ComparisonConstraint
{
/// <summary>
/// Initializes a new instance of the <see cref="T:GreaterThanOrEqualConstraint"/> class.
/// </summary>
- /// <param name="expected">The expected value.</param>
- public GreaterThanOrEqualConstraint(object expected) : base(expected, false, true, true, "greater than or equal to") { }
+ /// <param name="expected">The expected value.</param>
+ public GreaterThanOrEqualConstraint(object expected) : base(expected, ComparisonResults.Greater | ComparisonResults.Equal) { }
+
+ /// <summary>
+ /// The name of the Constraint.
+ /// </summary>
+ public override string Name
+ {
+ get { return "greater than or equal to"; }
+ }
}
}
\ No newline at end of file
=== modified file 'src/framework/Constraints/InstanceOfTypeConstraint.cs'
--- src/framework/Constraints/InstanceOfTypeConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/InstanceOfTypeConstraint.cs 2011-05-12 00:38:23 +0000
@@ -46,10 +46,10 @@
/// </summary>
/// <param name="actual">The object to be tested</param>
/// <returns>True if the object is of the provided type or derives from it, otherwise false.</returns>
- public override bool Matches(object actual)
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
- return actual != null && expectedType.IsInstanceOfType(actual);
+ return new ConstraintResult(actual != null && expectedType.IsInstanceOfType(actual));
}
/// <summary>
=== modified file 'src/framework/Constraints/LessThanConstraint.cs'
--- src/framework/Constraints/LessThanConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/LessThanConstraint.cs 2011-05-12 00:38:23 +0000
@@ -31,7 +31,7 @@
/// <summary>
/// Initializes a new instance of the <see cref="T:LessThanConstraint"/> class.
/// </summary>
- /// <param name="expected">The expected value.</param>
- public LessThanConstraint(object expected) : base(expected, true, false, false, "less than") { }
+ /// <param name="expected">The expected value.</param>
+ public LessThanConstraint(object expected) : base(expected, ComparisonResults.Less) { }
}
}
\ No newline at end of file
=== modified file 'src/framework/Constraints/LessThanOrEqualConstraint.cs'
--- src/framework/Constraints/LessThanOrEqualConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/LessThanOrEqualConstraint.cs 2011-05-12 00:38:23 +0000
@@ -31,7 +31,15 @@
/// <summary>
/// Initializes a new instance of the <see cref="T:LessThanOrEqualConstraint"/> class.
/// </summary>
- /// <param name="expected">The expected value.</param>
- public LessThanOrEqualConstraint(object expected) : base(expected, true, true, false, "less than or equal to") { }
+ /// <param name="expected">The expected value.</param>
+ public LessThanOrEqualConstraint(object expected) : base(expected, ComparisonResults.Less | ComparisonResults.Equal) { }
+
+ /// <summary>
+ /// The name of the Constraint.
+ /// </summary>
+ public override string Name
+ {
+ get { return "less than or equal to"; }
+ }
}
}
\ No newline at end of file
=== modified file 'src/framework/Constraints/NaNConstraint.cs'
--- src/framework/Constraints/NaNConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/NaNConstraint.cs 2011-05-12 00:38:23 +0000
@@ -21,6 +21,9 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************
+using System;
+using NUnit.Framework.Api;
+
namespace NUnit.Framework.Constraints
{
/// <summary>
@@ -28,26 +31,41 @@
/// </summary>
public class NaNConstraint : Constraint
{
- /// <summary>
- /// Test that the actual value is an NaN
- /// </summary>
- /// <param name="actual"></param>
- /// <returns></returns>
- public override bool Matches(object actual)
+
+ /// <summary>
+ /// The name of the Constraint.
+ /// </summary>
+ public override string Name
+ {
+ get { return "NaN"; }
+ }
+
+
+ /// <summary>
+ /// Verifies an actual value against the constraint.
+ /// </summary>
+ /// <param name="actual">The actual value to verify against the constraint.</param>
+ /// <returns>The outcome of the verification of actual value against the constraint.</returns>
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
+ //if (actual == null)
+ // throw new ArgumentNullException("actual", string.Format(verifyExceptionMessageFormat, GetType(), "actual is null."));
- return actual is double && double.IsNaN((double)actual)
- || actual is float && float.IsNaN((float)actual);
+ ResultState state = actual is double && double.IsNaN((double)actual) ||
+ actual is float && float.IsNaN((float)actual) ?
+ ResultState.Success : ResultState.Failure;
+ return new ConstraintResult(state, Name, string.Empty, actual, null);
}
+
/// <summary>
- /// Write the constraint description to a specified writer
+ /// Write the constraint description to a MessageWriter
/// </summary>
- /// <param name="writer"></param>
+ /// <param name="writer">The writer on which the description is displayed</param>
public override void WriteDescriptionTo(MessageWriter writer)
{
- writer.Write("NaN");
+ writer.Write(Name);
}
}
}
\ No newline at end of file
=== modified file 'src/framework/Constraints/NoItemConstraint.cs'
--- src/framework/Constraints/NoItemConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/NoItemConstraint.cs 2011-05-12 00:38:23 +0000
@@ -23,6 +23,7 @@
using System;
using System.Collections;
+using NUnit.Framework.Api;
namespace NUnit.Framework.Constraints
{
@@ -42,13 +43,13 @@
this.DisplayName = "none";
}
- /// <summary>
- /// Apply the item constraint to each item in the collection,
- /// failing if any item fails.
- /// </summary>
- /// <param name="actual"></param>
- /// <returns></returns>
- public override bool Matches(object actual)
+ /// <summary>
+ /// Apply the item constraint to each item in the collection,
+ /// failing if any item fails.
+ /// </summary>
+ /// <param name="actual"></param>
+ /// <returns></returns>
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
@@ -56,10 +57,10 @@
throw new ArgumentException( "The actual value must be an IEnumerable", "actual" );
foreach(object item in (IEnumerable)actual)
- if (baseConstraint.Matches(item))
- return false;
+ if (baseConstraint.Verify(item).Result == ResultState.Success)
+ return new ConstraintResult(false);
- return true;
+ return new ConstraintResult(true);
}
/// <summary>
=== modified file 'src/framework/Constraints/NotConstraint.cs'
--- src/framework/Constraints/NotConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/NotConstraint.cs 2011-05-12 00:38:23 +0000
@@ -21,6 +21,8 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************
+using NUnit.Framework.Api;
+
namespace NUnit.Framework.Constraints
{
/// <summary>
@@ -35,15 +37,19 @@
public NotConstraint(Constraint baseConstraint)
: base( baseConstraint ) { }
- /// <summary>
- /// Test whether the constraint is satisfied by a given value
- /// </summary>
- /// <param name="actual">The value to be tested</param>
- /// <returns>True for if the base constraint fails, false if it succeeds</returns>
- public override bool Matches(object actual)
+ /// <summary>
+ /// Test whether the constraint is satisfied by a given value
+ /// </summary>
+ /// <param name="actual">The value to be tested</param>
+ /// <returns>True for if the base constraint fails, false if it succeeds</returns>
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
- return !baseConstraint.Matches(actual);
+
+ // Temporary now result with ActualCanNotBeVerified does not exits in this stage of the refactoring
+ ConstraintResult cr = baseConstraint.Verify(actual);
+ bool newResult = cr.Result == ResultState.Success ? false : true;
+ return new ConstraintResult(newResult);
}
/// <summary>
=== modified file 'src/framework/Constraints/NullConstraint.cs'
--- src/framework/Constraints/NullConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/NullConstraint.cs 2011-05-12 00:38:23 +0000
@@ -21,16 +21,36 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************
+using NUnit.Framework.Api;
+
namespace NUnit.Framework.Constraints
{
/// <summary>
/// NullConstraint tests that the actual value is null
/// </summary>
- public class NullConstraint : BasicConstraint
+ public class NullConstraint : Constraint
{
- /// <summary>
- /// Initializes a new instance of the <see cref="T:NullConstraint"/> class.
- /// </summary>
- public NullConstraint() : base(null, "null") { }
+
+ /// <summary>
+ /// Verifies an actual value against the constraint.
+ /// </summary>
+ /// <param name="actual">The actual value to verify against the constraint.</param>
+ /// <returns>The outcome of the verification of actual value against the constraint.</returns>
+ public override ConstraintResult Verify(object actual)
+ {
+ this.actual = actual;
+ ResultState state = ReferenceEquals(actual, null) ? ResultState.Success : ResultState.Failure;
+ return new ConstraintResult(state, Name, string.Empty, actual, null);
+ }
+
+
+ /// <summary>
+ /// Write the constraint description to a MessageWriter
+ /// </summary>
+ /// <param name="writer">The writer on which the description is displayed</param>
+ public override void WriteDescriptionTo(MessageWriter writer)
+ {
+ writer.Write(Name);
+ }
}
}
\ No newline at end of file
=== modified file 'src/framework/Constraints/NullOrEmptyStringConstraint.cs'
--- src/framework/Constraints/NullOrEmptyStringConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/NullOrEmptyStringConstraint.cs 2011-05-12 00:38:23 +0000
@@ -43,17 +43,17 @@
/// </summary>
/// <param name="actual">The value to be tested</param>
/// <returns>True for success, false for failure</returns>
- public override bool Matches(object actual)
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
if (actual == null)
- return true;
+ return new ConstraintResult(true);
if (!(actual is string))
throw new ArgumentException("Actual value must be a string", "actual");
- return (string)actual == string.Empty;
+ return new ConstraintResult((string)actual == string.Empty);
}
/// <summary>
=== modified file 'src/framework/Constraints/OrConstraint.cs'
--- src/framework/Constraints/OrConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/OrConstraint.cs 2011-05-12 00:38:23 +0000
@@ -20,6 +20,8 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+using NUnit.Framework.Api;
+
namespace NUnit.Framework.Constraints
{
/// <summary>
@@ -34,16 +36,23 @@
/// <param name="right">The second constraint</param>
public OrConstraint(Constraint left, Constraint right) : base(left, right) { }
- /// <summary>
- /// Apply the member constraints to an actual value, succeeding
- /// succeeding as soon as one of them succeeds.
- /// </summary>
- /// <param name="actual">The actual value</param>
- /// <returns>True if either constraint succeeded</returns>
- public override bool Matches(object actual)
+ /// <summary>
+ /// Apply the member constraints to an actual value, succeeding
+ /// succeeding as soon as one of them succeeds.
+ /// </summary>
+ /// <param name="actual">The actual value</param>
+ /// <returns>True if either constraint succeeded</returns>
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
- return Left.Matches(actual) || Right.Matches(actual);
+
+
+ // Temporary now result with ActualCanNotBeVerified does not exits in this stage of the refactoring
+ ConstraintResult left = Left.Verify(actual);
+ ConstraintResult right = Right.Verify(actual);
+
+ return new ConstraintResult(left.Result == ResultState.Success ?
+ true : right.Result == ResultState.Success ? true : false);
}
/// <summary>
=== modified file 'src/framework/Constraints/PredicateConstraint.cs'
--- src/framework/Constraints/PredicateConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/PredicateConstraint.cs 2011-05-12 00:38:23 +0000
@@ -47,14 +47,14 @@
/// Determines whether the predicate succeeds when applied
/// to the actual value.
/// </summary>
- public override bool Matches(object actual)
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
if (!(actual is T))
throw new ArgumentException("The actual value is not of type " + typeof(T).Name, "actual");
- return predicate((T)actual);
+ return new ConstraintResult(predicate((T)actual));
}
/// <summary>
=== modified file 'src/framework/Constraints/PropertyConstraint.cs'
--- src/framework/Constraints/PropertyConstraint.cs 2010-09-19 16:45:44 +0000
+++ src/framework/Constraints/PropertyConstraint.cs 2011-05-12 00:38:23 +0000
@@ -47,12 +47,12 @@
this.name = name;
}
- /// <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>
- public override bool Matches(object actual)
+ /// <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>
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
if (actual == null)
@@ -69,7 +69,7 @@
throw new ArgumentException(string.Format("Property {0} was not found",name), "name");
propValue = property.GetValue( actual, null );
- return baseConstraint.Matches( propValue );
+ return baseConstraint.Verify( propValue );
}
/// <summary>
=== modified file 'src/framework/Constraints/PropertyExistsConstraint.cs'
--- src/framework/Constraints/PropertyExistsConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/PropertyExistsConstraint.cs 2011-05-12 00:38:23 +0000
@@ -55,7 +55,7 @@
/// </summary>
/// <param name="actual">The object to be tested</param>
/// <returns>True for success, false for failure</returns>
- public override bool Matches(object actual)
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
@@ -69,7 +69,7 @@
PropertyInfo property = actualType.GetProperty(name,
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetProperty);
- return property != null;
+ return new ConstraintResult(property != null);
}
/// <summary>
=== modified file 'src/framework/Constraints/RangeConstraint.cs'
--- src/framework/Constraints/RangeConstraint.cs 2010-09-19 16:45:44 +0000
+++ src/framework/Constraints/RangeConstraint.cs 2011-05-12 00:38:23 +0000
@@ -1,109 +1,162 @@
-// ***********************************************************************
-// Copyright (c) 2008 Charlie Poole
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-// ***********************************************************************
-
-using System;
-using System.Collections;
-#if CLR_2_0 || CLR_4_0
-using System.Collections.Generic;
-#endif
-
-namespace NUnit.Framework.Constraints
-{
- /// <summary>
- /// RangeConstraint tests whethe two values are within a
- /// specified range.
- /// </summary>
- public class RangeConstraint : Constraint
- {
- private readonly IComparable from;
- private readonly IComparable to;
-
- private ComparisonAdapter comparer = ComparisonAdapter.Default;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="T:RangeConstraint"/> class.
- /// </summary>
- /// <param name="from">From.</param>
- /// <param name="to">To.</param>
- public RangeConstraint(IComparable from, IComparable to) : base( from, to )
- {
- this.from = from;
- this.to = to;
- }
-
- /// <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>
- public override bool Matches(object actual)
- {
- this.actual = actual;
-
- if ( from == null || to == null || actual == null)
- throw new ArgumentException( "Cannot compare using a null reference", "expected" );
-
- return comparer.Compare(from, actual) <= 0 &&
- comparer.Compare(to, actual) >= 0;
- }
-
- /// <summary>
- /// Write the constraint description to a MessageWriter
- /// </summary>
- /// <param name="writer">The writer on which the description is displayed</param>
- public override void WriteDescriptionTo(MessageWriter writer)
- {
-
- writer.Write("in range ({0},{1})", from, to);
- }
-
- /// <summary>
- /// Modifies the constraint to use an IComparer and returns self.
- /// </summary>
- public RangeConstraint Using(IComparer comparer)
- {
- this.comparer = ComparisonAdapter.For(comparer);
- return this;
- }
-
-#if CLR_2_0 || CLR_4_0
- /// <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 a Comparison<T> and returns self.
- /// </summary>
- public RangeConstraint Using<T>(Comparison<T> comparer)
- {
- this.comparer = ComparisonAdapter.For(comparer);
- return this;
- }
-#endif
- }
-}
+// ***********************************************************************
+// Copyright (c) 2008 Charlie Poole
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// ***********************************************************************
+
+using System;
+using NUnit.Framework.Api;
+
+namespace NUnit.Framework.Constraints
+{
+ /// <summary>
+ /// RangeConstraint tests whethe two values are within a
+ /// specified range.
+ /// </summary>
+ public class RangeConstraint : Constraint
+ {
+ private readonly IComparable from;
+ private readonly IComparable to;
+
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="T:RangeConstraint"/> class.
+ /// </summary>
+ /// <param name="from">From.</param>
+ /// <param name="to">To.</param>
+ public RangeConstraint(IComparable from, IComparable to)
+ : base(from, to)
+ {
+ if (ReferenceEquals(from, null))
+ throw new ArgumentNullException("from", GetType().Name + " can't be setup since argument from is null.");
+
+ if (ReferenceEquals(to, null))
+ throw new ArgumentNullException("to", GetType().Name + " can't be setup since argument to is null.");
+
+
+ int fromToComparisonResult = GetCompareToResultBetweenFromAndToThrowIfFails(from, to);
+ if (fromToComparisonResult > 0)
+ throw new ArgumentException(GetType().Name + " can't be setup since argument from is greater than argument to.", "from");
+
+ this.from = from;
+ this.to = to;
+ }
+
+
+ private int GetCompareToResultBetweenFromAndToThrowIfFails(IComparable from, IComparable to)
+ {
+ if (NumericComparison.IsNumericComparisonPossible(from, to))
+ {
+ return NumericComparison.Compare(from, to);
+ }
+
+ int fromToComparisonResult;
+ try
+ {
+ fromToComparisonResult = from.CompareTo(to);
+ }
+ catch (Exception ex)
+ {
+ throw new ArgumentException(GetType().Name + " can't be setup since from's CompareTo method throw an exception.", "from", ex);
+ }
+
+ int toFromComparisonResult;
+ try
+ {
+ toFromComparisonResult = to.CompareTo(from);
+ }
+ catch (Exception ex)
+ {
+ throw new ArgumentException(GetType().Name + " can't be setup since to's CompareTo method throw an exception.", "to", ex);
+ }
+
+ if (FromAndToCompareToDoesNotYieldTheSameResult(fromToComparisonResult, toFromComparisonResult))
+ throw new ArgumentException(GetType().Name + " can't be setup since ambiguous was detected between from's and to's CompareTo methods.", "from");
+
+ return fromToComparisonResult;
+ }
+
+
+ private static bool FromAndToCompareToDoesNotYieldTheSameResult(int fromCompareTo, int toCompareTo)
+ {
+ return (fromCompareTo < 0 && toCompareTo < 0) || (fromCompareTo == 0 && toCompareTo != 0) || (fromCompareTo > 0 && toCompareTo > 0);
+ }
+
+
+
+ /// <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>
+ public override ConstraintResult Verify(object actual)
+ {
+ if (ReferenceEquals(actual, null))
+ throw new ArgumentNullException("actual", GetType().Name + " Verify method can't be performed since actual is null.");
+
+ this.actual = actual;
+
+ bool isInRange = GreaterOrEqualThanFrom(actual) && LessOrEqualThanTo(actual);
+ return new ConstraintResult(isInRange ? ResultState.Success : ResultState.Failure, Name, string.Empty, actual, "in range (" + from + "," + to + ")");
+ }
+
+
+ private bool GreaterOrEqualThanFrom(object actual)
+ {
+ try
+ {
+ int result = NumericComparison.IsNumericComparisonPossible(from, actual) ?
+ NumericComparison.Compare(from, actual) : from.CompareTo(actual);
+
+ return result <= 0;
+ }
+ catch (Exception ex)
+ {
+ throw new ArgumentException(GetType().Name + " Verify method can't be performed since from's CompareTo method throw an exception.", "actual", ex);
+ }
+ }
+
+ private bool LessOrEqualThanTo(object actual)
+ {
+ try
+ {
+ int result = NumericComparison.IsNumericComparisonPossible(to, actual)
+ ? NumericComparison.Compare(to, actual)
+ : to.CompareTo(actual);
+
+ return result >= 0;
+ }
+ catch (Exception ex)
+ {
+ throw new ArgumentException(GetType().Name + " Verify method can't be performed since to's CompareTo method throw an exception.", "actual", ex);
+ }
+ }
+
+
+ /// <summary>
+ /// Write the constraint description to a MessageWriter
+ /// </summary>
+ /// <param name="writer">The writer on which the description is displayed</param>
+ public override void WriteDescriptionTo(MessageWriter writer)
+ {
+ writer.Write("in range ({0},{1})", from, to);
+ }
+ }
+}
\ No newline at end of file
=== modified file 'src/framework/Constraints/RegexConstraint.cs'
--- src/framework/Constraints/RegexConstraint.cs 2011-04-20 16:40:19 +0000
+++ src/framework/Constraints/RegexConstraint.cs 2011-05-12 00:38:23 +0000
@@ -1,71 +1,70 @@
-// ***********************************************************************
-// Copyright (c) 2007 Charlie Poole
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-// ***********************************************************************
-
-#if !NETCF
-using System.Text.RegularExpressions;
-#endif
-
-namespace NUnit.Framework.Constraints
-{
-#if !NETCF
- /// <summary>
- /// RegexConstraint can test whether a string matches
- /// the pattern provided.
- /// </summary>
- public class RegexConstraint : StringConstraint
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="T:RegexConstraint"/> class.
- /// </summary>
- /// <param name="pattern">The pattern.</param>
- public RegexConstraint(string pattern) : base(pattern) { }
-
- /// <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 bool Matches(string actual)
- {
- //this.actual = actual;
-
- return Regex.IsMatch(
- actual,
- this.expected,
- this.caseInsensitive ? RegexOptions.IgnoreCase : RegexOptions.None);
- }
-
- /// <summary>
- /// Write the constraint description to a MessageWriter
- /// </summary>
- /// <param name="writer">The writer on which the description is displayed</param>
- public override void WriteDescriptionTo(MessageWriter writer)
- {
- writer.WritePredicate("String matching");
- writer.WriteExpectedValue(this.expected);
- if ( this.caseInsensitive )
- writer.WriteModifier( "ignoring case" );
- }
- }
-#endif
+// ***********************************************************************
+// Copyright (c) 2007 Charlie Poole
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// ***********************************************************************
+
+#if !NETCF
+using System.Text.RegularExpressions;
+#endif
+
+namespace NUnit.Framework.Constraints
+{
+#if !NETCF
+ /// <summary>
+ /// RegexConstraint can test whether a string matches
+ /// the pattern provided.
+ /// </summary>
+ public class RegexConstraint : StringConstraint
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="T:RegexConstraint"/> class.
+ /// </summary>
+ /// <param name="pattern">The pattern.</param>
+ public RegexConstraint(string pattern) : base(pattern) { }
+
+ /// <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 Verify(string actual)
+ {
+ return new ConstraintResult(
+ Regex.IsMatch(
+ actual,
+ expected,
+ caseInsensitive ? RegexOptions.IgnoreCase : RegexOptions.None));
+ }
+
+ /// <summary>
+ /// Write the constraint description to a MessageWriter
+ /// </summary>
+ /// <param name="writer">The writer on which the description is displayed</param>
+ public override void WriteDescriptionTo(MessageWriter writer)
+ {
+ writer.WritePredicate("String matching");
+ writer.WriteExpectedValue(this.expected);
+ if (this.caseInsensitive)
+ writer.WriteModifier("ignoring case");
+ }
+ }
+#endif
}
\ No newline at end of file
=== modified file 'src/framework/Constraints/SameAsConstraint.cs'
--- src/framework/Constraints/SameAsConstraint.cs 2010-09-19 16:45:44 +0000
+++ src/framework/Constraints/SameAsConstraint.cs 2011-05-12 00:38:23 +0000
@@ -47,15 +47,15 @@
/// </summary>
/// <param name="actual">The value to be tested</param>
/// <returns>True for success, false for failure</returns>
- public override bool Matches(object actual)
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
#if NETCF_1_0
// TODO: THis makes it compile, now make it work.
- return expected.Equals(actual);
+ return new ConstraintResult(expected.Equals(actual));
#else
- return Object.ReferenceEquals(expected, actual);
+ return new ConstraintResult(Object.ReferenceEquals(expected, actual));
#endif
}
=== modified file 'src/framework/Constraints/SamePathConstraint.cs'
--- src/framework/Constraints/SamePathConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/SamePathConstraint.cs 2011-05-12 00:38:23 +0000
@@ -39,14 +39,14 @@
/// </summary>
/// <param name="actual">The value to be tested</param>
/// <returns>True for success, false for failure</returns>
- public override bool Matches(object actual)
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
if ( !(actual is string) )
- return false;
+ return new ConstraintResult(false);
- return IsSamePath( expected, (string)actual );
+ return new ConstraintResult(IsSamePath(expected, (string)actual));
}
/// <summary>
=== modified file 'src/framework/Constraints/SamePathOrUnderConstraint.cs'
--- src/framework/Constraints/SamePathOrUnderConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/SamePathOrUnderConstraint.cs 2011-05-12 00:38:23 +0000
@@ -39,14 +39,14 @@
/// </summary>
/// <param name="actual">The value to be tested</param>
/// <returns>True for success, false for failure</returns>
- public override bool Matches(object actual)
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
if ( !(actual is string) )
- return false;
+ return new ConstraintResult(false);
- return IsSamePathOrUnder( expected, (string) actual );
+ return new ConstraintResult(IsSamePathOrUnder( expected, (string) actual ));
}
/// <summary>
=== modified file 'src/framework/Constraints/SomeItemsConstraint.cs'
--- src/framework/Constraints/SomeItemsConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/SomeItemsConstraint.cs 2011-05-12 00:38:23 +0000
@@ -23,6 +23,7 @@
using System;
using System.Collections;
+using NUnit.Framework.Api;
namespace NUnit.Framework.Constraints
{
@@ -42,13 +43,13 @@
this.DisplayName = "some";
}
- /// <summary>
- /// Apply the item constraint to each item in the collection,
- /// succeeding if any item succeeds.
- /// </summary>
- /// <param name="actual"></param>
- /// <returns></returns>
- public override bool Matches(object actual)
+ /// <summary>
+ /// Apply the item constraint to each item in the collection,
+ /// succeeding if any item succeeds.
+ /// </summary>
+ /// <param name="actual"></param>
+ /// <returns></returns>
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
@@ -56,10 +57,10 @@
throw new ArgumentException( "The actual value must be an IEnumerable", "actual" );
foreach(object item in (IEnumerable)actual)
- if (baseConstraint.Matches(item))
- return true;
+ if (baseConstraint.Verify(item).Result == ResultState.Success)
+ return new ConstraintResult(true);
- return false;
+ return new ConstraintResult(false);
}
/// <summary>
=== modified file 'src/framework/Constraints/StartsWithConstraint.cs'
--- src/framework/Constraints/StartsWithConstraint.cs 2011-04-20 16:40:19 +0000
+++ src/framework/Constraints/StartsWithConstraint.cs 2011-05-12 00:38:23 +0000
@@ -1,67 +1,65 @@
-// ***********************************************************************
-// Copyright (c) 2007 Charlie Poole
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-// ***********************************************************************
-
-namespace NUnit.Framework.Constraints
-{
- /// <summary>
- /// StartsWithConstraint can test whether a string starts
- /// with an expected substring.
- /// </summary>
- public class StartsWithConstraint : StringConstraint
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="T:StartsWithConstraint"/> class.
- /// </summary>
- /// <param name="expected">The expected string</param>
- public StartsWithConstraint(string expected) : base(expected) { }
-
- /// <summary>
- /// Test whether the constraint is matched by the actual value.
- /// This is a template method, which calls the IsMatch method
- /// of the derived class.
- /// </summary>
- /// <param name="actual"></param>
- /// <returns></returns>
- protected override bool Matches(string actual)
- {
- //this.actual = actual;
-
- if (this.caseInsensitive)
- return actual.ToLower().StartsWith(expected.ToLower());
- else
- return actual.StartsWith(expected);
- }
-
- /// <summary>
- /// Write the constraint description to a MessageWriter
- /// </summary>
- /// <param name="writer">The writer on which the description is displayed</param>
- public override void WriteDescriptionTo(MessageWriter writer)
- {
- writer.WritePredicate("String starting with");
- writer.WriteExpectedValue( MsgUtils.ClipString(expected, writer.MaxLineLength - 40, 0) );
- if ( this.caseInsensitive )
- writer.WriteModifier( "ignoring case" );
- }
- }
+// ***********************************************************************
+// Copyright (c) 2007 Charlie Poole
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// ***********************************************************************
+
+namespace NUnit.Framework.Constraints
+{
+ /// <summary>
+ /// StartsWithConstraint can test whether a string starts
+ /// with an expected substring.
+ /// </summary>
+ public class StartsWithConstraint : StringConstraint
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="T:StartsWithConstraint"/> class.
+ /// </summary>
+ /// <param name="expected">The expected string</param>
+ public StartsWithConstraint(string expected) : base(expected) { }
+
+ /// <summary>
+ /// Test whether the constraint is matched by the actual value.
+ /// This is a template method, which calls the IsMatch method
+ /// of the derived class.
+ /// </summary>
+ /// <param name="actual"></param>
+ /// <returns></returns>
+ protected override ConstraintResult Verify(string actual)
+ {
+ if (caseInsensitive)
+ return new ConstraintResult(actual.ToLower().StartsWith(expected.ToLower()));
+ else
+ return new ConstraintResult(actual.StartsWith(expected));
+ }
+
+ /// <summary>
+ /// Write the constraint description to a MessageWriter
+ /// </summary>
+ /// <param name="writer">The writer on which the description is displayed</param>
+ public override void WriteDescriptionTo(MessageWriter writer)
+ {
+ writer.WritePredicate("String starting with");
+ writer.WriteExpectedValue(MsgUtils.ClipString(expected, writer.MaxLineLength - 40, 0));
+ if (this.caseInsensitive)
+ writer.WriteModifier("ignoring case");
+ }
+ }
}
\ No newline at end of file
=== modified file 'src/framework/Constraints/StringConstraint.cs'
--- src/framework/Constraints/StringConstraint.cs 2011-04-20 16:40:19 +0000
+++ src/framework/Constraints/StringConstraint.cs 2011-05-12 00:38:23 +0000
@@ -58,21 +58,29 @@
get { caseInsensitive = true; return this; }
}
- /// <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>
- public override bool Matches(object actual)
- {
- this.actual = actual;
-
- if (!(actual is string))
- return false;
-
- return Matches((string)actual);
- }
-
- protected abstract bool Matches(string actual);
+ /// <summary>
+ /// Test whether the constraint is matched by the actual value.
+ /// This is a template method, which calls the IsMatch method
+ /// of the derived class.
+ /// </summary>
+ /// <param name="actual"></param>
+ /// <returns></returns>
+ public override ConstraintResult Verify(object actual)
+ {
+ this.actual = actual;
+
+ string actualAsString = actual as string;
+ if (actualAsString == null)
+ return new ConstraintResult(false);
+
+ return Verify(actualAsString);
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="actual"></param>
+ /// <returns></returns>
+ protected abstract ConstraintResult Verify(string actual);
}
}
\ No newline at end of file
=== modified file 'src/framework/Constraints/SubstringConstraint.cs'
--- src/framework/Constraints/SubstringConstraint.cs 2011-04-20 16:40:19 +0000
+++ src/framework/Constraints/SubstringConstraint.cs 2011-05-12 00:38:23 +0000
@@ -1,65 +1,63 @@
-// ***********************************************************************
-// Copyright (c) 2007 Charlie Poole
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-// ***********************************************************************
-
-namespace NUnit.Framework.Constraints
-{
- /// <summary>
- /// SubstringConstraint can test whether a string contains
- /// the expected substring.
- /// </summary>
- public class SubstringConstraint : StringConstraint
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="T:SubstringConstraint"/> class.
- /// </summary>
- /// <param name="expected">The expected.</param>
- public SubstringConstraint(string expected) : base(expected) { }
-
- /// <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 bool Matches(string actual)
- {
- //this.actual = actual;
-
- if (this.caseInsensitive)
- return actual.ToLower().IndexOf(expected.ToLower()) >= 0;
- else
- return actual.IndexOf(expected) >= 0;
- }
-
- /// <summary>
- /// Write the constraint description to a MessageWriter
- /// </summary>
- /// <param name="writer">The writer on which the description is displayed</param>
- public override void WriteDescriptionTo(MessageWriter writer)
- {
- writer.WritePredicate("String containing");
- writer.WriteExpectedValue(expected);
- if ( this.caseInsensitive )
- writer.WriteModifier( "ignoring case" );
- }
- }
+// ***********************************************************************
+// Copyright (c) 2007 Charlie Poole
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// ***********************************************************************
+
+namespace NUnit.Framework.Constraints
+{
+ /// <summary>
+ /// SubstringConstraint can test whether a string contains
+ /// the expected substring.
+ /// </summary>
+ public class SubstringConstraint : StringConstraint
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="T:SubstringConstraint"/> class.
+ /// </summary>
+ /// <param name="expected">The expected.</param>
+ public SubstringConstraint(string expected) : base(expected) { }
+
+ /// <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 Verify(string actual)
+ {
+ if (caseInsensitive)
+ return new ConstraintResult(actual.ToLower().IndexOf(expected.ToLower()) >= 0);
+ else
+ return new ConstraintResult(actual.IndexOf(expected) >= 0);
+ }
+
+ /// <summary>
+ /// Write the constraint description to a MessageWriter
+ /// </summary>
+ /// <param name="writer">The writer on which the description is displayed</param>
+ public override void WriteDescriptionTo(MessageWriter writer)
+ {
+ writer.WritePredicate("String containing");
+ writer.WriteExpectedValue(expected);
+ if (this.caseInsensitive)
+ writer.WriteModifier("ignoring case");
+ }
+ }
}
\ No newline at end of file
=== modified file 'src/framework/Constraints/ThrowsConstraint.cs'
--- src/framework/Constraints/ThrowsConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/ThrowsConstraint.cs 2011-05-12 00:38:23 +0000
@@ -50,6 +50,7 @@
}
#region Constraint Overrides
+
/// <summary>
/// Executes the code of the delegate and captures any exception.
/// If a non-null base constraint was provided, it applies that
@@ -57,7 +58,7 @@
/// </summary>
/// <param name="actual">A delegate representing the code to be tested</param>
/// <returns>True if an exception is thrown and the constraint succeeds, otherwise false</returns>
- public override bool Matches(object actual)
+ public override ConstraintResult Verify(object actual)
{
TestDelegate code = actual as TestDelegate;
if (code == null)
@@ -76,9 +77,9 @@
}
if (this.caughtException == null)
- return false;
+ return new ConstraintResult(false);
- return baseConstraint == null || baseConstraint.Matches(caughtException);
+ return baseConstraint == null ? new ConstraintResult(true) : baseConstraint.Verify(caughtException);
}
#if CLR_2_0 || CLR_4_0
@@ -88,10 +89,10 @@
/// </summary>
/// <param name="del"></param>
/// <returns></returns>
- public override bool Matches(ActualValueDelegate del)
+ public override ConstraintResult Verify(ActualValueDelegate del)
{
TestDelegate testDelegate = new TestDelegate(delegate { del(); });
- return Matches((object)testDelegate);
+ return Verify((object)testDelegate);
}
#endif
=== modified file 'src/framework/Constraints/ThrowsNothingConstraint.cs'
--- src/framework/Constraints/ThrowsNothingConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/ThrowsNothingConstraint.cs 2011-05-12 00:38:23 +0000
@@ -38,7 +38,7 @@
/// </summary>
/// <param name="actual">The value to be tested</param>
/// <returns>True if no exception is thrown, otherwise false</returns>
- public override bool Matches(object actual)
+ public override ConstraintResult Verify(object actual)
{
TestDelegate code = actual as TestDelegate;
if (code == null)
@@ -55,7 +55,7 @@
this.caughtException = ex;
}
- return this.caughtException == null;
+ return new ConstraintResult(this.caughtException == null);
}
/// <summary>
@@ -79,4 +79,4 @@
writer.WriteActualValue(this.caughtException.GetType());
}
}
-}
+}
\ No newline at end of file
=== modified file 'src/framework/Constraints/ToleranceMode.cs'
--- src/framework/Constraints/ToleranceMode.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/ToleranceMode.cs 2011-05-12 00:38:23 +0000
@@ -21,31 +21,34 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************
-/// <summary>
-/// Modes in which the tolerance value for a comparison can be interpreted.
-/// </summary>
-public enum ToleranceMode
+namespace NUnit.Framework.Constraints
{
/// <summary>
- /// The tolerance was created with a value, without specifying
- /// how the value would be used. This is used to prevent setting
- /// the mode more than once and is generally changed to Linear
- /// upon execution of the test.
- /// </summary>
- None,
- /// <summary>
- /// The tolerance is used as a numeric range within which
- /// two compared values are considered to be equal.
- /// </summary>
- Linear,
- /// <summary>
- /// Interprets the tolerance as the percentage by which
- /// the two compared values my deviate from each other.
- /// </summary>
- Percent,
- /// <summary>
- /// Compares two values based in their distance in
- /// representable numbers.
- /// </summary>
- Ulps
+ /// Modes in which the tolerance value for a comparison can be interpreted.
+ /// </summary>
+ public enum ToleranceMode
+ {
+ /// <summary>
+ /// The tolerance was created with a value, without specifying
+ /// how the value would be used. This is used to prevent setting
+ /// the mode more than once and is generally changed to Linear
+ /// upon execution of the test.
+ /// </summary>
+ None,
+ /// <summary>
+ /// The tolerance is used as a numeric range within which
+ /// two compared values are considered to be equal.
+ /// </summary>
+ Linear,
+ /// <summary>
+ /// Interprets the tolerance as the percentage by which
+ /// the two compared values my deviate from each other.
+ /// </summary>
+ Percent,
+ /// <summary>
+ /// Compares two values based in their distance in
+ /// representable numbers.
+ /// </summary>
+ Ulps
+ }
}
\ No newline at end of file
=== modified file 'src/framework/Constraints/TrueConstraint.cs'
--- src/framework/Constraints/TrueConstraint.cs 2011-03-31 17:46:09 +0000
+++ src/framework/Constraints/TrueConstraint.cs 2011-05-12 00:38:23 +0000
@@ -21,16 +21,50 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************
+using NUnit.Framework.Api;
+
namespace NUnit.Framework.Constraints
{
/// <summary>
/// TrueConstraint tests that the actual value is true
/// </summary>
- public class TrueConstraint : BasicConstraint
+ public class TrueConstraint : Constraint
{
- /// <summary>
- /// Initializes a new instance of the <see cref="T:TrueConstraint"/> class.
- /// </summary>
- public TrueConstraint() : base(true, "True") { }
+
+ /// <summary>
+ /// The name of the Constraint.
+ /// </summary>
+ public override string Name
+ {
+ get { return "True"; }
+ }
+
+
+ /// <summary>
+ /// Verifies an actual value against the constraint.
+ /// </summary>
+ /// <param name="actual">The actual value to verify against the constraint.</param>
+ /// <returns>The outcome of the verification of actual value against the constraint.</returns>
+ public override ConstraintResult Verify(object actual)
+ {
+ this.actual = actual;
+ //if (actual == null)
+ // throw new ArgumentNullException("actual", string.Format(verifyExceptionMessageFormat, GetType(), "actual is null."));
+ //if (actual.GetType() == typeof(bool))
+ // throw new ArgumentException(string.Format(verifyExceptionMessageFormat, GetType(), "actual must be of type bool."), "actual");
+
+ ResultState state = true.Equals(actual) ? ResultState.Success : ResultState.Failure;
+ return new ConstraintResult(state, Name, string.Empty, actual, null);
+ }
+
+
+ /// <summary>
+ /// Write the constraint description to a MessageWriter
+ /// </summary>
+ /// <param name="writer">The writer on which the description is displayed</param>
+ public override void WriteDescriptionTo(MessageWriter writer)
+ {
+ writer.Write(Name);
+ }
}
}
\ No newline at end of file
=== modified file 'src/framework/Constraints/XmlSerializableConstraint.cs'
--- src/framework/Constraints/XmlSerializableConstraint.cs 2010-07-26 18:53:17 +0000
+++ src/framework/Constraints/XmlSerializableConstraint.cs 2011-05-12 00:38:23 +0000
@@ -44,7 +44,7 @@
/// </summary>
/// <param name="actual">The value to be tested</param>
/// <returns>True for success, false for failure</returns>
- public override bool Matches(object actual)
+ public override ConstraintResult Verify(object actual)
{
this.actual = actual;
@@ -63,15 +63,15 @@
object value = serializer.Deserialize(stream);
- return value != null;
+ return new ConstraintResult(value != null);
}
catch (NotSupportedException)
{
- return false;
+ return new ConstraintResult(false);
}
catch (InvalidOperationException)
{
- return false;
+ return new ConstraintResult(false);
}
}
=== added file 'src/framework/Internal/NumericComparison.cs'
--- src/framework/Internal/NumericComparison.cs 1970-01-01 00:00:00 +0000
+++ src/framework/Internal/NumericComparison.cs 2011-05-12 00:38:23 +0000
@@ -0,0 +1,103 @@
+// ***********************************************************************
+// Copyright (c) 2011 Charlie Poole
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// ***********************************************************************
+
+using System;
+
+internal static class NumericComparison
+{
+ private static readonly Type[] NumericTypes = new[] { typeof(double), typeof(float), typeof(decimal),
+ typeof(ulong), typeof(long), typeof(uint), typeof(int), typeof(ushort), typeof(short), typeof(sbyte), typeof(byte) };
+ private static readonly Type[] SignedNumericTypes = new[] { typeof(long), typeof(int), typeof(short), typeof(sbyte) };
+
+
+
+ public static bool IsNumericComparisonPossible(object valueX, object valueY)
+ {
+ return IsNumericType(valueX) && IsNumericType(valueY);
+ }
+
+
+ /// <summary>Precondition assums that valueX and valueY is or numeric types.
+ /// The IsNumericComparisonPossible should return true for the supplied values.
+ /// </summary>
+ /// <param name="valueX"></param>
+ /// <param name="valueY"></param>
+ /// <returns>Less than zero if valueX is less than valueY; Zero if valueX and valueY are equal and
+ /// greater than zero if valueX is greater than valueY.</returns>
+ public static int Compare(object valueX, object valueY)
+ {
+ Type valueXType = valueX.GetType();
+ Type valueYType = valueY.GetType();
+
+ if (valueXType == valueYType)
+ return ((IComparable) valueX).CompareTo(valueY);
+
+ if (valueXType == typeof(double) || valueXType == typeof(float) || valueYType == typeof(double) || valueYType == typeof(float))
+ return Convert.ToDouble(valueX).CompareTo(Convert.ToDouble(valueY));
+
+ if (valueXType == typeof(decimal) || valueYType == typeof(decimal))
+ return Convert.ToDecimal(valueX).CompareTo(Convert.ToDecimal(valueY));
+
+ if (valueXType == typeof(ulong) || valueYType == typeof(ulong))
+ {
+ if (IsTypeSignedNumericType(valueXType))
+ {
+ long signedValueX = Convert.ToInt64(valueX);
+ return signedValueX < 0 ? -1 : ((ulong)signedValueX).CompareTo(Convert.ToUInt64(valueY));
+ }
+
+ if (IsTypeSignedNumericType(valueYType))
+ {
+ long signedValueY = Convert.ToInt64(valueY);
+ return signedValueY < 0 ? 1 : Convert.ToUInt64(valueX).CompareTo((ulong)signedValueY);
+ }
+
+ return Convert.ToUInt64(valueX).CompareTo(Convert.ToUInt64(valueY));
+ }
+
+ return Convert.ToInt64(valueX).CompareTo(Convert.ToInt64(valueY));
+ }
+
+
+ private static bool IsNumericType(object value)
+ {
+ if (value == null)
+ return false;
+
+ Type valueType = value.GetType();
+ foreach (Type numericType in NumericTypes)
+ if (valueType == numericType)
+ return true;
+
+ return false;
+ }
+
+ private static bool IsTypeSignedNumericType(Type type)
+ {
+ foreach (Type signedNumeric in SignedNumericTypes)
+ if (type == signedNumeric)
+ return true;
+
+ return false;
+ }
+}
\ No newline at end of file
=== added file 'src/framework/Internal/StringConverterHelper.cs'
--- src/framework/Internal/StringConverterHelper.cs 1970-01-01 00:00:00 +0000
+++ src/framework/Internal/StringConverterHelper.cs 2011-05-12 00:38:23 +0000
@@ -0,0 +1,58 @@
+// ***********************************************************************
+// Copyright (c) 2011 Charlie Poole
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// ***********************************************************************
+
+
+using System.Collections;
+using System.Text;
+
+namespace NUnitProposal.NUnit.Framework.Constraints.Helpers
+{
+ interna