using System; namespace NUnit.Framework { /// /// AbstractAsserter is the base class for all asserters. /// Asserters encapsulate a condition test and generation /// of an AssertionException with a tailored message. They /// are used by the Assert class as helper objects. /// /// User-defined asserters may be passed to the /// Assert.DoAssert method in order to implement /// extended asserts. /// public abstract class AbstractAsserter : IAsserter { /// /// The user-defined message for this asserter. /// protected readonly string message; /// /// Arguments to use in formatting the user-defined message. /// protected readonly object[] args; /// /// Constructs an AbstractAsserter /// /// The message issued upon failure /// Arguments to be used in formatting the message public AbstractAsserter( string message, params object[] args ) { this.message = message; this.args = args; } protected string FormattedMessage { get { if ( message == null ) return string.Empty; if ( args != null && args.Length > 0 ) return string.Format( message, args ); return message; } } /// /// Assert on the condition this object is designed /// to handle, throwing an exception if it fails. /// public abstract void Assert(); } }