// **************************************************************** // Copyright 2007, Charlie Poole // This is free software licensed under the NUnit license. You may // obtain a copy of the license at http://nunit.org/?p=license&r=2.4 // **************************************************************** using System; using System.Collections; using NUnit.Framework.SyntaxHelpers; using NUnit.Framework.Constraints; namespace NUnit.Framework { /// /// AssertionHelper is an optional base class for user tests, /// allowing the use of shorter names for constraints and /// asserts and avoiding conflict with the definition of /// , from which it inherits much of its /// behavior, in certain mock object frameworks. /// public class AssertionHelper : ConstraintBuilder { #region Expect /// /// Apply a constraint to an actual value, succeeding if the constraint /// is satisfied and throwing an assertion exception on failure. Works /// identically to /// /// A Constraint to be applied /// The actual value to test static public void Expect( object actual, Constraint constraint ) { Assert.That( actual, constraint, null, null ); } /// /// Apply a constraint to an actual value, succeeding if the constraint /// is satisfied and throwing an assertion exception on failure. Works /// identically to /// /// A Constraint to be applied /// The actual value to test /// The message that will be displayed on failure static public void Expect( object actual, Constraint constraint, string message ) { Assert.That( actual, constraint, message, null ); } /// /// Apply a constraint to an actual value, succeeding if the constraint /// is satisfied and throwing an assertion exception on failure. Works /// identically to /// /// A Constraint to be applied /// The actual value to test /// The message that will be displayed on failure /// Arguments to be used in formatting the message static public void Expect( object actual, Constraint constraint, string message, params object[] args ) { Assert.That( actual, constraint, message, args ); } /// /// Asserts that a condition is true. If the condition is false the method throws /// an . Works Identically to /// . /// /// The evaluated condition /// The message to display if the condition is false /// Arguments to be used in formatting the message static public void Expect(bool condition, string message, params object[] args) { Assert.That(condition, Is.True, message, args); } /// /// Asserts that a condition is true. If the condition is false the method throws /// an . Works Identically to /// . /// /// The evaluated condition /// The message to display if the condition is false static public void Expect(bool condition, string message) { Assert.That(condition, Is.True, message, null); } /// /// Asserts that a condition is true. If the condition is false the method throws /// an . Works Identically to . /// /// The evaluated condition static public void Expect(bool condition) { Assert.That(condition, Is.True, null, null); } #endregion #region Map /// /// Returns a ListMapper based on a collection. /// /// The original collection /// public ListMapper Map( ICollection original ) { return new ListMapper( original ); } #endregion } }