From: <sm...@us...> - 2003-02-10 13:26:20
|
Update of /cvsroot/nmock/nmock/test/NMock/Constraints In directory sc8-pr-cvs1:/tmp/cvs-serv32401/test/NMock/Constraints Modified Files: ConstraintsTest.cs Log Message: Added public object ExtractActualValue(object actual) to IConstraint interface Index: ConstraintsTest.cs =================================================================== RCS file: /cvsroot/nmock/nmock/test/NMock/Constraints/ConstraintsTest.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ConstraintsTest.cs 21 Jan 2003 18:16:13 -0000 1.4 --- ConstraintsTest.cs 10 Feb 2003 13:26:17 -0000 1.5 *************** *** 234,237 **** --- 234,238 ---- } + #region Property Tests [Test] public void PropertyIs() *************** *** 274,278 **** } } ! [Test] public void CollectingConstraint() --- 275,280 ---- } } ! #endregion ! [Test] public void CollectingConstraint() *************** *** 337,340 **** --- 339,347 ---- get { return null; } } + + public object ExtractActualValue(object actual) + { + return actual; + } } *************** *** 350,353 **** --- 357,365 ---- get { return null; } } + + public object ExtractActualValue(object actual) + { + return actual; + } } *************** *** 363,369 **** get { return "DUMMY"; } } ! } } --- 375,407 ---- get { return "DUMMY"; } } ! ! public object ExtractActualValue(object actual) ! { ! return actual; ! } } + #region ExtractActualValue test + class ExtractingConstraint : IsEqual + { + public ExtractingConstraint(object expected) : base(expected) {} + + + public override object ExtractActualValue(object actual) + { + return ((string)actual)[0].ToString(); + } + } + + [Test] + public void ExtractingActualValue() + { + ExtractingConstraint constraint = new ExtractingConstraint("E"); + + Assertion.AssertEquals("Should be modified value", "A", constraint.ExtractActualValue("ACTUAL")); + Assertion.Assert("Should match", constraint.Eval("EQUALS FIRST CHAR")); + Assertion.Assert("Should be different", new Not(constraint).Eval("NOT EQUAL")); + } + #endregion } |