// **************************************************************** // 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; namespace NUnit.Framework.Constraints { /// /// SameAsConstraint tests whether an object is identical to /// the object passed to its constructor /// public class SameAsConstraint : Constraint { private object expected; /// /// Initializes a new instance of the class. /// /// The expected object. public SameAsConstraint(object expected) { this.expected = expected; } /// /// Test whether the constraint is satisfied by a given value /// /// The value to be tested /// True for success, false for failure public override bool Matches(object actual) { this.actual = actual; return Object.ReferenceEquals(expected,actual); } /// /// Write the constraint description to a MessageWriter /// /// The writer on which the description is displayed public override void WriteDescriptionTo(MessageWriter writer) { writer.WritePredicate("same as"); writer.WriteExpectedValue(expected); } } }