1 // ****************************************************************
\r
2 // Copyright 2007, Charlie Poole
\r
3 // This is free software licensed under the NUnit license. You may
\r
4 // obtain a copy of the license at http://nunit.org/?p=license&r=2.4
\r
5 // ****************************************************************
\r
8 using System.Collections;
\r
10 namespace NUnit.Framework.Constraints
\r
13 /// EmptyConstraint tests a whether a string or collection is empty,
\r
14 /// postponing the decision about which test is applied until the
\r
15 /// type of the actual argument is known.
\r
17 public class EmptyConstraint : Constraint
\r
19 private Constraint RealConstraint
\r
23 if ( actual is string )
\r
24 return new EmptyStringConstraint();
\r
26 return new EmptyCollectionConstraint();
\r
31 /// Test whether the constraint is satisfied by a given value
\r
33 /// <param name="actual">The value to be tested</param>
\r
34 /// <returns>True for success, false for failure</returns>
\r
35 public override bool Matches(object actual)
\r
37 this.actual = actual;
\r
39 return this.RealConstraint.Matches( actual );
\r
43 /// Write the constraint description to a MessageWriter
\r
45 /// <param name="writer">The writer on which the description is displayed</param>
\r
46 public override void WriteDescriptionTo(MessageWriter writer)
\r
48 this.RealConstraint.WriteDescriptionTo( writer );
\r