From: Choy R. <ch...@us...> - 2005-02-20 09:26:59
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/Predicates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15950/DotNetMock/Dynamic/Predicates Modified Files: AndPredicate.cs IsAnything.cs IsCloseTo.cs IsEqual.cs IsEqualIgnoreCase.cs IsEqualIgnoreWhiteSpace.cs IsIn.cs IsMatch.cs IsNull.cs IsTypeOf.cs NotEqual.cs NotIn.cs NotNull.cs NotPredicate.cs OrPredicate.cs Predicate.cs Added Files: AbstractPredicate.cs Log Message: Make sure all Predicates support the ability to describe their evaluation expression through the ExpressionAsText(name) method. The name parameter is so that in the future we can include the name of the parameter that didn't satisfy the predicate in our assertion failure messages. Index: AndPredicate.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/Predicates/AndPredicate.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AndPredicate.cs 1 Jan 2005 21:13:54 -0000 1.4 --- AndPredicate.cs 20 Feb 2005 09:26:49 -0000 1.5 *************** *** 1,29 **** namespace DotNetMock.Dynamic.Predicates { /// <summary> ! /// Represets a <see cref="IPredicate"/> that expects a value to satisfy two predicates. /// </summary> ! public class AndPredicate : IPredicate { ! private IPredicate p1, p2; /// <summary> /// Default Constructor /// </summary> ! /// <param name="p1">first <see cref="IPredicate"/></param> ! /// <param name="p2">first <see cref="IPredicate"/></param> ! public AndPredicate(IPredicate p1, IPredicate p2) { ! this.p1 = p1; ! this.p2 = p2; } /// <summary> /// Evaluates the input value against both <see cref="IPredicate"/>s /// </summary> ! /// <param name="currentValue">Value to evaluate</param> /// <returns>True if the input value satisfies both <see cref="IPredicate"/> instances</returns> ! public bool Eval(object currentValue) { ! return p1.Eval(currentValue) && p2.Eval(currentValue); } } } --- 1,49 ---- + #region License + // Copyright (c) 2004 Griffin Caprio & Choy Rim. All rights reserved. + #endregion + #region Imports + using System; + #endregion + namespace DotNetMock.Dynamic.Predicates { /// <summary> ! /// A <see cref="IPredicate"/> that expects a value to satisfy two predicates. /// </summary> ! public class AndPredicate : AbstractPredicate { ! private IPredicate _lhs, _rhs; /// <summary> /// Default Constructor /// </summary> ! /// <param name="_lhs">first <see cref="IPredicate"/></param> ! /// <param name="_rhs">first <see cref="IPredicate"/></param> ! public AndPredicate(IPredicate _lhs, IPredicate _rhs) { ! this._lhs = _lhs; ! this._rhs = _rhs; } /// <summary> /// Evaluates the input value against both <see cref="IPredicate"/>s /// </summary> ! /// <param name="inputValue">Value to evaluate</param> /// <returns>True if the input value satisfies both <see cref="IPredicate"/> instances</returns> ! public override bool Eval(object inputValue) { ! return _lhs.Eval(inputValue) && _rhs.Eval(inputValue); } + /// <summary> + /// Text representation of what is evaluated by the + /// <see cref="Eval"/> method. + /// </summary> + public override string ExpressionAsText(string name) + { + return String.Format( + "({0}) and ({1})", + _lhs.ExpressionAsText(name), + _rhs.ExpressionAsText(name) + ); + } + } } Index: IsTypeOf.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/Predicates/IsTypeOf.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IsTypeOf.cs 1 Jan 2005 21:13:54 -0000 1.3 --- IsTypeOf.cs 20 Feb 2005 09:26:49 -0000 1.4 *************** *** 1,3 **** --- 1,8 ---- + #region License + // Copyright (c) 2004 Griffin Caprio & Choy Rim. All rights reserved. + #endregion + #region Imports using System; + #endregion namespace DotNetMock.Dynamic.Predicates *************** *** 6,10 **** /// <see cref="IPredicate"/> that evaluates the input value against the expected <see cref="Type"/> /// </summary> ! public class IsTypeOf : IPredicate { private Type _type; --- 11,15 ---- /// <see cref="IPredicate"/> that evaluates the input value against the expected <see cref="Type"/> /// </summary> ! public class IsTypeOf : AbstractPredicate { private Type _type; *************** *** 22,29 **** /// <param name="currentValue">input value</param> /// <returns>True if the original type is assignable from the input value, false otherwise.</returns> ! public bool Eval(object currentValue) { return currentValue == null ? false : _type.IsAssignableFrom(currentValue.GetType()); } } } --- 27,46 ---- /// <param name="currentValue">input value</param> /// <returns>True if the original type is assignable from the input value, false otherwise.</returns> ! public override bool Eval(object currentValue) { return currentValue == null ? false : _type.IsAssignableFrom(currentValue.GetType()); } + /// <summary> + /// Text representation of what is evaluated by the + /// <see cref="Eval"/> method. + /// </summary> + public override string ExpressionAsText(string name) + { + return String.Format( + "{0} is a {1}", + name, + _type.FullName + ); + } } } --- NEW FILE: AbstractPredicate.cs --- #region License // Copyright (c) 2004 Griffin Caprio & Choy Rim. All rights reserved. #endregion #region Imports using System; using System.Collections; #endregion namespace DotNetMock.Dynamic.Predicates { /// <summary> /// Abstract base class for all predicates. /// </summary> public abstract class AbstractPredicate : IPredicate { /// <summary> /// Evaluates whether input value satisfies this predicate. /// </summary> /// <param name="inputValue">input value</param> /// <returns>true if the predicate was satisfied</returns> public abstract bool Eval(object inputValue); /// <summary> /// Text representation of what is evaluated by the /// <see cref="Eval"/> method. /// </summary> /// <param name="name"> /// name of value/variable to use in the expression text /// </param> /// <returns>text representation of this predicate</returns> public virtual string ExpressionAsText(string name) { return "(N/A)"; } /// <summary> /// Returns a <see cref="String"/> that represents the /// expression evaluated by this <see cref="IPredicate"/>. /// </summary> /// <returns> /// Expression evaluated by this predicate. /// </returns> public override string ToString() { return ExpressionAsText("value"); } } } Index: IsIn.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/Predicates/IsIn.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IsIn.cs 1 Jan 2005 21:13:54 -0000 1.3 --- IsIn.cs 20 Feb 2005 09:26:49 -0000 1.4 *************** *** 1,4 **** --- 1,11 ---- + #region License + // Copyright (c) 2004 Griffin Caprio & Choy Rim. All rights reserved. + #endregion + #region Imports using System; + using DotNetMock.Util; + #endregion + namespace DotNetMock.Dynamic.Predicates { *************** *** 6,10 **** /// <see cref="IPredicate"/> that looks for an input value in an array of values. /// </summary> ! public class IsIn : IPredicate { private object[] _inList; --- 13,17 ---- /// <see cref="IPredicate"/> that looks for an input value in an array of values. /// </summary> ! public class IsIn : AbstractPredicate { private object[] _inList; *************** *** 31,35 **** /// <param name="inputValue">input value to look for</param> /// <returns>True if the input value is found, false otherwise.</returns> ! public bool Eval(object inputValue) { foreach (object o in _inList) --- 38,42 ---- /// <param name="inputValue">input value to look for</param> /// <returns>True if the input value is found, false otherwise.</returns> ! public override bool Eval(object inputValue) { foreach (object o in _inList) *************** *** 42,45 **** --- 49,64 ---- return false; } + /// <summary> + /// Text representation of what is evaluated by the + /// <see cref="Eval"/> method. + /// </summary> + public override string ExpressionAsText(string name) + { + return String.Format( + "{0} is in [{1}]", + name, + StringUtils.FormatArray(_inList) + ); + } } } Index: IsMatch.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/Predicates/IsMatch.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IsMatch.cs 1 Jan 2005 21:13:54 -0000 1.3 --- IsMatch.cs 20 Feb 2005 09:26:49 -0000 1.4 *************** *** 1,4 **** --- 1,9 ---- + #region License + // Copyright (c) 2004 Griffin Caprio & Choy Rim. All rights reserved. + #endregion + #region Imports using System; using System.Text.RegularExpressions; + #endregion namespace DotNetMock.Dynamic.Predicates *************** *** 7,11 **** /// <see cref="IPredicate"/> that compares the input value against an regular expression pattern. /// </summary> ! public class IsMatch : IPredicate { private Regex _regex; --- 12,16 ---- /// <see cref="IPredicate"/> that compares the input value against an regular expression pattern. /// </summary> ! public class IsMatch : AbstractPredicate { private Regex _regex; *************** *** 34,41 **** /// <param name="inputValue">input value</param> /// <returns>True if the regular expression matches the input value, flase otherwise.</returns> ! public bool Eval(object inputValue) { return inputValue == null ? false : _regex.IsMatch(inputValue.ToString()); } } } --- 39,58 ---- /// <param name="inputValue">input value</param> /// <returns>True if the regular expression matches the input value, flase otherwise.</returns> ! public override bool Eval(object inputValue) { return inputValue == null ? false : _regex.IsMatch(inputValue.ToString()); } + /// <summary> + /// Text representation of what is evaluated by the + /// <see cref="Eval"/> method. + /// </summary> + public override string ExpressionAsText(string name) + { + return String.Format( + "{0} matches /{1}/", + name, + _regex + ); + } } } Index: NotEqual.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/Predicates/NotEqual.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NotEqual.cs 1 Jan 2005 21:13:54 -0000 1.3 --- NotEqual.cs 20 Feb 2005 09:26:49 -0000 1.4 *************** *** 1,2 **** --- 1,11 ---- + #region License + // Copyright (c) 2004 Griffin Caprio & Choy Rim. All rights reserved. + #endregion + #region Imports + using System; + + using DotNetMock.Util; + #endregion + namespace DotNetMock.Dynamic.Predicates { *************** *** 4,10 **** /// <see cref="IPredicate"/> that verifies the input value is not equal to the original value. /// </summary> ! public class NotEqual : IPredicate { private IPredicate p; /// <summary> /// Default Constructor --- 13,20 ---- /// <see cref="IPredicate"/> that verifies the input value is not equal to the original value. /// </summary> ! public class NotEqual : AbstractPredicate { private IPredicate p; + object _rhs; /// <summary> /// Default Constructor *************** *** 13,16 **** --- 23,27 ---- public NotEqual(object compare) { + _rhs = compare; p = new NotPredicate(new IsEqual(compare)); } *************** *** 20,27 **** /// <param name="inputValue">input value</param> /// <returns>True if the input value does not equal the original value, false otherwise.</returns> ! public bool Eval(object inputValue) { return p.Eval(inputValue); } } } --- 31,50 ---- /// <param name="inputValue">input value</param> /// <returns>True if the input value does not equal the original value, false otherwise.</returns> ! public override bool Eval(object inputValue) { return p.Eval(inputValue); } + /// <summary> + /// Text representation of what is evaluated by the + /// <see cref="Eval"/> method. + /// </summary> + public override string ExpressionAsText(string name) + { + return String.Format( + "{0} is not equal to {1}", + name, + StringUtils.FormatScalar(_rhs) + ); + } } } Index: IsEqual.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/Predicates/IsEqual.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** IsEqual.cs 16 Feb 2005 10:39:26 -0000 1.6 --- IsEqual.cs 20 Feb 2005 09:26:49 -0000 1.7 *************** *** 1,4 **** --- 1,11 ---- + #region License + // Copyright (c) 2004 Griffin Caprio & Choy Rim. All rights reserved. + #endregion + #region Imports using System; + using DotNetMock.Util; + #endregion + namespace DotNetMock.Dynamic.Predicates { *************** *** 6,10 **** /// <see cref="IPredicate"/> comparing two values /// </summary> ! public class IsEqual : IPredicate { private object _compare; --- 13,17 ---- /// <see cref="IPredicate"/> comparing two values /// </summary> ! public class IsEqual : AbstractPredicate { private object _compare; *************** *** 17,30 **** _compare = compare; } - - /// <summary> - /// The condition this evaluates as text. - /// </summary> - /// <returns>"value equals (xxx)"</returns> - public override string ToString() - { - return String.Format("value equals ({0})", _compare); - } - /// <summary> /// Evaluates input value against original value for equality --- 24,27 ---- *************** *** 32,36 **** /// <param name="inputValue">input value</param> /// <returns>True if input value equals original value, false otherwise.</returns> ! public bool Eval(object inputValue) { if ( ( inputValue == null ) & ( _compare != null ) ) --- 29,33 ---- /// <param name="inputValue">input value</param> /// <returns>True if input value equals original value, false otherwise.</returns> ! public override bool Eval(object inputValue) { if ( ( inputValue == null ) & ( _compare != null ) ) *************** *** 72,75 **** --- 69,85 ---- } } + /// <summary> + /// Text representation of what is evaluated by the + /// <see cref="Eval"/> method. + /// </summary> + public override string ExpressionAsText(string name) + { + return String.Format( + "{0} equals {1}", + name, + StringUtils.FormatScalar(_compare) + ); + } + } } Index: IsEqualIgnoreCase.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/Predicates/IsEqualIgnoreCase.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IsEqualIgnoreCase.cs 1 Jan 2005 21:13:54 -0000 1.3 --- IsEqualIgnoreCase.cs 20 Feb 2005 09:26:49 -0000 1.4 *************** *** 1,3 **** --- 1,9 ---- + #region License + // Copyright (c) 2004 Griffin Caprio & Choy Rim. All rights reserved. + #endregion + #region Imports + using System; using System.Globalization; + #endregion namespace DotNetMock.Dynamic.Predicates *************** *** 6,12 **** /// <see cref="IPredicate"/> comparing strings while ignoring case /// </summary> ! public class IsEqualIgnoreCase : IPredicate { ! private IPredicate _originalPredicate; /// <summary> /// Default Constructor --- 12,18 ---- /// <see cref="IPredicate"/> comparing strings while ignoring case /// </summary> ! public class IsEqualIgnoreCase : AbstractPredicate { ! private IsEqual _isEqual; /// <summary> /// Default Constructor *************** *** 15,19 **** public IsEqualIgnoreCase(object compare) { ! _originalPredicate = new IsEqual(compare.ToString().ToLower(CultureInfo.CurrentCulture)); } /// <summary> --- 21,25 ---- public IsEqualIgnoreCase(object compare) { ! _isEqual = new IsEqual(compare.ToString().ToLower(CultureInfo.CurrentCulture)); } /// <summary> *************** *** 22,28 **** /// <param name="inputValue">Input value</param> /// <returns>True if input value equals original value</returns> ! public bool Eval(object inputValue) { ! return _originalPredicate.Eval(inputValue.ToString().ToLower(CultureInfo.CurrentCulture)); } } --- 28,45 ---- /// <param name="inputValue">Input value</param> /// <returns>True if input value equals original value</returns> ! public override bool Eval(object inputValue) { ! return _isEqual.Eval(inputValue.ToString().ToLower(CultureInfo.CurrentCulture)); ! } ! /// <summary> ! /// Text representation of what is evaluated by the ! /// <see cref="Eval"/> method. ! /// </summary> ! public override string ExpressionAsText(string name) ! { ! return String.Format( ! "{0} (ignore case)", ! _isEqual.ExpressionAsText(name) ! ); } } Index: NotNull.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/Predicates/NotNull.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NotNull.cs 1 Jan 2005 21:13:54 -0000 1.3 --- NotNull.cs 20 Feb 2005 09:26:49 -0000 1.4 *************** *** 1,2 **** --- 1,9 ---- + #region License + // Copyright (c) 2004 Griffin Caprio & Choy Rim. All rights reserved. + #endregion + #region Imports + using System; + #endregion + namespace DotNetMock.Dynamic.Predicates { *************** *** 4,8 **** /// <see cref="IPredicate"/> that verifies that the input value is null. Opposite of <see cref="IsNull"/>. /// </summary> ! public class NotNull : IPredicate { /// <summary> --- 11,15 ---- /// <see cref="IPredicate"/> that verifies that the input value is null. Opposite of <see cref="IsNull"/>. /// </summary> ! public class NotNull : AbstractPredicate { /// <summary> *************** *** 11,18 **** /// <param name="inputValue">input value</param> /// <returns>True if the input value is not null, false otherwise.</returns> ! public bool Eval(object inputValue) { return inputValue != null; } } } --- 18,36 ---- /// <param name="inputValue">input value</param> /// <returns>True if the input value is not null, false otherwise.</returns> ! public override bool Eval(object inputValue) { return inputValue != null; } + /// <summary> + /// Text representation of what is evaluated by the + /// <see cref="Eval"/> method. + /// </summary> + public override string ExpressionAsText(string name) + { + return String.Format( + "{0} is not null", + name + ); + } } } Index: Predicate.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/Predicates/Predicate.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Predicate.cs 1 Jan 2005 21:13:54 -0000 1.3 --- Predicate.cs 20 Feb 2005 09:26:49 -0000 1.4 *************** *** 4,8 **** /// <see cref="IPredicate"/> that accepts a reference to the a delegate instance that performs the evaluation. /// </summary> ! public class Predicate : IPredicate { /// <summary> --- 4,8 ---- /// <see cref="IPredicate"/> that accepts a reference to the a delegate instance that performs the evaluation. /// </summary> ! public class Predicate : AbstractPredicate { /// <summary> *************** *** 25,29 **** /// <param name="currentValue">input value</param> /// <returns>The results of the delegation methods evaluation</returns> ! public bool Eval(object currentValue) { return _evaluationMethod(currentValue); --- 25,29 ---- /// <param name="currentValue">input value</param> /// <returns>The results of the delegation methods evaluation</returns> ! public override bool Eval(object currentValue) { return _evaluationMethod(currentValue); Index: NotPredicate.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/Predicates/NotPredicate.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NotPredicate.cs 1 Jan 2005 21:13:54 -0000 1.3 --- NotPredicate.cs 20 Feb 2005 09:26:49 -0000 1.4 *************** *** 1,2 **** --- 1,9 ---- + #region License + // Copyright (c) 2004 Griffin Caprio & Choy Rim. All rights reserved. + #endregion + #region Imports + using System; + #endregion + namespace DotNetMock.Dynamic.Predicates { *************** *** 4,8 **** /// <see cref="IPredicate"/> that is used to wrap other <see cref="IPredicate"/> objects, and invert their results. /// </summary> ! public class NotPredicate : IPredicate { private IPredicate _wrappedPredicate; --- 11,15 ---- /// <see cref="IPredicate"/> that is used to wrap other <see cref="IPredicate"/> objects, and invert their results. /// </summary> ! public class NotPredicate : AbstractPredicate { private IPredicate _wrappedPredicate; *************** *** 20,27 **** /// <param name="inputValue">input value</param> /// <returns>The opposite ( ! ) of the original <see cref="IPredicate"/>s evaluation.</returns> ! public bool Eval(object inputValue) { return !_wrappedPredicate.Eval(inputValue); } } } --- 27,45 ---- /// <param name="inputValue">input value</param> /// <returns>The opposite ( ! ) of the original <see cref="IPredicate"/>s evaluation.</returns> ! public override bool Eval(object inputValue) { return !_wrappedPredicate.Eval(inputValue); } + /// <summary> + /// Text representation of what is evaluated by the + /// <see cref="Eval"/> method. + /// </summary> + public override string ExpressionAsText(string name) + { + return String.Format( + "not ({0})", + _wrappedPredicate.ExpressionAsText(name) + ); + } } } Index: IsCloseTo.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/Predicates/IsCloseTo.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IsCloseTo.cs 1 Jan 2005 21:13:54 -0000 1.4 --- IsCloseTo.cs 20 Feb 2005 09:26:49 -0000 1.5 *************** *** 1,4 **** --- 1,9 ---- + #region License + // Copyright (c) 2004 Griffin Caprio & Choy Rim. All rights reserved. + #endregion + #region Imports using System; using System.Globalization; + #endregion namespace DotNetMock.Dynamic.Predicates *************** *** 7,11 **** /// <see cref="IPredicate"/> representing a expected value, but also an acceptable delta for the input value /// </summary> ! public class IsCloseTo : IPredicate { private double _expected; --- 12,16 ---- /// <see cref="IPredicate"/> representing a expected value, but also an acceptable delta for the input value /// </summary> ! public class IsCloseTo : AbstractPredicate { private double _expected; *************** *** 26,30 **** /// <param name="currentValue">Input value to evaluate</param> /// <returns>True if the input value is within acceptable range.</returns> ! public bool Eval(object currentValue) { try --- 31,35 ---- /// <param name="currentValue">Input value to evaluate</param> /// <returns>True if the input value is within acceptable range.</returns> ! public override bool Eval(object currentValue) { try *************** *** 38,41 **** --- 43,59 ---- } } + /// <summary> + /// Text representation of what is evaluated by the + /// <see cref="Eval"/> method. + /// </summary> + public override string ExpressionAsText(string name) + { + return String.Format( + "{0} is within {1} of {2}", + name, + _error, + _expected + ); + } } } Index: IsAnything.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/Predicates/IsAnything.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IsAnything.cs 1 Jan 2005 21:13:54 -0000 1.4 --- IsAnything.cs 20 Feb 2005 09:26:49 -0000 1.5 *************** *** 1,2 **** --- 1,5 ---- + #region License + // Copyright (c) 2004 Griffin Caprio & Choy Rim. All rights reserved. + #endregion using System; *************** *** 6,10 **** /// <see cref="IPredicate"/> representing any value /// </summary> ! public class IsAnything : IPredicate { /// <summary> --- 9,13 ---- /// <see cref="IPredicate"/> representing any value /// </summary> ! public class IsAnything : AbstractPredicate { /// <summary> *************** *** 13,20 **** /// <param name="currentValue">INput value to evaluate</param> /// <returns>True</returns> ! public bool Eval(object currentValue) { return true; } } } --- 16,31 ---- /// <param name="currentValue">INput value to evaluate</param> /// <returns>True</returns> ! public override bool Eval(object currentValue) { return true; } + /// <summary> + /// Text representation of what is evaluated by the + /// <see cref="Eval"/> method. + /// </summary> + public override string ExpressionAsText(string name) + { + return String.Format("{0} is anything", name); + } } } Index: IsNull.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/Predicates/IsNull.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IsNull.cs 16 Feb 2005 10:39:26 -0000 1.4 --- IsNull.cs 20 Feb 2005 09:26:49 -0000 1.5 *************** *** 1,2 **** --- 1,9 ---- + #region License + // Copyright (c) 2004 Griffin Caprio & Choy Rim. All rights reserved. + #endregion + #region Imports + using System; + #endregion + namespace DotNetMock.Dynamic.Predicates { *************** *** 4,27 **** /// <see cref="IPredicate"/> that indicates that the input value should be null. /// </summary> ! public class IsNull : IPredicate { /// <summary> - /// The condition this evaluates as text. - /// </summary> - /// <returns>"value is null"</returns> - public override string ToString() - { - return "value is null"; - } - - /// <summary> /// Evaluates the input value against null /// </summary> /// <param name="inputValue">input value</param> /// <returns>True if the input value is null, false otherwise.</returns> ! public bool Eval(object inputValue) { return inputValue == null; } } } --- 11,36 ---- /// <see cref="IPredicate"/> that indicates that the input value should be null. /// </summary> ! public class IsNull : AbstractPredicate { /// <summary> /// Evaluates the input value against null /// </summary> /// <param name="inputValue">input value</param> /// <returns>True if the input value is null, false otherwise.</returns> ! public override bool Eval(object inputValue) { return inputValue == null; } + /// <summary> + /// Text representation of what is evaluated by the + /// <see cref="Eval"/> method. + /// </summary> + public override string ExpressionAsText(string name) + { + return String.Format( + "{0} is null", + name + ); + } } } Index: IsEqualIgnoreWhiteSpace.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/Predicates/IsEqualIgnoreWhiteSpace.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IsEqualIgnoreWhiteSpace.cs 1 Jan 2005 21:13:54 -0000 1.3 --- IsEqualIgnoreWhiteSpace.cs 20 Feb 2005 09:26:49 -0000 1.4 *************** *** 1,5 **** --- 1,12 ---- + #region License + // Copyright (c) 2004 Griffin Caprio & Choy Rim. All rights reserved. + #endregion + #region Imports using System; using System.Text; + using DotNetMock.Util; + #endregion + namespace DotNetMock.Dynamic.Predicates { *************** *** 7,13 **** /// <see cref="IPredicate"/> comparing string values that ignore whitespace. /// </summary> ! public class IsEqualIgnoreWhiteSpace : IPredicate { private IPredicate _originalPredicate; /// <summary> /// Default Constructor --- 14,21 ---- /// <see cref="IPredicate"/> comparing string values that ignore whitespace. /// </summary> ! public class IsEqualIgnoreWhiteSpace : AbstractPredicate { private IPredicate _originalPredicate; + private string _compare; /// <summary> /// Default Constructor *************** *** 16,19 **** --- 24,28 ---- public IsEqualIgnoreWhiteSpace(object compare) { + _compare = compare.ToString(); _originalPredicate = new IsEqual(StripSpace(compare.ToString())); } *************** *** 23,27 **** /// <param name="inputValue">input value to compare</param> /// <returns>True if the input value equals the original value, false otherwise</returns> ! public bool Eval(object inputValue) { return _originalPredicate.Eval(StripSpace(inputValue.ToString())); --- 32,36 ---- /// <param name="inputValue">input value to compare</param> /// <returns>True if the input value equals the original value, false otherwise</returns> ! public override bool Eval(object inputValue) { return _originalPredicate.Eval(StripSpace(inputValue.ToString())); *************** *** 54,57 **** --- 63,78 ---- return result.ToString().Trim(); } + /// <summary> + /// Text representation of what is evaluated by the + /// <see cref="Eval"/> method. + /// </summary> + public override string ExpressionAsText(string name) + { + return String.Format( + "{0} equals {1} (ignore whitespace)", + name, + StringUtils.FormatScalar(_compare) + ); + } } } Index: NotIn.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/Predicates/NotIn.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NotIn.cs 1 Jan 2005 21:13:54 -0000 1.3 --- NotIn.cs 20 Feb 2005 09:26:49 -0000 1.4 *************** *** 1,2 **** --- 1,11 ---- + #region License + // Copyright (c) 2004 Griffin Caprio & Choy Rim. All rights reserved. + #endregion + #region Imports + using System; + + using DotNetMock.Util; + #endregion + namespace DotNetMock.Dynamic.Predicates { *************** *** 4,10 **** /// <see cref="IPredicate"/> to verify that the input value is not in the original list of values. Opposite of <see cref="IsIn"/>. /// </summary> ! public class NotIn : IPredicate { private IPredicate p; /// <summary> /// Default Constructor --- 13,20 ---- /// <see cref="IPredicate"/> to verify that the input value is not in the original list of values. Opposite of <see cref="IsIn"/>. /// </summary> ! public class NotIn : AbstractPredicate { private IPredicate p; + private object[] _inList; /// <summary> /// Default Constructor *************** *** 13,16 **** --- 23,27 ---- public NotIn(params object[] inList) { + _inList = inList; p = new NotPredicate(new IsIn(inList)); } *************** *** 20,27 **** /// <param name="inputValue">input value</param> /// <returns>True if the input value is not in the original array of values, false otherwise.</returns> ! public bool Eval(object inputValue) { return p.Eval(inputValue); } } } --- 31,50 ---- /// <param name="inputValue">input value</param> /// <returns>True if the input value is not in the original array of values, false otherwise.</returns> ! public override bool Eval(object inputValue) { return p.Eval(inputValue); } + /// <summary> + /// Text representation of what is evaluated by the + /// <see cref="Eval"/> method. + /// </summary> + public override string ExpressionAsText(string name) + { + return String.Format( + "{0} is not in [{1}]", + name, + StringUtils.FormatArray(_inList) + ); + } } } Index: OrPredicate.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/Predicates/OrPredicate.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OrPredicate.cs 1 Jan 2005 21:13:54 -0000 1.3 --- OrPredicate.cs 20 Feb 2005 09:26:49 -0000 1.4 *************** *** 1,2 **** --- 1,9 ---- + #region License + // Copyright (c) 2004 Griffin Caprio & Choy Rim. All rights reserved. + #endregion + #region Imports + using System; + #endregion + namespace DotNetMock.Dynamic.Predicates { *************** *** 4,8 **** /// <see cref="IPredicate"/> that compares the input value against two <see cref="IPredicate"/> instances. /// </summary> ! public class OrPredicate : IPredicate { private IPredicate _originalPredicate1; --- 11,15 ---- /// <see cref="IPredicate"/> that compares the input value against two <see cref="IPredicate"/> instances. /// </summary> ! public class OrPredicate : AbstractPredicate { private IPredicate _originalPredicate1; *************** *** 23,30 **** /// <param name="inputValue">input value</param> /// <returns>True if the input value satisfies either of the original <see cref="IPredicate"/> objects, false otherwise.</returns> ! public bool Eval(object inputValue) { return _originalPredicate1.Eval(inputValue) || _originalPredicate2.Eval(inputValue); } } } --- 30,49 ---- /// <param name="inputValue">input value</param> /// <returns>True if the input value satisfies either of the original <see cref="IPredicate"/> objects, false otherwise.</returns> ! public override bool Eval(object inputValue) { return _originalPredicate1.Eval(inputValue) || _originalPredicate2.Eval(inputValue); } + /// <summary> + /// Text representation of what is evaluated by the + /// <see cref="Eval"/> method. + /// </summary> + public override string ExpressionAsText(string name) + { + return String.Format( + "({0}) or ({1})", + _originalPredicate1.ExpressionAsText(name), + _originalPredicate2.ExpressionAsText(name) + ); + } } } |