You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(31) |
Dec
(26) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(8) |
Feb
(27) |
Mar
(15) |
Apr
|
May
(2) |
Jun
(13) |
Jul
(59) |
Aug
(48) |
Sep
(9) |
Oct
(4) |
Nov
(24) |
Dec
|
| 2004 |
Jan
(24) |
Feb
(2) |
Mar
(12) |
Apr
(9) |
May
(4) |
Jun
(26) |
Jul
(20) |
Aug
(23) |
Sep
(13) |
Oct
(31) |
Nov
(23) |
Dec
(11) |
| 2005 |
Jan
|
Feb
|
Mar
|
Apr
(19) |
May
(64) |
Jun
(7) |
Jul
(20) |
Aug
(1) |
Sep
(6) |
Oct
|
Nov
(3) |
Dec
|
| 2006 |
Jan
|
Feb
(69) |
Mar
(18) |
Apr
(1) |
May
(4) |
Jun
(3) |
Jul
(27) |
Aug
(19) |
Sep
(12) |
Oct
(3) |
Nov
(13) |
Dec
(6) |
| 2007 |
Jan
(20) |
Feb
(17) |
Mar
(1) |
Apr
(3) |
May
(4) |
Jun
(11) |
Jul
(10) |
Aug
(24) |
Sep
(19) |
Oct
(13) |
Nov
(8) |
Dec
(7) |
| 2008 |
Jan
(54) |
Feb
(24) |
Mar
(11) |
Apr
(35) |
May
(13) |
Jun
(10) |
Jul
(30) |
Aug
(18) |
Sep
(21) |
Oct
(18) |
Nov
(40) |
Dec
(76) |
| 2009 |
Jan
(64) |
Feb
(23) |
Mar
(15) |
Apr
(23) |
May
(46) |
Jun
(25) |
Jul
(31) |
Aug
(7) |
Sep
(7) |
Oct
(6) |
Nov
(15) |
Dec
(19) |
| 2010 |
Jan
(13) |
Feb
(8) |
Mar
(6) |
Apr
(4) |
May
(8) |
Jun
(7) |
Jul
(3) |
Aug
(9) |
Sep
(6) |
Oct
(15) |
Nov
(3) |
Dec
(5) |
| 2011 |
Jan
(1) |
Feb
|
Mar
(4) |
Apr
(5) |
May
(2) |
Jun
|
Jul
(2) |
Aug
(2) |
Sep
(2) |
Oct
(4) |
Nov
(2) |
Dec
(3) |
| 2012 |
Jan
(6) |
Feb
(2) |
Mar
(3) |
Apr
(3) |
May
(3) |
Jun
(1) |
Jul
|
Aug
|
Sep
(2) |
Oct
(2) |
Nov
|
Dec
(1) |
| 2013 |
Jan
(3) |
Feb
(1) |
Mar
|
Apr
|
May
(1) |
Jun
(1) |
Jul
|
Aug
(5) |
Sep
|
Oct
(1) |
Nov
(2) |
Dec
|
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
(1) |
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
| 2015 |
Jan
|
Feb
(19) |
Mar
(115) |
Apr
(23) |
May
(41) |
Jun
(48) |
Jul
(59) |
Aug
(29) |
Sep
(40) |
Oct
(78) |
Nov
(58) |
Dec
(47) |
| 2016 |
Jan
(25) |
Feb
(30) |
Mar
(29) |
Apr
(10) |
May
(17) |
Jun
(1) |
Jul
(1) |
Aug
(6) |
Sep
(2) |
Oct
(1) |
Nov
(3) |
Dec
(2) |
| 2017 |
Jan
(5) |
Feb
(2) |
Mar
(7) |
Apr
(1) |
May
(7) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(5) |
Apr
|
May
(1) |
Jun
|
Jul
(3) |
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
|
| 2019 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(3) |
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
(6) |
May
|
Jun
|
Jul
(29) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2021 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(5) |
Dec
(3) |
| 2022 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(5) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2023 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
|
Jun
(7) |
Jul
(1) |
Aug
|
Sep
(6) |
Oct
(4) |
Nov
(1) |
Dec
(4) |
| 2024 |
Jan
(2) |
Feb
(5) |
Mar
|
Apr
|
May
(8) |
Jun
(159) |
Jul
(90) |
Aug
(22) |
Sep
|
Oct
(6) |
Nov
(8) |
Dec
(1) |
| 2025 |
Jan
(20) |
Feb
(6) |
Mar
(2) |
Apr
(4) |
May
(29) |
Jun
(63) |
Jul
(62) |
Aug
(70) |
Sep
(120) |
Oct
(46) |
Nov
(33) |
Dec
(25) |
| 2026 |
Jan
(37) |
Feb
(56) |
Mar
(62) |
Apr
(20) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <joe...@us...> - 2002-11-15 22:48:23
|
Update of /cvsroot/nmock/nmock/src/NMock/Constraints
In directory usw-pr-cvs1:/tmp/cvs-serv3449/src/NMock/Constraints
Added Files:
IConstraint.cs Constraints.cs
Log Message:
- Added sensible error messages
- Renamed IMock.Object to IMock.MockInstance
- Renamed Conditions to Constraints and moved to new namespace.
- Renamed eval() to Eval() (.NET conventions).
- Renamed IMock.SetValue() to IMock.SetupResult (as in Java MockObjects).
--- NEW FILE: IConstraint.cs ---
namespace NMock.Constraints
{
public interface IConstraint
{
bool Eval(object val);
string Message { get; }
}
}
--- NEW FILE: Constraints.cs ---
using System;
using System.Text;
using System.Text.RegularExpressions;
namespace NMock.Constraints
{
public class IsNull : IConstraint
{
public bool Eval(object val)
{
return val == null;
}
public string Message
{
get { return "null"; }
}
}
public class IsAnything : IConstraint
{
public bool Eval(object val)
{
return true;
}
public string Message
{
get { return ""; }
}
}
public class IsIn : IConstraint
{
private object[] inList;
public IsIn(params object[] inList)
{
if (inList.Length == 1 && inList[0].GetType().IsArray)
{
Array arr = (Array)inList[0];
this.inList = new object[arr.Length];
arr.CopyTo(this.inList, 0);
}
else
{
this.inList = inList;
}
}
public bool Eval(object val)
{
foreach (object o in inList)
{
if (o.Equals(val))
{
return true;
}
}
return false;
}
public string Message
{
get
{
StringBuilder builder = new StringBuilder("IN ");
foreach (object o in inList)
{
builder.Append('<');
builder.Append(o);
builder.Append(">, ");
}
string result = builder.ToString();
if (result.EndsWith(", "))
{
result = result.Substring(0, result.Length - 2);
}
return result;
}
}
}
public class IsEqual : IConstraint {
private object compare;
public IsEqual(object compare)
{
this.compare = compare;
}
public bool Eval(object val)
{
return compare.Equals(val);
}
public string Message
{
get { return "<" + compare + ">"; }
}
}
public class IsTypeOf : IConstraint
{
private Type type;
public IsTypeOf(Type type)
{
this.type = type;
}
public bool Eval(object val)
{
return val == null ? false : type.IsAssignableFrom(val.GetType());
}
public string Message
{
get { return "typeof <" + type.FullName + ">"; }
}
}
public class Not : IConstraint
{
private IConstraint p;
public Not(IConstraint p)
{
this.p = p;
}
public bool Eval(object val)
{
return !p.Eval(val);
}
public string Message
{
get { return "NOT " + p.Message; }
}
}
public class And : IConstraint
{
private IConstraint p1, p2;
public And(IConstraint p1, IConstraint p2)
{
this.p1 = p1;
this.p2 = p2;
}
public bool Eval(object val)
{
return p1.Eval(val) && p2.Eval(val);
}
public string Message
{
get { return p1.Message + " AND " + p2.Message; }
}
}
public class Or : IConstraint
{
private IConstraint p1, p2;
public Or(IConstraint p1, IConstraint p2)
{
this.p1 = p1;
this.p2 = p2;
}
public bool Eval(object val)
{
return p1.Eval(val) || p2.Eval(val);
}
public string Message
{
get { return p1.Message + " OR " + p2.Message; }
}
}
public class NotNull : IConstraint
{
public bool Eval(object val)
{
return val != null;
}
public string Message
{
get { return "NOT null"; }
}
}
public class NotEqual : IConstraint
{
private IConstraint p;
public NotEqual(object compare)
{
p = new Not(new IsEqual(compare));
}
public bool Eval(object val)
{
return p.Eval(val);
}
public string Message
{
get { return p.Message; }
}
}
public class NotIn : IConstraint
{
private IConstraint p;
public NotIn(params object[] inList)
{
p = new Not(new IsIn(inList));
}
public bool Eval(object val)
{
return p.Eval(val);
}
public string Message
{
get { return p.Message; }
}
}
public class IsEqualIgnoreCase : IConstraint
{
private IConstraint p;
public IsEqualIgnoreCase(object compare)
{
p = new IsEqual(compare.ToString().ToLower());
}
public bool Eval(object val)
{
return p.Eval(val.ToString().ToLower());
}
public string Message
{
get { return p.Message; }
}
}
public class IsEqualIgnoreWhiteSpace : IConstraint
{
private IConstraint p;
public IsEqualIgnoreWhiteSpace(object compare)
{
p = new IsEqual(StripSpace(compare.ToString()));
}
public bool Eval(object val)
{
return p.Eval(StripSpace(val.ToString()));
}
public static string StripSpace(string s)
{
StringBuilder result = new StringBuilder();
bool lastWasSpace = true;
foreach(char c in s)
{
if (Char.IsWhiteSpace(c))
{
if (!lastWasSpace)
{
result.Append(' ');
}
lastWasSpace = true;
}
else
{
result.Append(c);
lastWasSpace = false;
}
}
return result.ToString().Trim();
}
public string Message
{
get { return p.Message; }
}
}
public class IsMatch : IConstraint
{
private Regex regex;
public IsMatch(Regex regex)
{
this.regex = regex;
}
public IsMatch(String regex) : this(new Regex(regex))
{
}
public IsMatch(String regex, bool ignoreCase) :
this(new Regex(regex, ignoreCase ? RegexOptions.IgnoreCase : RegexOptions.None))
{
}
public bool Eval(object val)
{
return val == null ? false : regex.IsMatch(val.ToString());
}
public string Message
{
get { return "<" + regex.ToString() + ">"; }
}
}
public class IsCloseTo : IConstraint
{
private double expected;
private double error;
public IsCloseTo(double expected, double error)
{
this.expected = expected;
this.error = error;
}
public bool Eval(object val)
{
try
{
double actual = Convert.ToDouble(val);
return Math.Abs(actual - expected) <= error;
}
catch (FormatException)
{
return false;
}
}
public string Message
{
get { return "<" + expected + ">"; }
}
}
public class Constraint : IConstraint
{
public delegate bool Method(object val);
private Method m;
public Constraint(Method m)
{
this.m = m;
}
public bool Eval(object val)
{
return m(val);
}
public string Message
{
get { return "Custom Constraint"; }
}
}
}
|
|
From: <joe...@us...> - 2002-11-15 22:48:23
|
Update of /cvsroot/nmock/nmock/test/NMock/Constraints
In directory usw-pr-cvs1:/tmp/cvs-serv3449/test/NMock/Constraints
Added Files:
ConstraintsTest.cs
Log Message:
- Added sensible error messages
- Renamed IMock.Object to IMock.MockInstance
- Renamed Conditions to Constraints and moved to new namespace.
- Renamed eval() to Eval() (.NET conventions).
- Renamed IMock.SetValue() to IMock.SetupResult (as in Java MockObjects).
--- NEW FILE: ConstraintsTest.cs ---
using NUnit.Framework;
using System.Text.RegularExpressions;
namespace NMock.Constraints
{
[TestFixture]
public class ConstraintsTest
{
private IConstraint c;
[Test]
public void IsNull()
{
c = new IsNull();
Assertion.Assert(c.Eval(null));
Assertion.Assert(!c.Eval(new object()));
Assertion.Assert(!c.Eval(1));
Assertion.Assert(!c.Eval(true));
Assertion.Assert(!c.Eval(false));
}
[Test]
public void NotNull()
{
c = new NotNull();
Assertion.Assert(!c.Eval(null));
Assertion.Assert(c.Eval(new object()));
}
[Test]
public void IsEqual()
{
object o1 = new object();
object o2 = new object();
c = new IsEqual(o1);
Assertion.Assert(c.Eval(o1));
Assertion.Assert(!c.Eval(o2));
Assertion.Assert(!c.Eval(null));
int i1 = 1;
int i2 = 2;
c = new IsEqual(i1);
Assertion.Assert(c.Eval(i1));
Assertion.Assert(c.Eval(1));
Assertion.Assert(!c.Eval(i2));
Assertion.Assert(!c.Eval(2));
}
[Test]
public void NotEqual()
{
object o1 = new object();
object o2 = new object();
c = new NotEqual(o1);
Assertion.Assert(!c.Eval(o1));
Assertion.Assert(c.Eval(o2));
Assertion.Assert(c.Eval(null));
int i1 = 1;
int i2 = 2;
c = new NotEqual(i1);
Assertion.Assert(!c.Eval(i1));
Assertion.Assert(!c.Eval(1));
Assertion.Assert(c.Eval(i2));
Assertion.Assert(c.Eval(2));
}
[Test]
public void IsAnything()
{
c = new IsAnything();
Assertion.Assert(c.Eval(null));
Assertion.Assert(c.Eval(0));
Assertion.Assert(c.Eval(99));
Assertion.Assert(c.Eval(-2));
Assertion.Assert(c.Eval(true));
Assertion.Assert(c.Eval(false));
Assertion.Assert(c.Eval(""));
Assertion.Assert(c.Eval("hello"));
Assertion.Assert(c.Eval(new object()));
}
[Test]
public void IsType()
{
c = new IsTypeOf(typeof(System.IO.TextReader));
Assertion.Assert(!c.Eval(null));
Assertion.Assert(c.Eval(new System.IO.StringReader("")));
Assertion.Assert(!c.Eval(new System.IO.StringWriter()));
}
[Test]
public void Not()
{
Assertion.Assert(new Not(new False()).Eval(null));
Assertion.Assert(!new Not(new True()).Eval(null));
}
[Test]
public void And()
{
Assertion.Assert( new And(new True() , new True() ).Eval(null));
Assertion.Assert(!new And(new True() , new False()).Eval(null));
Assertion.Assert(!new And(new False(), new True() ).Eval(null));
Assertion.Assert(!new And(new False(), new False()).Eval(null));
}
[Test]
public void Or()
{
Assertion.Assert( new Or(new True() , new True() ).Eval(null));
Assertion.Assert( new Or(new True() , new False()).Eval(null));
Assertion.Assert( new Or(new False(), new True() ).Eval(null));
Assertion.Assert(!new Or(new False(), new False()).Eval(null));
}
[Test]
public void IsIn()
{
c = new IsIn(2, 3, 5);
Assertion.Assert(!c.Eval(1));
Assertion.Assert(c.Eval(2));
Assertion.Assert(c.Eval(3));
Assertion.Assert(!c.Eval(4));
Assertion.Assert(c.Eval(5));
Assertion.Assert(!c.Eval(6));
Assertion.Assert(!c.Eval(null));
int[] array = {1, 2};
c = new IsIn(array);
Assertion.Assert(c.Eval(1));
Assertion.Assert(c.Eval(2));
Assertion.Assert(!c.Eval(3));
}
[Test]
public void NotIn()
{
c = new NotIn(1, 2);
Assertion.Assert(!c.Eval(1));
Assertion.Assert(!c.Eval(2));
Assertion.Assert(c.Eval(3));
int[] array = {1, 2};
c = new NotIn(array);
Assertion.Assert(!c.Eval(1));
Assertion.Assert(!c.Eval(2));
Assertion.Assert(c.Eval(3));
}
[Test]
public void IsEqualIgnoreCase()
{
c = new IsEqualIgnoreCase("heLLo");
Assertion.Assert(c.Eval("HELLO"));
Assertion.Assert(c.Eval("hello"));
Assertion.Assert(c.Eval("HelLo"));
Assertion.Assert(!c.Eval("abcde"));
}
[Test]
public void StripSpace()
{
Assertion.AssertEquals("Hello World", IsEqualIgnoreWhiteSpace.StripSpace("Hello\n \n World"));
Assertion.AssertEquals("Hello World", IsEqualIgnoreWhiteSpace.StripSpace(" Hello World "));
Assertion.AssertEquals("", IsEqualIgnoreWhiteSpace.StripSpace(" "));
}
[Test]
public void TestIsEqualIgnoreWhiteSpace()
{
c = new IsEqualIgnoreWhiteSpace("Hello World how\n are we?");
Assertion.Assert(c.Eval("Hello World how are we?"));
Assertion.Assert(c.Eval(" Hello World how are \n\n\twe?"));
Assertion.Assert(!c.Eval("HelloWorld how are we?"));
Assertion.Assert(!c.Eval("Hello World how are we"));
}
[Test]
public void IsMatch()
{
c = new IsMatch(new Regex(@"^th[aeiou]\w* .*$"));
Assertion.Assert(c.Eval("the world"));
Assertion.Assert(!c.Eval("theworld"));
Assertion.Assert(!c.Eval("ThE world"));
Assertion.Assert(!c.Eval(" the world"));
Assertion.Assert(c.Eval("thats nice"));
Assertion.Assert(!c.Eval(new object()));
Assertion.Assert(!c.Eval(null));
c = new IsMatch(@"^th[aeiou]\w* .*$");
Assertion.Assert(c.Eval("the world"));
Assertion.Assert(!c.Eval("theworld"));
Assertion.Assert(!c.Eval("ThE world"));
c = new IsMatch(@"^th[aeiou]\w* .*$", false);
Assertion.Assert(c.Eval("the world"));
Assertion.Assert(!c.Eval("theworld"));
Assertion.Assert(!c.Eval("ThE world"));
c = new IsMatch(@"^th[aeiou]\w* .*$", true);
Assertion.Assert(c.Eval("the world"));
Assertion.Assert(!c.Eval("theworld"));
Assertion.Assert(c.Eval("ThE world"));
}
[Test]
public void IsCloseTo()
{
c = new IsCloseTo(1.0, 0.5);
Assertion.Assert(c.Eval(1.0));
Assertion.Assert(c.Eval(0.5));
Assertion.Assert(c.Eval(1.5));
Assertion.Assert(c.Eval(1));
Assertion.Assert(c.Eval(0.5f));
Assertion.Assert(c.Eval(new decimal(1.5)));
Assertion.Assert(!c.Eval(0.49));
Assertion.Assert(!c.Eval(1.51));
Assertion.Assert(!c.Eval(-1.0));
Assertion.Assert(c.Eval("1.2"));
Assertion.Assert(!c.Eval("0.2"));
Assertion.Assert(!c.Eval("hello"));
Assertion.Assert(!c.Eval(null));
Assertion.Assert(!c.Eval(0));
Assertion.Assert(!c.Eval(0.0));
}
[Test]
public void Delegate()
{
c = new Constraint(new Constraint.Method(myEval));
myFlag = false;
Assertion.Assert(c.Eval(null));
Assertion.Assert(!c.Eval(null));
Assertion.Assert(c.Eval(null));
Assertion.Assert(!c.Eval(null));
}
[Test]
public void Messages()
{
Assertion.AssertEquals("null", new IsNull().Message);
Assertion.AssertEquals("", new IsAnything().Message);
Assertion.AssertEquals("IN <hi>, <1>, <bye>", new IsIn("hi", 1, "bye").Message);
Assertion.AssertEquals("<hi>", new IsEqual("hi").Message);
Assertion.AssertEquals("typeof <System.String>", new IsTypeOf(typeof(System.String)).Message);
Assertion.AssertEquals("NOT DUMMY", new Not(new Dummy()).Message);
Assertion.AssertEquals("DUMMY AND DUMMY", new And(new Dummy(), new Dummy()).Message);
Assertion.AssertEquals("DUMMY OR DUMMY", new Or(new Dummy(), new Dummy()).Message);
Assertion.AssertEquals("NOT null", new NotNull().Message);
Assertion.AssertEquals("NOT <hi>", new NotEqual("hi").Message);
Assertion.AssertEquals("NOT IN <hi>, <1>, <bye>", new NotIn("hi", 1, "bye").Message);
Assertion.AssertEquals("<hi>", new IsEqualIgnoreCase("hi").Message);
Assertion.AssertEquals("<hi>", new IsEqualIgnoreWhiteSpace("hi").Message);
Assertion.AssertEquals("<hi>", new IsMatch("hi").Message);
Assertion.AssertEquals("<7>", new IsCloseTo(7.0, 1.1).Message);
Assertion.AssertEquals("Custom Constraint", new Constraint(new Constraint.Method(myEval)).Message);
}
private bool myFlag;
private bool myEval(object val)
{
myFlag = !myFlag;
return myFlag;
}
class True : IConstraint
{
public bool Eval(object val)
{
return true;
}
public string Message
{
get { return null; }
}
}
class False : IConstraint
{
public bool Eval(object val)
{
return false;
}
public string Message
{
get { return null; }
}
}
class Dummy : IConstraint
{
public bool Eval(object val)
{
return false;
}
public string Message
{
get { return "DUMMY"; }
}
}
}
}
|
|
From: <joe...@us...> - 2002-11-15 22:45:54
|
Update of /cvsroot/nmock/nmock/test/NMock/Constraints In directory usw-pr-cvs1:/tmp/cvs-serv2645/test/NMock/Constraints Log Message: Directory /cvsroot/nmock/nmock/test/NMock/Constraints added to the repository |
|
From: <joe...@us...> - 2002-11-15 22:44:22
|
Update of /cvsroot/nmock/nmock/src/NMock/Constraints In directory usw-pr-cvs1:/tmp/cvs-serv2179/src/NMock/Constraints Log Message: Directory /cvsroot/nmock/nmock/src/NMock/Constraints added to the repository |
|
From: <joe...@us...> - 2002-11-15 22:31:14
|
Update of /cvsroot/nmock/nmock/test/NMock
In directory usw-pr-cvs1:/tmp/cvs-serv30242/test/NMock
Modified Files:
MockTest.cs DynamicMockTest.cs
Removed Files:
ConditionsTest.cs
Log Message:
- Added sensible error messages
- Renamed IMock.Object to IMock.MockInstance
- Renamed Conditions to Constraints and moved to new namespace.
- Renamed eval() to Eval() (.NET conventions).
- Renamed IMock.SetValue() to IMock.SetupResult (as in Java MockObjects).
Index: MockTest.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/test/NMock/MockTest.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** MockTest.cs 11 Nov 2002 20:00:21 -0000 1.3
--- MockTest.cs 15 Nov 2002 22:31:10 -0000 1.4
***************
*** 1,3 ****
--- 1,4 ----
using NUnit.Framework;
+ using NMock.Constraints;
namespace NMock
***************
*** 189,193 ****
[Test]
! public void DefaultEqualsCondition()
{
object o = new object();
--- 190,194 ----
[Test]
! public void DefaultEqualsConstraint()
{
object o = new object();
***************
*** 198,202 ****
[Test]
[ExpectedException(typeof(VerifyException))]
! public void DefaultEqualsConditionFailure()
{
mock.Expect("myMethod", new object());
--- 199,203 ----
[Test]
[ExpectedException(typeof(VerifyException))]
! public void DefaultEqualsConstraintFailure()
{
mock.Expect("myMethod", new object());
***************
*** 205,209 ****
[Test]
! public void DefaultAnythingCondition()
{
mock.Expect("myMethod", null, null);
--- 206,210 ----
[Test]
! public void DefaultAnythingConstraint()
{
mock.Expect("myMethod", null, null);
***************
*** 218,223 ****
public void FixedValue()
{
! mock.SetValue("myMethod", "hello");
! mock.SetValue("anotherMethod", "world");
Assertion.AssertEquals("hello", mock.Call("myMethod"));
Assertion.AssertEquals("hello", mock.Call("myMethod"));
--- 219,224 ----
public void FixedValue()
{
! mock.SetupResult("myMethod", "hello");
! mock.SetupResult("anotherMethod", "world");
Assertion.AssertEquals("hello", mock.Call("myMethod"));
Assertion.AssertEquals("hello", mock.Call("myMethod"));
***************
*** 226,234 ****
Assertion.AssertEquals("world", mock.Call("anotherMethod"));
Assertion.AssertEquals("world", mock.Call("anotherMethod"));
! mock.SetValue("myMethod", "bye");
Assertion.AssertEquals("bye", mock.Call("myMethod"));
Assertion.AssertEquals("bye", mock.Call("myMethod"));
Assertion.AssertEquals("world", mock.Call("anotherMethod"));
! mock.SetValue("myMethod", null);
Assertion.AssertNull(mock.Call("myMethod"));
Assertion.AssertNull(mock.Call("myMethod"));
--- 227,235 ----
Assertion.AssertEquals("world", mock.Call("anotherMethod"));
Assertion.AssertEquals("world", mock.Call("anotherMethod"));
! mock.SetupResult("myMethod", "bye");
Assertion.AssertEquals("bye", mock.Call("myMethod"));
Assertion.AssertEquals("bye", mock.Call("myMethod"));
Assertion.AssertEquals("world", mock.Call("anotherMethod"));
! mock.SetupResult("myMethod", null);
Assertion.AssertNull(mock.Call("myMethod"));
Assertion.AssertNull(mock.Call("myMethod"));
***************
*** 263,292 ****
mock.Call("z");
}
[Test]
! public void ExpectNiceErrorMessageTooManyTimes()
{
try
{
mock.Expect("x");
mock.Expect("x");
mock.Call("x");
mock.Call("x");
! mock.Call("x");
Assertion.Fail("Expected VerifyException");
}
catch (VerifyException e)
{
! Assertion.AssertEquals( "x() called too many times", e.Message );
}
! }
[Test]
! [Ignore("in progress")]
! public void ExpectNiceErrorMessageMethodNotCalledEnoughTimes()
{
try
{
mock.Expect("x");
mock.Verify();
Assertion.Fail("Expected VerifyException");
--- 264,328 ----
mock.Call("z");
}
+
+ [Test]
+ public void ExpectedNoCallsMessage()
+ {
+ try
+ {
+ mock.ExpectNoCall("x");
+ mock.Call("x");
+ Assertion.Fail("Expected VerifyException");
+ }
+ catch (VerifyException e)
+ {
+ Assertion.AssertEquals("x() called", e.Reason);
+ Assertion.AssertEquals(0, e.Expected);
+ Assertion.AssertEquals(1, e.Actual);
+ }
+ }
[Test]
! public void ExpectedOneCallMessage()
{
try
{
mock.Expect("x");
+ mock.Verify();
+ Assertion.Fail("Expected VerifyException");
+ }
+ catch (VerifyException e)
+ {
+ Assertion.AssertEquals("x() never called", e.Reason);
+ Assertion.AssertEquals(1, e.Expected);
+ Assertion.AssertEquals(0, e.Actual);
+ }
+ }
+
+ [Test]
+ public void ExpectedOneCallGotTooManyMessage()
+ {
+ try
+ {
mock.Expect("x");
mock.Call("x");
mock.Call("x");
! mock.Verify();
Assertion.Fail("Expected VerifyException");
}
catch (VerifyException e)
{
! Assertion.AssertEquals("x() called too many times", e.Reason);
! Assertion.AssertEquals(1, e.Expected);
! Assertion.AssertEquals(2, e.Actual);
}
! }
[Test]
! public void ExpectedManyCallsGotNoneMessage()
{
try
{
mock.Expect("x");
+ mock.Expect("x");
mock.Verify();
Assertion.Fail("Expected VerifyException");
***************
*** 294,335 ****
catch (VerifyException e)
{
! Assertion.AssertEquals( "x() was not called enough times Expected:<1> Was:<0>", e.Message );
}
! }
[Test]
! public void ExpectNiceErrorMessageMethodShouldNotBeCalled()
{
try
{
! mock.ExpectNoCall("x");
! mock.Call("x", null);
Assertion.Fail("Expected VerifyException");
}
catch (VerifyException e)
{
! Assertion.AssertEquals( "x() should not be called", e.Message );
}
! }
[Test]
! [Ignore("Work in progress")]
! public void NiceErrorMessageIncorrectParameter()
{
try
{
! mock.Expect("x", new object[] {1, 2, 3} );
! mock.Call("x", new object[] {2, 3, 4});
Assertion.Fail("Expected VerifyException");
}
catch (VerifyException e)
{
! Assertion.AssertEquals( "x() called with incorrect parameter (0) Expected:<1> Was:<2>", e.Message );
}
! }
[Test]
! public void NiceErrorMessageIncorrectNumberOfParameters()
{
try
--- 330,402 ----
catch (VerifyException e)
{
! Assertion.AssertEquals("x() never called", e.Reason);
! Assertion.AssertEquals(2, e.Expected);
! Assertion.AssertEquals(0, e.Actual);
}
! }
[Test]
! public void ExpectedManyCallsGotOneMessage()
{
try
{
! mock.Expect("x");
! mock.Expect("x");
! mock.Call("x");
! mock.Verify();
Assertion.Fail("Expected VerifyException");
}
catch (VerifyException e)
{
! Assertion.AssertEquals("x() not called enough times", e.Reason);
! Assertion.AssertEquals(2, e.Expected);
! Assertion.AssertEquals(1, e.Actual);
}
+ }
! [Test]
! public void ExpectedManyCallsGotTooManyMessage()
! {
! try
! {
! mock.Expect("x");
! mock.Expect("x");
! mock.Call("x");
! mock.Call("x");
! mock.Call("x");
! mock.Verify();
! Assertion.Fail("Expected VerifyException");
! }
! catch (VerifyException e)
! {
! Assertion.AssertEquals("x() called too many times", e.Reason);
! Assertion.AssertEquals(2, e.Expected);
! Assertion.AssertEquals(3, e.Actual);
! }
! }
[Test]
! public void ExpectedManyCallsGotNotEnoughMessage()
{
try
{
! mock.Expect("x");
! mock.Expect("x");
! mock.Expect("x");
! mock.Call("x");
! mock.Call("x");
! mock.Verify();
Assertion.Fail("Expected VerifyException");
}
catch (VerifyException e)
{
! Assertion.AssertEquals("x() not called enough times", e.Reason);
! Assertion.AssertEquals(3, e.Expected);
! Assertion.AssertEquals(2, e.Actual);
}
! }
[Test]
! public void IncorrectNumberOfParametersMessage()
{
try
***************
*** 341,345 ****
catch (VerifyException e)
{
! Assertion.AssertEquals( "x() called with incorrect number of parameters Expected:<3> Was:<2>", e.Message );
}
}
--- 408,435 ----
catch (VerifyException e)
{
! Assertion.AssertEquals("x() called with incorrect number of parameters", e.Reason);
! Assertion.AssertEquals(3, e.Expected);
! Assertion.AssertEquals(2, e.Actual);
! }
! }
!
! [Test]
! public void IncorrectParameterConstraintMessage()
! {
! try
! {
! IMock Constraint = new DynamicMock(typeof(IConstraint));
! Constraint.SetupResult("Message", "wee woo");
! Constraint.SetupResult("Eval", false);
!
! mock.Expect("x", new IsAnything(), (IConstraint)Constraint.MockInstance);
! mock.Call("x", "hello", "world");
! Assertion.Fail("Expected VerifyException");
! }
! catch (VerifyException e)
! {
! Assertion.AssertEquals("x() called with incorrect parameter (2)", e.Reason);
! Assertion.AssertEquals("wee woo", e.Expected);
! Assertion.AssertEquals("world", e.Actual);
}
}
Index: DynamicMockTest.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/test/NMock/DynamicMockTest.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** DynamicMockTest.cs 11 Nov 2002 20:00:21 -0000 1.2
--- DynamicMockTest.cs 15 Nov 2002 22:31:10 -0000 1.3
***************
*** 21,25 ****
mock.ExpectAndReturn("DoStuff", "world", "hello");
! IBlah blah = (IBlah)mock.Object;
Assertion.AssertEquals("world", blah.DoStuff("hello"));
--- 21,25 ----
mock.ExpectAndReturn("DoStuff", "world", "hello");
! IBlah blah = (IBlah)mock.MockInstance;
Assertion.AssertEquals("world", blah.DoStuff("hello"));
***************
*** 39,43 ****
{
IMock mock = new CustomMock(typeof(IBlah));
! IBlah blah = (IBlah)mock.Object;
Assertion.AssertEquals("CUSTOM", blah.DoStuff("hello"));
mock.Verify();
--- 39,43 ----
{
IMock mock = new CustomMock(typeof(IBlah));
! IBlah blah = (IBlah)mock.MockInstance;
Assertion.AssertEquals("CUSTOM", blah.DoStuff("hello"));
mock.Verify();
***************
*** 59,65 ****
DynamicMock mock = new DynamicMock(typeof(SameClass));
mock.Ignore("A");
! SameClass sc = (SameClass)mock.Object;
! mock.SetValue("b", "hello");
Assertion.AssertEquals("hello", sc.A());
--- 59,65 ----
DynamicMock mock = new DynamicMock(typeof(SameClass));
mock.Ignore("A");
! SameClass sc = (SameClass)mock.MockInstance;
! mock.SetupResult("b", "hello");
Assertion.AssertEquals("hello", sc.A());
--- ConditionsTest.cs DELETED ---
|
|
From: <joe...@us...> - 2002-11-15 22:31:14
|
Update of /cvsroot/nmock/nmock/test/NMock/Dynamic In directory usw-pr-cvs1:/tmp/cvs-serv30242/test/NMock/Dynamic Modified Files: ClassGeneratorTest.cs Log Message: - Added sensible error messages - Renamed IMock.Object to IMock.MockInstance - Renamed Conditions to Constraints and moved to new namespace. - Renamed eval() to Eval() (.NET conventions). - Renamed IMock.SetValue() to IMock.SetupResult (as in Java MockObjects). Index: ClassGeneratorTest.cs =================================================================== RCS file: /cvsroot/nmock/nmock/test/NMock/Dynamic/ClassGeneratorTest.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ClassGeneratorTest.cs 10 Nov 2002 16:32:27 -0000 1.1.1.1 --- ClassGeneratorTest.cs 15 Nov 2002 22:31:10 -0000 1.2 *************** *** 1,4 **** --- 1,5 ---- using NUnit.Framework; using NMock; + using NMock.Constraints; using System.Reflection.Emit; using System.Collections; |
|
From: <joe...@us...> - 2002-11-15 22:31:14
|
Update of /cvsroot/nmock/nmock/sample/random
In directory usw-pr-cvs1:/tmp/cvs-serv30242/sample/random
Modified Files:
WeatherTest.cs
Log Message:
- Added sensible error messages
- Renamed IMock.Object to IMock.MockInstance
- Renamed Conditions to Constraints and moved to new namespace.
- Renamed eval() to Eval() (.NET conventions).
- Renamed IMock.SetValue() to IMock.SetupResult (as in Java MockObjects).
Index: WeatherTest.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/sample/random/WeatherTest.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** WeatherTest.cs 10 Nov 2002 16:32:27 -0000 1.1.1.1
--- WeatherTest.cs 15 Nov 2002 22:31:10 -0000 1.2
***************
*** 16,20 ****
{
random = new DynamicMock(typeof(WeatherRandom));
! weather = new Weather((WeatherRandom)random.Object);
}
--- 16,20 ----
{
random = new DynamicMock(typeof(WeatherRandom));
! weather = new Weather((WeatherRandom)random.MockInstance);
}
***************
*** 22,27 ****
public void RandomRaining()
{
! random.SetValue("NextTemperature", 1.0);
! random.SetValue("NextIsRaining", true);
weather.Randomize();
Assertion.Assert("is raining", weather.IsRaining);
--- 22,27 ----
public void RandomRaining()
{
! random.SetupResult("NextTemperature", 1.0);
! random.SetupResult("NextIsRaining", true);
weather.Randomize();
Assertion.Assert("is raining", weather.IsRaining);
***************
*** 31,36 ****
public void RandomNotRaining()
{
! random.SetValue("NextTemperature", 1.0);
! random.SetValue("NextIsRaining", false);
weather.Randomize();
Assertion.Assert("is not raining", !weather.IsRaining);
--- 31,36 ----
public void RandomNotRaining()
{
! random.SetupResult("NextTemperature", 1.0);
! random.SetupResult("NextIsRaining", false);
weather.Randomize();
Assertion.Assert("is not raining", !weather.IsRaining);
***************
*** 41,46 ****
{
double TEMPERATURE = 20.0;
! random.SetValue("NextTemperature", TEMPERATURE);
! random.SetValue("NextIsRaining", false);
weather.Randomize();
Assertion.AssertEquals("temperature", TEMPERATURE, weather.Temperature);
--- 41,46 ----
{
double TEMPERATURE = 20.0;
! random.SetupResult("NextTemperature", TEMPERATURE);
! random.SetupResult("NextIsRaining", false);
weather.Randomize();
Assertion.AssertEquals("temperature", TEMPERATURE, weather.Temperature);
***************
*** 51,56 ****
{
double TEMPERATURE = 20.0;
! random.SetValue("NextTemperature", TEMPERATURE);
! random.SetValue("NextIsRaining", true);
weather.Randomize();
Assertion.AssertEquals("temperature", TEMPERATURE / 2.0, weather.Temperature);
--- 51,56 ----
{
double TEMPERATURE = 20.0;
! random.SetupResult("NextTemperature", TEMPERATURE);
! random.SetupResult("NextIsRaining", true);
weather.Randomize();
Assertion.AssertEquals("temperature", TEMPERATURE / 2.0, weather.Temperature);
***************
*** 67,79 ****
{
IMock random = new DynamicMock(typeof(System.Random));
! WeatherRandom weather = new DefaultWeatherRandom((System.Random)random.Object);
! random.SetValue("NextDouble", 0.0);
Assertion.Assert("is raining", weather.NextIsRaining());
! random.SetValue("NextDouble", DefaultWeatherRandom.CHANCE_OF_RAIN);
Assertion.Assert("is not raining", !weather.NextIsRaining());
! random.SetValue("NextDouble", 1.0);
Assertion.Assert("is not raining", !weather.NextIsRaining());
}
--- 67,79 ----
{
IMock random = new DynamicMock(typeof(System.Random));
! WeatherRandom weather = new DefaultWeatherRandom((System.Random)random.MockInstance);
! random.SetupResult("NextDouble", 0.0);
Assertion.Assert("is raining", weather.NextIsRaining());
! random.SetupResult("NextDouble", DefaultWeatherRandom.CHANCE_OF_RAIN);
Assertion.Assert("is not raining", !weather.NextIsRaining());
! random.SetupResult("NextDouble", 1.0);
Assertion.Assert("is not raining", !weather.NextIsRaining());
}
***************
*** 83,89 ****
{
IMock random = new DynamicMock(typeof(System.Random));
! WeatherRandom weather = new DefaultWeatherRandom((System.Random)random.Object);
! random.SetValue("NextDouble", 0.0);
Assertion.AssertEquals("should be min temperature",
DefaultWeatherRandom.MIN_TEMPERATURE,
--- 83,89 ----
{
IMock random = new DynamicMock(typeof(System.Random));
! WeatherRandom weather = new DefaultWeatherRandom((System.Random)random.MockInstance);
! random.SetupResult("NextDouble", 0.0);
Assertion.AssertEquals("should be min temperature",
DefaultWeatherRandom.MIN_TEMPERATURE,
***************
*** 91,95 ****
);
! random.SetValue("NextDouble", 0.5);
Assertion.AssertEquals("should be average temperature",
0.5 * (DefaultWeatherRandom.MIN_TEMPERATURE + DefaultWeatherRandom.MAX_TEMPERATURE),
--- 91,95 ----
);
! random.SetupResult("NextDouble", 0.5);
Assertion.AssertEquals("should be average temperature",
0.5 * (DefaultWeatherRandom.MIN_TEMPERATURE + DefaultWeatherRandom.MAX_TEMPERATURE),
***************
*** 97,101 ****
);
! random.SetValue("NextDouble", 1.0);
Assertion.AssertEquals("should be max temperature",
DefaultWeatherRandom.MAX_TEMPERATURE,
--- 97,101 ----
);
! random.SetupResult("NextDouble", 1.0);
Assertion.AssertEquals("should be max temperature",
DefaultWeatherRandom.MAX_TEMPERATURE,
|
|
From: <joe...@us...> - 2002-11-15 22:31:14
|
Update of /cvsroot/nmock/nmock/src/NMock
In directory usw-pr-cvs1:/tmp/cvs-serv30242/src/NMock
Modified Files:
DynamicMock.cs Mock.cs IMock.cs VerifyException.cs
Removed Files:
Conditions.cs ICondition.cs
Log Message:
- Added sensible error messages
- Renamed IMock.Object to IMock.MockInstance
- Renamed Conditions to Constraints and moved to new namespace.
- Renamed eval() to Eval() (.NET conventions).
- Renamed IMock.SetValue() to IMock.SetupResult (as in Java MockObjects).
Index: DynamicMock.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/DynamicMock.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** DynamicMock.cs 11 Nov 2002 20:00:19 -0000 1.2
--- DynamicMock.cs 15 Nov 2002 22:31:09 -0000 1.3
***************
*** 28,32 ****
}
! public override object Object
{
get
--- 28,32 ----
}
! public override object MockInstance
{
get
Index: Mock.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/Mock.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Mock.cs 11 Nov 2002 20:00:20 -0000 1.3
--- Mock.cs 15 Nov 2002 22:31:09 -0000 1.4
***************
*** 1,4 ****
--- 1,5 ----
using System;
using System.Collections;
+ using NMock.Constraints;
namespace NMock
***************
*** 13,16 ****
--- 14,18 ----
private IDictionary expectations;
private IDictionary values;
+ private IDictionary counters;
public Mock(string name)
***************
*** 19,22 ****
--- 21,25 ----
expectations = new Hashtable();
values = new Hashtable();
+ counters = new Hashtable();
}
***************
*** 27,31 ****
}
! public virtual object Object
{
get { return obj; }
--- 30,34 ----
}
! public virtual object MockInstance
{
get { return obj; }
***************
*** 44,48 ****
{
IList list = (IList) expectations[methodName];
! Assertion.AssertEquals(methodName + "() was not called enough times", 0, list.Count);
}
}
--- 47,53 ----
{
IList list = (IList) expectations[methodName];
! int count = counter(methodName);
! string msg = count == 0 ? "never called" : "not called enough times";
! Assertion.AssertEquals(methodName + "() " + msg, list.Count, count);
}
}
***************
*** 55,59 ****
public virtual void ExpectNoCall(string methodName)
{
! addExpectation(new Expectation(methodName, null, new VerifyException(methodName + "() should not be called"), null));
}
--- 60,64 ----
public virtual void ExpectNoCall(string methodName)
{
! addExpectation(new NoCallExpectation(methodName));
}
***************
*** 68,72 ****
}
! public virtual void SetValue(string methodName, object returnVal)
{
values[methodName] = returnVal;
--- 73,77 ----
}
! public virtual void SetupResult(string methodName, object returnVal)
{
values[methodName] = returnVal;
***************
*** 85,101 ****
if ( strict )
{
! throw new VerifyException(methodName + "() called too many times");
}
return null;
}
! if (list.Count == 0)
{
! Assertion.Fail(methodName + "() called too many times");
}
! Expectation e = (Expectation)list[0];
! list.RemoveAt(0);
return e.Verify(methodName, args);
}
private void addExpectation(Expectation e)
{
--- 90,120 ----
if ( strict )
{
! throw new VerifyException(methodName + "() called too many times", 0, counter(methodName) + 1);
}
return null;
}
! if (list.Count == counter(methodName))
{
! throw new VerifyException(methodName + "() called too many times", list.Count, counter(methodName) + 1);
}
! Expectation e = (Expectation)list[counter(methodName)];
! if (e is NoCallExpectation)
! {
! throw new VerifyException(methodName + "() called", 0, 1);
! }
! increment(methodName);
return e.Verify(methodName, args);
}
+ private void increment(string methodName)
+ {
+ counters[methodName] = counter(methodName) + 1;
+ }
+
+ private int counter(string methodName)
+ {
+ return counters.Contains(methodName) ? (int)counters[methodName] : 0;
+ }
+
private void addExpectation(Expectation e)
{
***************
*** 134,139 ****
public virtual object Verify(string methodName, object[] args)
{
- Assertion.AssertEquals(this.MethodName, methodName);
-
if ( this.args.Length > 0 )
{
--- 153,156 ----
***************
*** 146,168 ****
object expectedArg = this.args[i];
object actualArg = args[i];
! ICondition condition = expectedArg as ICondition;
! // if expectedArg is not an ICondition, use default
// behavior of IsEqual or IsAnything
! if (condition == null)
{
if (expectedArg == null)
{
! condition = new IsAnything();
}
else
{
! condition = new IsEqual(expectedArg);
}
}
! String messageFormat = "{0}() called with incorrect parameter ({1}) Expected:<{2}> Was:<{3}>";
! //String message = String.Format(messageFormat, methodName, i, condition.Description, actualArg);
! String message = String.Format(messageFormat, methodName, i, "fixme", actualArg);
! Assertion.Assert(message, condition.eval(actualArg));
}
}
--- 163,187 ----
object expectedArg = this.args[i];
object actualArg = args[i];
! IConstraint Constraint = expectedArg as IConstraint;
! // if expectedArg is not an IConstraint, use default
// behavior of IsEqual or IsAnything
! if (Constraint == null)
{
if (expectedArg == null)
{
! Constraint = new IsAnything();
}
else
{
! Constraint = new IsEqual(expectedArg);
}
}
! String messageFormat = "{0}() called with incorrect parameter ({1})";
! String message = String.Format(messageFormat, methodName, i + 1);
! if (!Constraint.Eval(actualArg))
! {
! throw new VerifyException(message, Constraint.Message, actualArg);
! }
}
}
***************
*** 177,180 ****
--- 196,206 ----
}
}
+
+ private class NoCallExpectation : Expectation
+ {
+ public NoCallExpectation(string methodName) : base(methodName, null, null, null)
+ {
+ }
+ }
private class Assertion
***************
*** 184,209 ****
if (!expression)
{
! Fail(message);
}
}
! public static void AssertEquals(object a, object b)
! {
! AssertEquals("Verification failed", a, b);
! }
!
! public static void AssertEquals(string message, object a, object b)
{
! if (! a.Equals(b))
{
! String messageFormat = "{0} Expected:<{1}> Was:<{2}>";
! Fail(String.Format(messageFormat, message, a, b));
}
}
- public static void Fail(string msg)
- {
- throw new VerifyException(msg);
- }
}
--- 210,225 ----
if (!expression)
{
! throw new VerifyException(message, null, null);
}
}
! public static void AssertEquals(string message, object expected, object actual)
{
! if (!expected.Equals(actual))
{
! throw new VerifyException(message, expected, actual);
}
}
}
Index: IMock.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/IMock.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** IMock.cs 10 Nov 2002 16:32:27 -0000 1.1.1.1
--- IMock.cs 15 Nov 2002 22:31:09 -0000 1.2
***************
*** 18,22 ****
/// Get mocked version of object.
/// </summary>
! object Object { get; }
/// <summary>
--- 18,22 ----
/// Get mocked version of object.
/// </summary>
! object MockInstance { get; }
/// <summary>
***************
*** 53,57 ****
/// each time. Useful for getter style methods.
/// </summary>
! void SetValue(string methodName, object returnVal);
/// <summary>
--- 53,57 ----
/// each time. Useful for getter style methods.
/// </summary>
! void SetupResult(string methodName, object returnVal);
/// <summary>
Index: VerifyException.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/VerifyException.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** VerifyException.cs 10 Nov 2002 16:32:27 -0000 1.1.1.1
--- VerifyException.cs 15 Nov 2002 22:31:09 -0000 1.2
***************
*** 5,10 ****
public class VerifyException : Exception
{
! public VerifyException(string msg) : base(msg)
{
}
}
--- 5,43 ----
public class VerifyException : Exception
{
!
! private string reason;
! private object actual;
! private object expected;
!
! private const string format = "{0}\nexpected:{1}\n but was:<{2}>";
!
! public VerifyException(string reason, object expected, object actual) : base(reason)
{
+ this.reason = reason;
+ this.expected = expected;
+ this.actual = actual;
+ }
+
+ public string Reason
+ {
+ get { return reason; }
+ }
+
+ public object Expected
+ {
+ get { return expected; }
+ }
+
+ public object Actual
+ {
+ get { return actual; }
+ }
+
+ public override string Message
+ {
+ get
+ {
+ return String.Format(format, reason, expected, actual);
+ }
}
}
--- Conditions.cs DELETED ---
--- ICondition.cs DELETED ---
|
|
From: <joe...@us...> - 2002-11-15 22:31:14
|
Update of /cvsroot/nmock/nmock/sample/order
In directory usw-pr-cvs1:/tmp/cvs-serv30242/sample/order
Modified Files:
OrderProcessorTest.cs
Log Message:
- Added sensible error messages
- Renamed IMock.Object to IMock.MockInstance
- Renamed Conditions to Constraints and moved to new namespace.
- Renamed eval() to Eval() (.NET conventions).
- Renamed IMock.SetValue() to IMock.SetupResult (as in Java MockObjects).
Index: OrderProcessorTest.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/sample/order/OrderProcessorTest.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** OrderProcessorTest.cs 10 Nov 2002 16:32:27 -0000 1.1.1.1
--- OrderProcessorTest.cs 15 Nov 2002 22:31:09 -0000 1.2
***************
*** 29,36 ****
// setup mock Order and populate with default return values.
order = new DynamicMock(typeof(Order));
! order.SetValue("Amount", 1002.0);
! order.SetValue("Urgent", false);
! order.SetValue("Number", 123);
! order.SetValue("User", "joe");
// create mock Notifier
--- 29,36 ----
// setup mock Order and populate with default return values.
order = new DynamicMock(typeof(Order));
! order.SetupResult("Amount", 1002.0);
! order.SetupResult("Urgent", false);
! order.SetupResult("Number", 123);
! order.SetupResult("User", "joe");
// create mock Notifier
***************
*** 41,45 ****
// switch the OrderProcessor to use the mock Notifier
! orderProcessor.notifier = (Notifier)notifier.Object;
}
--- 41,45 ----
// switch the OrderProcessor to use the mock Notifier
! orderProcessor.notifier = (Notifier)notifier.MockInstance;
}
***************
*** 51,55 ****
// execute
! orderProcessor.Process((Order)order.Object);
// verify
--- 51,55 ----
// execute
! orderProcessor.Process((Order)order.MockInstance);
// verify
***************
*** 61,70 ****
{
// setup
! order.SetValue("Number", 456);
! order.SetValue("User", "chris");
notifier.Expect("NotifyUser", "chris", "Order 456 has been dispatched");
// execute
! orderProcessor.Process((Order)order.Object);
// verify
--- 61,70 ----
{
// setup
! order.SetupResult("Number", 456);
! order.SetupResult("User", "chris");
notifier.Expect("NotifyUser", "chris", "Order 456 has been dispatched");
// execute
! orderProcessor.Process((Order)order.MockInstance);
// verify
***************
*** 76,83 ****
{
// setup
! order.SetValue("Amount", 999.0);
// execute
! orderProcessor.Process((Order)order.Object);
// verify
--- 76,83 ----
{
// setup
! order.SetupResult("Amount", 999.0);
// execute
! orderProcessor.Process((Order)order.MockInstance);
// verify
***************
*** 89,98 ****
{
// setuo
! order.SetValue("Urgent", true);
notifier.Expect("NotifyUser", "joe", "Order 123 has been dispatched");
notifier.Expect("NotifyAdmin", "Order 123 needs to be urgently dispatched to joe");
// execute
! orderProcessor.Process((Order)order.Object);
// verify
--- 89,98 ----
{
// setuo
! order.SetupResult("Urgent", true);
notifier.Expect("NotifyUser", "joe", "Order 123 has been dispatched");
notifier.Expect("NotifyAdmin", "Order 123 needs to be urgently dispatched to joe");
// execute
! orderProcessor.Process((Order)order.MockInstance);
// verify
***************
*** 104,112 ****
{
// setup
! order.SetValue("Amount", 999.0);
! order.SetValue("Urgent", true);
// execute
! orderProcessor.Process((Order)order.Object);
// verify
--- 104,112 ----
{
// setup
! order.SetupResult("Amount", 999.0);
! order.SetupResult("Urgent", true);
// execute
! orderProcessor.Process((Order)order.MockInstance);
// verify
|
|
From: <joe...@us...> - 2002-11-11 20:00:24
|
Update of /cvsroot/nmock/nmock/test/NMock
In directory usw-pr-cvs1:/tmp/cvs-serv30478/test/NMock
Modified Files:
MockTest.cs DynamicMockTest.cs
Log Message:
Integrated some changes that have been lingering around for a while:
- mocking of self methods.
- descriptive error messages.
Index: MockTest.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/test/NMock/MockTest.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** MockTest.cs 10 Nov 2002 18:21:50 -0000 1.2
--- MockTest.cs 11 Nov 2002 20:00:21 -0000 1.3
***************
*** 263,266 ****
--- 263,348 ----
mock.Call("z");
}
+
+ [Test]
+ public void ExpectNiceErrorMessageTooManyTimes()
+ {
+ try
+ {
+ mock.Expect("x");
+ mock.Expect("x");
+ mock.Call("x");
+ mock.Call("x");
+ mock.Call("x");
+ Assertion.Fail("Expected VerifyException");
+ }
+ catch (VerifyException e)
+ {
+ Assertion.AssertEquals( "x() called too many times", e.Message );
+ }
+ }
+
+ [Test]
+ [Ignore("in progress")]
+ public void ExpectNiceErrorMessageMethodNotCalledEnoughTimes()
+ {
+ try
+ {
+ mock.Expect("x");
+ mock.Verify();
+ Assertion.Fail("Expected VerifyException");
+ }
+ catch (VerifyException e)
+ {
+ Assertion.AssertEquals( "x() was not called enough times Expected:<1> Was:<0>", e.Message );
+ }
+ }
+
+ [Test]
+ public void ExpectNiceErrorMessageMethodShouldNotBeCalled()
+ {
+ try
+ {
+ mock.ExpectNoCall("x");
+ mock.Call("x", null);
+ Assertion.Fail("Expected VerifyException");
+ }
+ catch (VerifyException e)
+ {
+ Assertion.AssertEquals( "x() should not be called", e.Message );
+ }
+
+ }
+
+ [Test]
+ [Ignore("Work in progress")]
+ public void NiceErrorMessageIncorrectParameter()
+ {
+ try
+ {
+ mock.Expect("x", new object[] {1, 2, 3} );
+ mock.Call("x", new object[] {2, 3, 4});
+ Assertion.Fail("Expected VerifyException");
+ }
+ catch (VerifyException e)
+ {
+ Assertion.AssertEquals( "x() called with incorrect parameter (0) Expected:<1> Was:<2>", e.Message );
+ }
+ }
+
+ [Test]
+ public void NiceErrorMessageIncorrectNumberOfParameters()
+ {
+ try
+ {
+ mock.Expect("x", new object[] {1, 2, 3} );
+ mock.Call("x", new object[] {2, 3});
+ Assertion.Fail("Expected VerifyException");
+ }
+ catch (VerifyException e)
+ {
+ Assertion.AssertEquals( "x() called with incorrect number of parameters Expected:<3> Was:<2>", e.Message );
+ }
+ }
+
}
}
Index: DynamicMockTest.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/test/NMock/DynamicMockTest.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** DynamicMockTest.cs 10 Nov 2002 16:32:27 -0000 1.1.1.1
--- DynamicMockTest.cs 11 Nov 2002 20:00:21 -0000 1.2
***************
*** 53,56 ****
--- 53,81 ----
}
}
+
+ [Test]
+ public void MockingPartsOfSameObject()
+ {
+ DynamicMock mock = new DynamicMock(typeof(SameClass));
+ mock.Ignore("A");
+ SameClass sc = (SameClass)mock.Object;
+
+ mock.SetValue("b", "hello");
+
+ Assertion.AssertEquals("hello", sc.A());
+ }
+
+ public class SameClass
+ {
+ public virtual string A()
+ {
+ return b();
+ }
+
+ protected virtual string b()
+ {
+ throw new Exception("Ouch");
+ }
+ }
}
}
|
|
From: <joe...@us...> - 2002-11-11 20:00:24
|
Update of /cvsroot/nmock/nmock/src/NMock/Dynamic
In directory usw-pr-cvs1:/tmp/cvs-serv30478/src/NMock/Dynamic
Modified Files:
ClassGenerator.cs
Log Message:
Integrated some changes that have been lingering around for a while:
- mocking of self methods.
- descriptive error messages.
Index: ClassGenerator.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/Dynamic/ClassGenerator.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** ClassGenerator.cs 10 Nov 2002 16:32:27 -0000 1.1.1.1
--- ClassGenerator.cs 11 Nov 2002 20:00:20 -0000 1.2
***************
*** 11,22 ****
private static IDictionary boxingOpCodes;
! public object Generate(Type type, IMock mock)
{
TypeBuilder typeBuilder = getTypeBuilder("Mock" + type.Name, type);
FieldBuilder mockFieldBuilder = typeBuilder.DefineField("underlyingMock", typeof(IMock), FieldAttributes.Public);
! MethodInfo[] methods = type.GetMethods();
foreach ( MethodInfo m in methods )
{
! implementMethod(type, typeBuilder, m, mockFieldBuilder);
}
Type proxyType = typeBuilder.CreateType();
--- 11,30 ----
private static IDictionary boxingOpCodes;
! public virtual object Generate(Type type, IMock mock)
! {
! return Generate(type, mock, new ArrayList());
! }
!
! public virtual object Generate(Type type, IMock mock, IList methodsToIgnore)
{
TypeBuilder typeBuilder = getTypeBuilder("Mock" + type.Name, type);
FieldBuilder mockFieldBuilder = typeBuilder.DefineField("underlyingMock", typeof(IMock), FieldAttributes.Public);
! MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
foreach ( MethodInfo m in methods )
{
! if(!methodsToIgnore.Contains(m.Name))
! {
! implementMethod(type, typeBuilder, m, mockFieldBuilder);
! }
}
Type proxyType = typeBuilder.CreateType();
|
|
From: <joe...@us...> - 2002-11-11 20:00:24
|
Update of /cvsroot/nmock/nmock/src/NMock
In directory usw-pr-cvs1:/tmp/cvs-serv30478/src/NMock
Modified Files:
DynamicMock.cs Mock.cs
Log Message:
Integrated some changes that have been lingering around for a while:
- mocking of self methods.
- descriptive error messages.
Index: DynamicMock.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/DynamicMock.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** DynamicMock.cs 10 Nov 2002 16:32:27 -0000 1.1.1.1
--- DynamicMock.cs 11 Nov 2002 20:00:19 -0000 1.2
***************
*** 1,3 ****
--- 1,4 ----
using System;
+ using System.Collections;
using NMock.Dynamic;
***************
*** 9,16 ****
--- 10,19 ----
private object obj;
private Type type;
+ private IList ignore;
public DynamicMock(Type type) : this(type, null)
{
string name = type.Name;
+ ignore = new ArrayList();
if (name.StartsWith("I"))
{
***************
*** 37,44 ****
}
private void generate()
{
ClassGenerator cg = new ClassGenerator();
! obj = cg.Generate(type, this);
}
}
--- 40,55 ----
}
+ /// <summary>
+ /// Don't generate mock method for suppied methodName.
+ /// </summary>
+ public virtual void Ignore(string methodName)
+ {
+ ignore.Add(methodName);
+ }
+
private void generate()
{
ClassGenerator cg = new ClassGenerator();
! obj = cg.Generate(type, this, ignore);
}
}
Index: Mock.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/Mock.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Mock.cs 10 Nov 2002 18:21:50 -0000 1.2
--- Mock.cs 11 Nov 2002 20:00:20 -0000 1.3
***************
*** 41,47 ****
public virtual void Verify()
{
! foreach (IList list in expectations.Values)
{
! Assertion.AssertEquals(0, list.Count);
}
}
--- 41,48 ----
public virtual void Verify()
{
! foreach (String methodName in expectations.Keys)
{
! IList list = (IList) expectations[methodName];
! Assertion.AssertEquals(methodName + "() was not called enough times", 0, list.Count);
}
}
***************
*** 54,58 ****
public virtual void ExpectNoCall(string methodName)
{
! addExpectation(new Expectation(methodName, null, new VerifyException(methodName + "() should never be called."), null));
}
--- 55,59 ----
public virtual void ExpectNoCall(string methodName)
{
! addExpectation(new Expectation(methodName, null, new VerifyException(methodName + "() should not be called"), null));
}
***************
*** 135,160 ****
Assertion.AssertEquals(this.MethodName, methodName);
! // assert that each passed in arg is validated by the appropriate condition.
! for (int i = 0; i < this.args.Length; i++)
{
! object expectedArg = this.args[i];
! object actualArg = args[i];
! ICondition condition = expectedArg as ICondition;
!
! // if expectedArg is not an ICondition, use default
! // behavior of IsEqual or IsAnything
! if (condition == null)
{
! if (expectedArg == null)
! {
! condition = new IsAnything();
! }
! else
{
! condition = new IsEqual(expectedArg);
}
}
-
- Assertion.Assert(condition.eval(actualArg));
}
--- 136,169 ----
Assertion.AssertEquals(this.MethodName, methodName);
! if ( this.args.Length > 0 )
{
! // assert that the correct number of arguments were passed
! Assertion.AssertEquals("x() called with incorrect number of parameters", this.args.Length, args.Length);
!
! // assert that each passed in arg is validated by the appropriate predicate.
! for (int i = 0; i < this.args.Length; i++)
{
! object expectedArg = this.args[i];
! object actualArg = args[i];
! ICondition condition = expectedArg as ICondition;
!
! // if expectedArg is not an ICondition, use default
! // behavior of IsEqual or IsAnything
! if (condition == null)
{
! if (expectedArg == null)
! {
! condition = new IsAnything();
! }
! else
! {
! condition = new IsEqual(expectedArg);
! }
}
+ String messageFormat = "{0}() called with incorrect parameter ({1}) Expected:<{2}> Was:<{3}>";
+ //String message = String.Format(messageFormat, methodName, i, condition.Description, actualArg);
+ String message = String.Format(messageFormat, methodName, i, "fixme", actualArg);
+ Assertion.Assert(message, condition.eval(actualArg));
}
}
***************
*** 171,179 ****
private class Assertion
{
! public static void Assert(bool expression)
{
if (!expression)
{
! Fail("Verification failed.");
}
}
--- 180,188 ----
private class Assertion
{
! public static void Assert(string message, bool expression)
{
if (!expression)
{
! Fail(message);
}
}
***************
*** 181,187 ****
public static void AssertEquals(object a, object b)
{
if (! a.Equals(b))
{
! Fail("Verification failed.");
}
}
--- 190,202 ----
public static void AssertEquals(object a, object b)
{
+ AssertEquals("Verification failed", a, b);
+ }
+
+ public static void AssertEquals(string message, object a, object b)
+ {
if (! a.Equals(b))
{
! String messageFormat = "{0} Expected:<{1}> Was:<{2}>";
! Fail(String.Format(messageFormat, message, a, b));
}
}
|
|
From: <joe...@us...> - 2002-11-11 19:35:30
|
Update of /cvsroot/nmock/nmock/lib In directory usw-pr-cvs1:/tmp/cvs-serv21182/lib Modified Files: nunit-console.exe nunit.framework.dll nunit.util.dll Log Message: Fixed corrupted files. Index: nunit-console.exe =================================================================== RCS file: /cvsroot/nmock/nmock/lib/nunit-console.exe,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 Binary files /tmp/cvsqtxjkh and /tmp/cvsEbkrGq differ Index: nunit.framework.dll =================================================================== RCS file: /cvsroot/nmock/nmock/lib/nunit.framework.dll,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 Binary files /tmp/cvsbDypzi and /tmp/cvs6CReRs differ Index: nunit.util.dll =================================================================== RCS file: /cvsroot/nmock/nmock/lib/nunit.util.dll,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 Binary files /tmp/cvseid8yj and /tmp/cvsw1xpRu differ |
|
From: <joe...@us...> - 2002-11-10 19:26:48
|
Update of /cvsroot/nmock/website In directory usw-pr-cvs1:/tmp/cvs-serv27981 Added Files: requirements.html Log Message: Added requirements page --- NEW FILE: requirements.html --- <title>Requirements</title> <ul> <li> <b>.NET Compiler</b><br> Any one of the following: <ul> <li>.NET Framework SDK</li> <li>Visual Studio.NET</li> <li>Rotor Shared-Source</li> <li>Mono</li> </ul> </li> <li> <b>Unit Testing Framework</b><br> NMock is not tied to any particular unit-testing framework. <ul> <li><a href="http://www.nunit.org/">NUnit 2</a> <i>(Recommended)</i></li> <li>NUnit 1</li> <li>#Unit</li> <li>X-Unity</li> <li>Custom grown...</li> </ul> </li> </ul> |
|
From: <joe...@us...> - 2002-11-10 19:26:48
|
Update of /cvsroot/nmock/website/decorators In directory usw-pr-cvs1:/tmp/cvs-serv27981/decorators Modified Files: main.jsp Log Message: Added requirements page Index: main.jsp =================================================================== RCS file: /cvsroot/nmock/website/decorators/main.jsp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** main.jsp 10 Nov 2002 18:33:08 -0000 1.5 --- main.jsp 10 Nov 2002 19:26:44 -0000 1.6 *************** *** 69,72 **** --- 69,73 ---- <strong>NMock</strong> <div><small><a href="./index.html">Overview</a></small></div> + <div><small><a href="./requirements.html">Requirements</a></small></div> <div><small><a href="./license.html">License</a></small></div> <div><small><a href="./download.html">Download</a></small></div> |
|
From: <joe...@us...> - 2002-11-10 18:33:11
|
Update of /cvsroot/nmock/website/decorators In directory usw-pr-cvs1:/tmp/cvs-serv30508/decorators Modified Files: main.jsp Log Message: Added Jira links to nav Index: main.jsp =================================================================== RCS file: /cvsroot/nmock/website/decorators/main.jsp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** main.jsp 10 Nov 2002 16:56:18 -0000 1.4 --- main.jsp 10 Nov 2002 18:33:08 -0000 1.5 *************** *** 69,76 **** <strong>NMock</strong> <div><small><a href="./index.html">Overview</a></small></div> - <div><small><a href="./team.html">Project Team</a></small></div> - <div><small><a href="./source.html">Source Code</a></small></div> <div><small><a href="./license.html">License</a></small></div> <div><small><a href="./download.html">Download</a></small></div> </div> </div> --- 69,81 ---- <strong>NMock</strong> <div><small><a href="./index.html">Overview</a></small></div> <div><small><a href="./license.html">License</a></small></div> <div><small><a href="./download.html">Download</a></small></div> + <div><small><a href="./team.html">Project Team</a></small></div> + </div> + <div> + <strong>Development</strong> + <div><small><a href="source.html">Source Code</a></small></div> + <div><small><a href="http://jira.truemesh.com/secure/BrowseProject.jspa?id=10001&report=compversions">Tracker</small></div> + <div><small><a href="http://jira.truemesh.com/secure/BrowseProject.jspa?id=10001&report=roadmap">Road Map</small></div> </div> </div> |
|
From: <joe...@us...> - 2002-11-10 18:21:54
|
Update of /cvsroot/nmock/nmock/test/NMock
In directory usw-pr-cvs1:/tmp/cvs-serv24420/test/NMock
Modified Files:
MockTest.cs
Added Files:
ConditionsTest.cs
Removed Files:
PredicatesTest.cs
Log Message:
Renamed Predicate to Condition
--- NEW FILE: ConditionsTest.cs ---
using NUnit.Framework;
using System.Text.RegularExpressions;
namespace NMock
{
[TestFixture]
public class ConditionsTest
{
private ICondition c;
[Test]
public void IsNull()
{
c = new IsNull();
Assertion.Assert(c.eval(null));
Assertion.Assert(!c.eval(new object()));
Assertion.Assert(!c.eval(1));
Assertion.Assert(!c.eval(true));
Assertion.Assert(!c.eval(false));
}
[Test]
public void NotNull()
{
c = new NotNull();
Assertion.Assert(!c.eval(null));
Assertion.Assert(c.eval(new object()));
}
[Test]
public void IsEqual()
{
object o1 = new object();
object o2 = new object();
c = new IsEqual(o1);
Assertion.Assert(c.eval(o1));
Assertion.Assert(!c.eval(o2));
Assertion.Assert(!c.eval(null));
int i1 = 1;
int i2 = 2;
c = new IsEqual(i1);
Assertion.Assert(c.eval(i1));
Assertion.Assert(c.eval(1));
Assertion.Assert(!c.eval(i2));
Assertion.Assert(!c.eval(2));
}
[Test]
public void NotEqual()
{
object o1 = new object();
object o2 = new object();
c = new NotEqual(o1);
Assertion.Assert(!c.eval(o1));
Assertion.Assert(c.eval(o2));
Assertion.Assert(c.eval(null));
int i1 = 1;
int i2 = 2;
c = new NotEqual(i1);
Assertion.Assert(!c.eval(i1));
Assertion.Assert(!c.eval(1));
Assertion.Assert(c.eval(i2));
Assertion.Assert(c.eval(2));
}
[Test]
public void IsAnything()
{
c = new IsAnything();
Assertion.Assert(c.eval(null));
Assertion.Assert(c.eval(0));
Assertion.Assert(c.eval(99));
Assertion.Assert(c.eval(-2));
Assertion.Assert(c.eval(true));
Assertion.Assert(c.eval(false));
Assertion.Assert(c.eval(""));
Assertion.Assert(c.eval("hello"));
Assertion.Assert(c.eval(new object()));
}
[Test]
public void IsType()
{
c = new IsTypeOf(typeof(System.IO.TextReader));
Assertion.Assert(!c.eval(null));
Assertion.Assert(c.eval(new System.IO.StringReader("")));
Assertion.Assert(!c.eval(new System.IO.StringWriter()));
}
[Test]
public void Not()
{
Assertion.Assert(new Not(new False()).eval(null));
Assertion.Assert(!new Not(new True()).eval(null));
}
[Test]
public void And()
{
Assertion.Assert( new And(new True() , new True() ).eval(null));
Assertion.Assert(!new And(new True() , new False()).eval(null));
Assertion.Assert(!new And(new False(), new True() ).eval(null));
Assertion.Assert(!new And(new False(), new False()).eval(null));
}
[Test]
public void Or()
{
Assertion.Assert( new Or(new True() , new True() ).eval(null));
Assertion.Assert( new Or(new True() , new False()).eval(null));
Assertion.Assert( new Or(new False(), new True() ).eval(null));
Assertion.Assert(!new Or(new False(), new False()).eval(null));
}
[Test]
public void IsIn()
{
c = new IsIn(2, 3, 5);
Assertion.Assert(!c.eval(1));
Assertion.Assert(c.eval(2));
Assertion.Assert(c.eval(3));
Assertion.Assert(!c.eval(4));
Assertion.Assert(c.eval(5));
Assertion.Assert(!c.eval(6));
Assertion.Assert(!c.eval(null));
int[] array = {1, 2};
c = new IsIn(array);
Assertion.Assert(c.eval(1));
Assertion.Assert(c.eval(2));
Assertion.Assert(!c.eval(3));
}
[Test]
public void NotIn()
{
c = new NotIn(1, 2);
Assertion.Assert(!c.eval(1));
Assertion.Assert(!c.eval(2));
Assertion.Assert(c.eval(3));
int[] array = {1, 2};
c = new NotIn(array);
Assertion.Assert(!c.eval(1));
Assertion.Assert(!c.eval(2));
Assertion.Assert(c.eval(3));
}
[Test]
public void IsEqualIgnoreCase()
{
c = new IsEqualIgnoreCase("heLLo");
Assertion.Assert(c.eval("HELLO"));
Assertion.Assert(c.eval("hello"));
Assertion.Assert(c.eval("HelLo"));
Assertion.Assert(!c.eval("abcde"));
}
[Test]
public void StripSpace()
{
Assertion.AssertEquals("Hello World", IsEqualIgnoreWhiteSpace.StripSpace("Hello\n \n World"));
Assertion.AssertEquals("Hello World", IsEqualIgnoreWhiteSpace.StripSpace(" Hello World "));
Assertion.AssertEquals("", IsEqualIgnoreWhiteSpace.StripSpace(" "));
}
[Test]
public void TestIsEqualIgnoreWhiteSpace()
{
c = new IsEqualIgnoreWhiteSpace("Hello World how\n are we?");
Assertion.Assert(c.eval("Hello World how are we?"));
Assertion.Assert(c.eval(" Hello World how are \n\n\twe?"));
Assertion.Assert(!c.eval("HelloWorld how are we?"));
Assertion.Assert(!c.eval("Hello World how are we"));
}
[Test]
public void IsMatch()
{
c = new IsMatch(new Regex(@"^th[aeiou]\w* .*$"));
Assertion.Assert(c.eval("the world"));
Assertion.Assert(!c.eval("theworld"));
Assertion.Assert(!c.eval("ThE world"));
Assertion.Assert(!c.eval(" the world"));
Assertion.Assert(c.eval("thats nice"));
Assertion.Assert(!c.eval(new object()));
Assertion.Assert(!c.eval(null));
c = new IsMatch(@"^th[aeiou]\w* .*$");
Assertion.Assert(c.eval("the world"));
Assertion.Assert(!c.eval("theworld"));
Assertion.Assert(!c.eval("ThE world"));
c = new IsMatch(@"^th[aeiou]\w* .*$", false);
Assertion.Assert(c.eval("the world"));
Assertion.Assert(!c.eval("theworld"));
Assertion.Assert(!c.eval("ThE world"));
c = new IsMatch(@"^th[aeiou]\w* .*$", true);
Assertion.Assert(c.eval("the world"));
Assertion.Assert(!c.eval("theworld"));
Assertion.Assert(c.eval("ThE world"));
}
[Test]
public void IsCloseTo()
{
c = new IsCloseTo(1.0, 0.5);
Assertion.Assert(c.eval(1.0));
Assertion.Assert(c.eval(0.5));
Assertion.Assert(c.eval(1.5));
Assertion.Assert(c.eval(1));
Assertion.Assert(c.eval(0.5f));
Assertion.Assert(c.eval(new decimal(1.5)));
Assertion.Assert(!c.eval(0.49));
Assertion.Assert(!c.eval(1.51));
Assertion.Assert(!c.eval(-1.0));
Assertion.Assert(c.eval("1.2"));
Assertion.Assert(!c.eval("0.2"));
Assertion.Assert(!c.eval("hello"));
Assertion.Assert(!c.eval(null));
Assertion.Assert(!c.eval(0));
Assertion.Assert(!c.eval(0.0));
}
[Test]
public void Delegate()
{
c = new Condition(new Condition.Method(myEval));
myFlag = false;
Assertion.Assert(c.eval(null));
Assertion.Assert(!c.eval(null));
Assertion.Assert(c.eval(null));
Assertion.Assert(!c.eval(null));
}
private bool myFlag;
private bool myEval(object val)
{
myFlag = !myFlag;
return myFlag;
}
class True : ICondition
{
public bool eval(object val)
{
return true;
}
}
class False : ICondition
{
public bool eval(object val)
{
return false;
}
}
}
}
Index: MockTest.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/test/NMock/MockTest.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** MockTest.cs 10 Nov 2002 16:32:27 -0000 1.1.1.1
--- MockTest.cs 10 Nov 2002 18:21:50 -0000 1.2
***************
*** 189,193 ****
[Test]
! public void DefaultEqualsPredicates()
{
object o = new object();
--- 189,193 ----
[Test]
! public void DefaultEqualsCondition()
{
object o = new object();
***************
*** 198,202 ****
[Test]
[ExpectedException(typeof(VerifyException))]
! public void DefaultEqualsPredicatesFailure()
{
mock.Expect("myMethod", new object());
--- 198,202 ----
[Test]
[ExpectedException(typeof(VerifyException))]
! public void DefaultEqualsConditionFailure()
{
mock.Expect("myMethod", new object());
***************
*** 205,209 ****
[Test]
! public void DefaultAnythingPredicates()
{
mock.Expect("myMethod", null, null);
--- 205,209 ----
[Test]
! public void DefaultAnythingCondition()
{
mock.Expect("myMethod", null, null);
--- PredicatesTest.cs DELETED ---
|
|
From: <joe...@us...> - 2002-11-10 18:21:54
|
Update of /cvsroot/nmock/nmock/src/NMock
In directory usw-pr-cvs1:/tmp/cvs-serv24420/src/NMock
Modified Files:
Mock.cs
Added Files:
Conditions.cs ICondition.cs
Removed Files:
IPredicate.cs Predicates.cs
Log Message:
Renamed Predicate to Condition
--- NEW FILE: Conditions.cs ---
using System;
using System.Text;
using System.Text.RegularExpressions;
namespace NMock
{
public class IsNull : ICondition
{
public bool eval(object val)
{
return val == null;
}
}
public class IsAnything : ICondition
{
public bool eval(object val)
{
return true;
}
}
public class IsIn : ICondition
{
private object[] inList;
public IsIn(params object[] inList)
{
if (inList.Length == 1 && inList[0].GetType().IsArray)
{
Array arr = (Array)inList[0];
this.inList = new object[arr.Length];
arr.CopyTo(this.inList, 0);
}
else
{
this.inList = inList;
}
}
public bool eval(object val)
{
foreach (object o in inList)
{
if (o.Equals(val))
{
return true;
}
}
return false;
}
}
public class IsEqual : ICondition {
private object compare;
public IsEqual(object compare)
{
this.compare = compare;
}
public bool eval(object val)
{
return compare.Equals(val);
}
}
public class IsTypeOf : ICondition
{
private Type type;
public IsTypeOf(Type type)
{
this.type = type;
}
public bool eval(object val)
{
return val == null ? false : type.IsAssignableFrom(val.GetType());
}
}
public class Not : ICondition
{
private ICondition p;
public Not(ICondition p)
{
this.p = p;
}
public bool eval(object val)
{
return !p.eval(val);
}
}
public class And : ICondition
{
private ICondition p1, p2;
public And(ICondition p1, ICondition p2)
{
this.p1 = p1;
this.p2 = p2;
}
public bool eval(object val)
{
return p1.eval(val) && p2.eval(val);
}
}
public class Or : ICondition
{
private ICondition p1, p2;
public Or(ICondition p1, ICondition p2)
{
this.p1 = p1;
this.p2 = p2;
}
public bool eval(object val)
{
return p1.eval(val) || p2.eval(val);
}
}
public class NotNull : ICondition
{
public bool eval(object val)
{
return val != null;
}
}
public class NotEqual : ICondition
{
private ICondition p;
public NotEqual(object compare)
{
p = new Not(new IsEqual(compare));
}
public bool eval(object val)
{
return p.eval(val);
}
}
public class NotIn : ICondition
{
private ICondition p;
public NotIn(params object[] inList)
{
p = new Not(new IsIn(inList));
}
public bool eval(object val)
{
return p.eval(val);
}
}
public class IsEqualIgnoreCase : ICondition
{
private ICondition p;
public IsEqualIgnoreCase(object compare)
{
p = new IsEqual(compare.ToString().ToLower());
}
public bool eval(object val)
{
return p.eval(val.ToString().ToLower());
}
}
public class IsEqualIgnoreWhiteSpace : ICondition
{
private ICondition p;
public IsEqualIgnoreWhiteSpace(object compare)
{
p = new IsEqual(StripSpace(compare.ToString()));
}
public bool eval(object val)
{
return p.eval(StripSpace(val.ToString()));
}
public static string StripSpace(string s)
{
StringBuilder result = new StringBuilder();
bool lastWasSpace = true;
foreach(char c in s)
{
if (Char.IsWhiteSpace(c))
{
if (!lastWasSpace)
{
result.Append(' ');
}
lastWasSpace = true;
}
else
{
result.Append(c);
lastWasSpace = false;
}
}
return result.ToString().Trim();
}
}
public class IsMatch : ICondition
{
private Regex regex;
public IsMatch(Regex regex)
{
this.regex = regex;
}
public IsMatch(String regex) : this(new Regex(regex))
{
}
public IsMatch(String regex, bool ignoreCase) :
this(new Regex(regex, ignoreCase ? RegexOptions.IgnoreCase : RegexOptions.None))
{
}
public bool eval(object val)
{
return val == null ? false : regex.IsMatch(val.ToString());
}
}
public class IsCloseTo : ICondition
{
private double expected;
private double error;
public IsCloseTo(double expected, double error)
{
this.expected = expected;
this.error = error;
}
public bool eval(object val)
{
try
{
double actual = Convert.ToDouble(val);
return Math.Abs(actual - expected) <= error;
}
catch (FormatException)
{
return false;
}
}
}
public class Condition : ICondition
{
public delegate bool Method(object val);
private Method m;
public Condition(Method m)
{
this.m = m;
}
public bool eval(object val)
{
return m(val);
}
}
}
--- NEW FILE: ICondition.cs ---
namespace NMock
{
public interface ICondition
{
bool eval(object val);
}
}
Index: Mock.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/Mock.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Mock.cs 10 Nov 2002 16:32:27 -0000 1.1.1.1
--- Mock.cs 10 Nov 2002 18:21:50 -0000 1.2
***************
*** 135,160 ****
Assertion.AssertEquals(this.MethodName, methodName);
! // assert that each passed in arg is validated by the appropriate predicate.
for (int i = 0; i < this.args.Length; i++)
{
object expectedArg = this.args[i];
object actualArg = args[i];
! IPredicate predicate = expectedArg as IPredicate;
! // if expectedArg is not an IPredicate, use default
// behavior of IsEqual or IsAnything
! if (predicate == null)
{
if (expectedArg == null)
{
! predicate = new IsAnything();
}
else
{
! predicate = new IsEqual(expectedArg);
}
}
! Assertion.Assert(predicate.eval(actualArg));
}
--- 135,160 ----
Assertion.AssertEquals(this.MethodName, methodName);
! // assert that each passed in arg is validated by the appropriate condition.
for (int i = 0; i < this.args.Length; i++)
{
object expectedArg = this.args[i];
object actualArg = args[i];
! ICondition condition = expectedArg as ICondition;
! // if expectedArg is not an ICondition, use default
// behavior of IsEqual or IsAnything
! if (condition == null)
{
if (expectedArg == null)
{
! condition = new IsAnything();
}
else
{
! condition = new IsEqual(expectedArg);
}
}
! Assertion.Assert(condition.eval(actualArg));
}
--- IPredicate.cs DELETED ---
--- Predicates.cs DELETED ---
|
|
From: <joe...@us...> - 2002-11-10 17:36:08
|
Update of /cvsroot/nmock/nmock In directory usw-pr-cvs1:/tmp/cvs-serv1042 Added Files: nmock.build Log Message: NAnt build file added for build/test/release. --- NEW FILE: nmock.build --- <project name="NMock" default="release"> <target name="compile" description="Compile core library"> <mkdir dir="build"/> <csc target="library" output="build/nmock.dll" debug="true"> <sources> <includes name="src/**.cs"/> <includes name="test/**.cs"/> <includes name="sample/**.cs"/> </sources> <references basedir="lib"> <includes name="*.dll"/> </references> </csc> </target> <target name="test" depends="compile" description="Run unit tests"> <exec program="lib\nunit-console.exe" commandline="/assembly:build\nmock.dll"/> </target> <target name="clean" description="Clean up built files"> <!-- the delete task fails if the dir doesn't exist, so mkdir just in case --> <mkdir dir="build"/> <mkdir dir="dist"/> <delete dir="build"/> <delete dir="dist"/> </target> <target name="release" depends="clean, test" description="Generate release"> <mkdir dir="dist"/> <!-- recompile cleaner dll, without tests and samples and no debug symbols --> <csc target="library" output="dist/nmock.dll" debug="false"> <sources> <includes name="src/**.cs"/> </sources> </csc> <echo message="*********************************"/> <echo message="* Release built: dist/nmock.dll *"/> <echo message="*********************************"/> </target> </project> |
|
From: <joe...@us...> - 2002-11-10 17:36:07
|
Update of /cvsroot/nmock/nmock/lib In directory usw-pr-cvs1:/tmp/cvs-serv1042/lib Added Files: nunit-console.exe nunit.framework.dll nunit.util.dll Log Message: NAnt build file added for build/test/release. --- NEW FILE: nunit-console.exe --- (This appears to be a binary file; contents omitted.) --- NEW FILE: nunit.framework.dll --- (This appears to be a binary file; contents omitted.) --- NEW FILE: nunit.util.dll --- (This appears to be a binary file; contents omitted.) |
|
From: <joe...@us...> - 2002-11-10 17:18:11
|
Update of /cvsroot/nmock/nmock/lib In directory usw-pr-cvs1:/tmp/cvs-serv23872/lib Log Message: Directory /cvsroot/nmock/nmock/lib added to the repository |
|
From: <joe...@us...> - 2002-11-10 16:56:21
|
Update of /cvsroot/nmock/website/decorators In directory usw-pr-cvs1:/tmp/cvs-serv11226/decorators Modified Files: main.jsp Log Message: Added page on sourcecode access. Switched h3 tags to h4 Index: main.jsp =================================================================== RCS file: /cvsroot/nmock/website/decorators/main.jsp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** main.jsp 10 Nov 2002 16:31:06 -0000 1.3 --- main.jsp 10 Nov 2002 16:56:18 -0000 1.4 *************** *** 70,73 **** --- 70,74 ---- <div><small><a href="./index.html">Overview</a></small></div> <div><small><a href="./team.html">Project Team</a></small></div> + <div><small><a href="./source.html">Source Code</a></small></div> <div><small><a href="./license.html">License</a></small></div> <div><small><a href="./download.html">Download</a></small></div> *************** *** 87,90 **** --- 88,92 ---- <div class="app"> + <h3><decorator:title default="NMock"/></h3> <decorator:body/> |
|
From: <joe...@us...> - 2002-11-10 16:56:21
|
Update of /cvsroot/nmock/website In directory usw-pr-cvs1:/tmp/cvs-serv11226 Modified Files: team.html Added Files: source.html Log Message: Added page on sourcecode access. Switched h3 tags to h4 --- NEW FILE: source.html --- <title>Source Code</title> <p>The latest source code resides in CVS.</p> <p>It is recommended to use <a href="http://www.tortoisecvs.org/">Tortoise CVS</a> to access. <h4>Anonymous Read-Only Access</h4> <table> <tr> <td><b>Server</b></td> <td>cvs.sf.net</td> </tr> <tr> <td><b>Method</b></td> <td>pserver</td> </tr> <tr> <td><b>Username</b></td> <td>anonymous</td> </tr> <tr> <td><b>Repository</b></td> <td>/cvsroot/nmock</td> </tr> <tr> <td><b>Module</b></td> <td>nmock</td> </tr> </table> <h4>Web-based Access</h4> <p>To quickly browse the source without downloading, visit the <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/nmock/nmock">CVS web-interface</a>.</p> <h4>Developer Read/Write Access</h4> <p>Please see details on <a href="http://sourceforge.net/cvs/?group_id=66591">SourceForge</a> for developer access.</p> Index: team.html =================================================================== RCS file: /cvsroot/nmock/website/team.html,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** team.html 10 Nov 2002 13:20:48 -0000 1.1.1.1 --- team.html 10 Nov 2002 16:56:18 -0000 1.2 *************** *** 1,5 **** <title>Project Team</title> ! <h3>Developers</h3> <table cellpadding="3" cellspacing="2" border="1" width="100%"> --- 1,5 ---- <title>Project Team</title> ! <h4>Developers</h4> <table cellpadding="3" cellspacing="2" border="1" width="100%"> *************** *** 26,30 **** </table> ! <h3>Contributors</h3> <table cellpadding="3" cellspacing="2" border="1" width="100%"> --- 26,30 ---- </table> ! <h4>Contributors</h4> <table cellpadding="3" cellspacing="2" border="1" width="100%"> |
|
From: <joe...@us...> - 2002-11-10 16:31:09
|
Update of /cvsroot/nmock/website/decorators In directory usw-pr-cvs1:/tmp/cvs-serv29597/decorators Modified Files: main.jsp Log Message: License added to website Index: main.jsp =================================================================== RCS file: /cvsroot/nmock/website/decorators/main.jsp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** main.jsp 10 Nov 2002 14:07:29 -0000 1.2 --- main.jsp 10 Nov 2002 16:31:06 -0000 1.3 *************** *** 70,73 **** --- 70,74 ---- <div><small><a href="./index.html">Overview</a></small></div> <div><small><a href="./team.html">Project Team</a></small></div> + <div><small><a href="./license.html">License</a></small></div> <div><small><a href="./download.html">Download</a></small></div> </div> |
|
From: <joe...@us...> - 2002-11-10 16:31:09
|
Update of /cvsroot/nmock/website In directory usw-pr-cvs1:/tmp/cvs-serv29597 Added Files: license.html Log Message: License added to website --- NEW FILE: license.html --- <title>License</title> <p>NMock is open-source and released under the BSD license.</p> <hr> <pre> Copyright (c) 2002, Joe Walnes, Chris Stevenson, Owen Rogers All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. </pre> |