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
(64) |
May
(55) |
Jun
(38) |
Jul
(23) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <joe...@us...> - 2003-02-27 22:45:54
|
Update of /cvsroot/nmock/nmock/src/NMock
In directory sc8-pr-cvs1:/tmp/cvs-serv30577/src/NMock
Modified Files:
DynamicMock.cs
Log Message:
Added support for faster error handling (thanks to Jeremy Stell Smith for the failing test, Jim Arnold for implementing it and to Paul Hammant and Martin Fowler for keeping us company)
Index: DynamicMock.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/DynamicMock.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** DynamicMock.cs 21 Jan 2003 16:44:08 -0000 1.5
--- DynamicMock.cs 27 Feb 2003 22:45:51 -0000 1.6
***************
*** 1,4 ****
--- 1,5 ----
using System;
using System.Collections;
+ using System.Reflection;
using NMock.Dynamic;
***************
*** 54,57 ****
--- 55,119 ----
obj = cg.Generate(type, this, ignore);
}
+
+ public override void Expect(string methodName, params object[] args)
+ {
+ checkMethodIsValid(methodName);
+
+ base.Expect(methodName, args);
+ }
+
+ public override void SetupResult(string methodName, object returnVal)
+ {
+ checkMethodIsValid(methodName);
+ checkReturnTypeIsValid(methodName, returnVal);
+ base.SetupResult(methodName, returnVal);
+ }
+
+ void checkReturnTypeIsValid(string methodName, object returnVal)
+ {
+ if (returnVal == null)
+ {
+ return;
+ }
+
+ MethodInfo method = type.GetMethod(methodName, ClassGenerator.ALL_INSTANCE_METHODS);
+ Type realReturnVal;
+ if(method == null)
+ {
+ realReturnVal = type.GetProperty(methodName, ClassGenerator.ALL_INSTANCE_METHODS).PropertyType;
+ }
+ else
+ {
+ realReturnVal = method.ReturnType;
+ }
+
+ if (realReturnVal == null)
+ {
+ realReturnVal = type.GetProperty(methodName, ClassGenerator.ALL_INSTANCE_METHODS).PropertyType;
+ }
+
+ if(realReturnVal != returnVal.GetType())
+ {
+ throw new ArgumentException(String.Format("method <{0}> returns a {1}", methodName, realReturnVal));
+ }
+ }
+
+ void checkMethodIsValid(string methodName)
+ {
+ MethodInfo method = type.GetMethod(methodName, ClassGenerator.ALL_INSTANCE_METHODS);
+ PropertyInfo property = type.GetProperty(methodName, ClassGenerator.ALL_INSTANCE_METHODS);
+
+ if (method == null && property == null)
+ {
+ throw new MissingMethodException(String.Format("method <{0}> not defined", methodName));
+ }
+
+
+ if(method != null)
+ {
+ if(!method.IsVirtual) throw new ArgumentException(String.Format("method <{0}> is not virtual", methodName));
+ }
+ }
+
}
}
|
|
From: Joe W. <jo...@tr...> - 2003-02-27 07:54:00
|
Good idea. I'll work these in over the weekend. And I still think this is the most awesome way to submit bugfix/feature requests. -joe Jeremy Stell-Smith wrote: >this is more just things I find really annoying. >Mostly that NMock should fail early and tell you why >it won't do what you're trying to make it do... > >__________________________________________________ >Do you Yahoo!? >Yahoo! Tax Center - forms, calculators, tips, more >http://taxes.yahoo.com/ > >------------------------------------------------------------------------ > >using System; > >using NUnit.Framework; >using NMock; > >namespace Pilot.Fit.Test >{ > /// <summary> > /// looking at the code, I think fixing this for one case (SetupResult or Expect) > /// should fix it in all places (at least that's the intent) > /// > /// I didn't use ExpectException because I wanted to specify the error message > /// </summary> > [TestFixture] > public class FastErrorHandlingTest : Assertion > { > public class Empty > { > } > > public class Full > { > public string Foo() > { > return "foo"; > } > > public virtual string Bar(string s) > { > return "bar"; > } > } > > private IMock empty; > private IMock full; > > [SetUp] > public void SetUp() > { > empty = new DynamicMock(typeof(Empty)); > full = new DynamicMock(typeof(Full)); > } > > [Test] > public void SetupResultWithNoMethod() > { > try > { > empty.Expect("Foo"); > Fail(); > } > catch (MissingMethodException e) > { > AssertEquals("method <Foo> not defined", e.Message); > } > } > > [Test] > public void SetupResultWithWrongType() > { > try > { > full.SetupResult("Foo", true); > Fail(); > } > catch (ArgumentException e) > { > AssertEquals("method <Foo> returns a System.String", e.Message); > } > } > > /// <summary> > /// this is HUGE, I keep trying to mock non-virtual methods and wasting tons of time trying to figure > /// out why my tests are working :) > /// </summary> > [Test] > public void MethodNotVirtual() > { > try > { > full.Expect("Bar"); > Fail(); > } > catch(ArgumentException e) > { > AssertEquals("method <bar> not virtual", e.Message); > } > } > } >} > > |
|
From: Jeremy Stell-S. <ste...@ya...> - 2003-02-27 02:05:01
|
this is more just things I find really annoying. Mostly that NMock should fail early and tell you why it won't do what you're trying to make it do... __________________________________________________ Do you Yahoo!? Yahoo! Tax Center - forms, calculators, tips, more http://taxes.yahoo.com/ |
|
From: <joe...@us...> - 2003-02-26 07:47:20
|
Update of /cvsroot/nmock/nmock/src/NMock/Dynamic
In directory sc8-pr-cvs1:/tmp/cvs-serv15626/src/NMock/Dynamic
Modified Files:
ClassGenerator.cs
Log Message:
Fixed bug that causes the whole runtime to crash when trying to mock value types.
Bug fix by Luke Maxon @ ThoughtWorks
Index: ClassGenerator.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/Dynamic/ClassGenerator.cs,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** ClassGenerator.cs 14 Feb 2003 20:51:00 -0000 1.7
--- ClassGenerator.cs 26 Feb 2003 07:47:17 -0000 1.8
***************
*** 139,143 ****
il.Emit(OpCodes.Ldc_I4_S, i);
il.Emit(OpCodes.Ldarg_S, i + 1);
! if (paramTypes[i].IsPrimitive)
{
il.Emit(OpCodes.Box, paramTypes[i]);
--- 139,143 ----
il.Emit(OpCodes.Ldc_I4_S, i);
il.Emit(OpCodes.Ldarg_S, i + 1);
! if (paramTypes[i].IsPrimitive || paramTypes[i].IsValueType)
{
il.Emit(OpCodes.Box, paramTypes[i]);
|
|
From: <joe...@us...> - 2003-02-26 07:47:20
|
Update of /cvsroot/nmock/nmock/test/NMock
In directory sc8-pr-cvs1:/tmp/cvs-serv15626/test/NMock
Modified Files:
DynamicMockTest.cs
Log Message:
Fixed bug that causes the whole runtime to crash when trying to mock value types.
Bug fix by Luke Maxon @ ThoughtWorks
Index: DynamicMockTest.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/test/NMock/DynamicMockTest.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** DynamicMockTest.cs 12 Dec 2002 21:39:44 -0000 1.4
--- DynamicMockTest.cs 26 Feb 2003 07:47:17 -0000 1.5
***************
*** 1,4 ****
--- 1,5 ----
using NUnit.Framework;
using System;
+ using System.Collections;
namespace NMock
***************
*** 102,105 ****
--- 103,126 ----
m2.Call("y", "something else");
m2.Verify();
+ }
+
+ [Test]
+ public void ValueType()
+ {
+ IMock mock = new DynamicMock(typeof(IValueType));
+ Assertion.AssertEquals("MockValueType", mock.Name);
+ ArrayList ret = new ArrayList();
+ DateTime date = DateTime.Now;
+ mock.ExpectAndReturn("Query", ret, "hello", date);
+
+ IValueType blah = (IValueType)mock.MockInstance;
+ Assertion.AssertEquals(ret, blah.Query("hello", date));
+
+ mock.Verify();
+ }
+
+ interface IValueType
+ {
+ ArrayList Query(string symbol, DateTime arg2);
}
|
|
From: <sm...@us...> - 2003-02-19 12:20:46
|
Update of /cvsroot/nmock/nmock/test In directory sc8-pr-cvs1:/tmp/cvs-serv32524/test Removed Files: test.csproj.user Log Message: deleted non-repository file --- test.csproj.user DELETED --- |
|
From: <sm...@us...> - 2003-02-19 12:20:46
|
Update of /cvsroot/nmock/nmock/src In directory sc8-pr-cvs1:/tmp/cvs-serv32524/src Removed Files: src.csproj.user Log Message: deleted non-repository file --- src.csproj.user DELETED --- |
|
From: Joe W. <jo...@tr...> - 2003-02-14 22:09:48
|
Jeremy Stell-Smith wrote: >write a test for a project that exposes the bug, and >have someone fix it w/in a couple hours...way cool :) > > What was really cool was how I had no idea what I was doing..... I used your test, thought about it for a bit, and thought 'what if I do this....' and it just passed first time! :) Why don't all oss projects work like this? -joe |
|
From: Jeremy Stell-S. <ste...@ya...> - 2003-02-14 21:26:52
|
write a test for a project that exposes the bug, and have someone fix it w/in a couple hours...way cool :) __________________________________________________ Do you Yahoo!? Yahoo! Shopping - Send Flowers for Valentine's Day http://shopping.yahoo.com |
|
From: <joe...@us...> - 2003-02-14 20:56:36
|
Update of /cvsroot/nmock/nmock/test/NMock/Dynamic
In directory sc8-pr-cvs1:/tmp/cvs-serv21429/test/NMock/Dynamic
Modified Files:
ClassGeneratorTest.cs
Log Message:
DynamicMock can now return enums. Failing test supplied by Jeremey Stell-Smith.
Index: ClassGeneratorTest.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/test/NMock/Dynamic/ClassGeneratorTest.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** ClassGeneratorTest.cs 3 Jan 2003 16:00:46 -0000 1.5
--- ClassGeneratorTest.cs 14 Feb 2003 20:56:32 -0000 1.6
***************
*** 24,27 ****
--- 24,28 ----
double doubleReturn();
IThingy AThingy();
+ MyEnum getEnum();
string ReadProperty { get; }
string WriteProperty { set; }
***************
*** 56,59 ****
--- 57,66 ----
get { return "xx"; }
}
+
+ }
+
+ public enum MyEnum
+ {
+ A, B, C, D
}
***************
*** 81,85 ****
mock.Verify();
}
!
[Test]
public void CallMethodWithReturn()
--- 88,92 ----
mock.Verify();
}
!
[Test]
public void CallMethodWithReturn()
***************
*** 131,134 ****
--- 138,150 ----
}
+ [Test]
+ public void CallMethodWithReturnEnum()
+ {
+ mock.ExpectAndReturn("getEnum", MyEnum.C);
+ MyEnum result = thingy.getEnum();
+ Assertion.AssertEquals(MyEnum.C, result);
+ mock.Verify();
+ }
+
[Test]
[ExpectedException(typeof(System.IO.IOException))]
|
|
From: Joe W. <jo...@tr...> - 2003-02-14 20:53:13
|
Cheers - fixed!
-joe
Jeremy Stell-Smith wrote:
>I hit what I'm mostly sure is a bug. Basically, when
>you setup a return value of an enum, it doesn't work.
>Here's a failing test for y'all to fix.
>
>Jeremy
>
>
>using System;
>
>using NMock;
>using NUnit.Framework;
>
>namespace Foo
>{
> [TestFixture]
> public class FooTest : Assertion
> {
> private enum MyEnum { A, B, C, D }
>
> private interface MyInterface
> {
> MyEnum DoSomething();
> }
>
> [Test]
> public void TestReturnEnum()
> {
> DynamicMock mock = new
>DynamicMock(typeof(MyInterface));
> mock.ExpectAndReturn("DoSomething", MyEnum.A);
>
> MyInterface instance = (MyInterface)
>mock.MockInstance;
> AssertEquals(MyEnum.A, instance.DoSomething());
> }
> }
>}
>
>
>__________________________________________________
>Do you Yahoo!?
>Yahoo! Shopping - Send Flowers for Valentine's Day
>http://shopping.yahoo.com
>
>
>-------------------------------------------------------
>This SF.NET email is sponsored by: FREE SSL Guide from Thawte
>are you planning your Web Server Security? Click here to get a FREE
>Thawte SSL guide and find the answers to all your SSL security issues.
>http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en
>_______________________________________________
>Nmock-general mailing list
>Nmo...@li...
>https://lists.sourceforge.net/lists/listinfo/nmock-general
>
>
|
|
From: <joe...@us...> - 2003-02-14 20:51:04
|
Update of /cvsroot/nmock/nmock/src/NMock/Dynamic
In directory sc8-pr-cvs1:/tmp/cvs-serv18960a/src/NMock/Dynamic
Modified Files:
ClassGenerator.cs
Log Message:
DynamicMock can now return enums. Failing test supplied by Jeremey Stell-Smith.
Index: ClassGenerator.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/Dynamic/ClassGenerator.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** ClassGenerator.cs 3 Jan 2003 16:00:47 -0000 1.6
--- ClassGenerator.cs 14 Feb 2003 20:51:00 -0000 1.7
***************
*** 163,167 ****
else
{
! if (returnType.IsPrimitive)
{
il.Emit(OpCodes.Unbox, returnType);
--- 163,167 ----
else
{
! if (returnType.IsPrimitive || returnType.IsEnum)
{
il.Emit(OpCodes.Unbox, returnType);
|
|
From: Jeremy Stell-S. <ste...@ya...> - 2003-02-14 18:43:40
|
I hit what I'm mostly sure is a bug. Basically, when
you setup a return value of an enum, it doesn't work.
Here's a failing test for y'all to fix.
Jeremy
using System;
using NMock;
using NUnit.Framework;
namespace Foo
{
[TestFixture]
public class FooTest : Assertion
{
private enum MyEnum { A, B, C, D }
private interface MyInterface
{
MyEnum DoSomething();
}
[Test]
public void TestReturnEnum()
{
DynamicMock mock = new
DynamicMock(typeof(MyInterface));
mock.ExpectAndReturn("DoSomething", MyEnum.A);
MyInterface instance = (MyInterface)
mock.MockInstance;
AssertEquals(MyEnum.A, instance.DoSomething());
}
}
}
__________________________________________________
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com
|
|
From: <sm...@us...> - 2003-02-10 13:26:21
|
Update of /cvsroot/nmock/nmock/src/NMock/Constraints
In directory sc8-pr-cvs1:/tmp/cvs-serv32401/src/NMock/Constraints
Modified Files:
Constraints.cs
Log Message:
Added
public object ExtractActualValue(object actual)
to IConstraint interface
Index: Constraints.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/Constraints/Constraints.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Constraints.cs 21 Jan 2003 18:16:13 -0000 1.5
--- Constraints.cs 10 Feb 2003 13:26:17 -0000 1.6
***************
*** 7,18 ****
{
! public class IsNull : IConstraint
{
! public bool Eval(object val)
{
! return val == null;
}
! public string Message
{
get { return "null"; }
--- 7,29 ----
{
! public abstract class BaseConstraint : IConstraint
! {
! public virtual object ExtractActualValue(object actual)
! {
! return actual;
! }
!
! public abstract bool Eval(object val);
! public abstract string Message { get; }
! }
!
! public class IsNull : BaseConstraint
{
! public override bool Eval(object val)
{
! return ExtractActualValue(val) == null;
}
! public override string Message
{
get { return "null"; }
***************
*** 20,31 ****
}
! public class IsAnything : IConstraint
{
! public bool Eval(object val)
{
return true;
}
! public string Message
{
get { return ""; }
--- 31,42 ----
}
! public class IsAnything : BaseConstraint
{
! public override bool Eval(object val)
{
return true;
}
! public override string Message
{
get { return ""; }
***************
*** 33,37 ****
}
! public class IsIn : IConstraint
{
private object[] inList;
--- 44,48 ----
}
! public class IsIn : BaseConstraint
{
private object[] inList;
***************
*** 51,59 ****
}
! public bool Eval(object val)
{
foreach (object o in inList)
{
! if (o.Equals(val))
{
return true;
--- 62,70 ----
}
! public override bool Eval(object val)
{
foreach (object o in inList)
{
! if (o.Equals(ExtractActualValue(val)))
{
return true;
***************
*** 63,67 ****
}
! public string Message
{
get
--- 74,78 ----
}
! public override string Message
{
get
***************
*** 84,88 ****
}
! public class IsEqual : IConstraint {
private object compare;
--- 95,99 ----
}
! public class IsEqual : BaseConstraint {
private object compare;
***************
*** 92,101 ****
}
! public bool Eval(object val)
{
! return compare.Equals(val);
}
! public string Message
{
get { return "<" + compare + ">"; }
--- 103,112 ----
}
! public override bool Eval(object val)
{
! return compare.Equals(ExtractActualValue(val));
}
! public override string Message
{
get { return "<" + compare + ">"; }
***************
*** 103,107 ****
}
! public class IsTypeOf : IConstraint
{
private Type type;
--- 114,118 ----
}
! public class IsTypeOf : BaseConstraint
{
private Type type;
***************
*** 112,121 ****
}
! public bool Eval(object val)
{
! return val == null ? false : type.IsAssignableFrom(val.GetType());
}
! public string Message
{
get { return "typeof <" + type.FullName + ">"; }
--- 123,133 ----
}
! public override bool Eval(object val)
{
! object actualValue = ExtractActualValue(val);
! return actualValue == null ? false : type.IsAssignableFrom(actualValue.GetType());
}
! public override string Message
{
get { return "typeof <" + type.FullName + ">"; }
***************
*** 123,127 ****
}
! public class Not : IConstraint
{
private IConstraint p;
--- 135,139 ----
}
! public class Not : BaseConstraint
{
private IConstraint p;
***************
*** 132,141 ****
}
! public bool Eval(object val)
{
! return !p.Eval(val);
}
! public string Message
{
get { return "NOT " + p.Message; }
--- 144,153 ----
}
! public override bool Eval(object val)
{
! return !p.Eval(ExtractActualValue(val));
}
! public override string Message
{
get { return "NOT " + p.Message; }
***************
*** 143,147 ****
}
! public class And : IConstraint
{
private IConstraint p1, p2;
--- 155,159 ----
}
! public class And : BaseConstraint
{
private IConstraint p1, p2;
***************
*** 153,162 ****
}
! public bool Eval(object val)
{
! return p1.Eval(val) && p2.Eval(val);
}
! public string Message
{
get { return p1.Message + " AND " + p2.Message; }
--- 165,175 ----
}
! public override bool Eval(object val)
{
! object actualValue = ExtractActualValue(val);
! return p1.Eval(actualValue) && p2.Eval(actualValue);
}
! public override string Message
{
get { return p1.Message + " AND " + p2.Message; }
***************
*** 164,168 ****
}
! public class Or : IConstraint
{
private IConstraint p1, p2;
--- 177,181 ----
}
! public class Or : BaseConstraint
{
private IConstraint p1, p2;
***************
*** 174,183 ****
}
! public bool Eval(object val)
{
! return p1.Eval(val) || p2.Eval(val);
}
! public string Message
{
get { return p1.Message + " OR " + p2.Message; }
--- 187,197 ----
}
! public override bool Eval(object val)
{
! object actualValue = ExtractActualValue(val);
! return p1.Eval(actualValue) || p2.Eval(actualValue);
}
! public override string Message
{
get { return p1.Message + " OR " + p2.Message; }
***************
*** 185,196 ****
}
! public class NotNull : IConstraint
{
! public bool Eval(object val)
{
! return val != null;
}
! public string Message
{
get { return "NOT null"; }
--- 199,210 ----
}
! public class NotNull : BaseConstraint
{
! public override bool Eval(object val)
{
! return ExtractActualValue(val) != null;
}
! public override string Message
{
get { return "NOT null"; }
***************
*** 198,202 ****
}
! public class NotEqual : IConstraint
{
private IConstraint p;
--- 212,216 ----
}
! public class NotEqual : BaseConstraint
{
private IConstraint p;
***************
*** 207,216 ****
}
! public bool Eval(object val)
{
! return p.Eval(val);
}
! public string Message
{
get { return p.Message; }
--- 221,230 ----
}
! public override bool Eval(object val)
{
! return p.Eval(ExtractActualValue(val));
}
! public override string Message
{
get { return p.Message; }
***************
*** 218,222 ****
}
! public class NotIn : IConstraint
{
private IConstraint p;
--- 232,236 ----
}
! public class NotIn : BaseConstraint
{
private IConstraint p;
***************
*** 227,236 ****
}
! public bool Eval(object val)
{
! return p.Eval(val);
}
! public string Message
{
get { return p.Message; }
--- 241,250 ----
}
! public override bool Eval(object val)
{
! return p.Eval(ExtractActualValue(val));
}
! public override string Message
{
get { return p.Message; }
***************
*** 238,242 ****
}
! public class IsEqualIgnoreCase : IConstraint
{
private IConstraint p;
--- 252,256 ----
}
! public class IsEqualIgnoreCase : BaseConstraint
{
private IConstraint p;
***************
*** 247,256 ****
}
! public bool Eval(object val)
{
! return p.Eval(val.ToString().ToLower());
}
! public string Message
{
get { return p.Message; }
--- 261,270 ----
}
! public override bool Eval(object val)
{
! return p.Eval(ExtractActualValue(val).ToString().ToLower());
}
! public override string Message
{
get { return p.Message; }
***************
*** 258,262 ****
}
! public class IsEqualIgnoreWhiteSpace : IConstraint
{
private IConstraint p;
--- 272,276 ----
}
! public class IsEqualIgnoreWhiteSpace : BaseConstraint
{
private IConstraint p;
***************
*** 267,273 ****
}
! public bool Eval(object val)
{
! return p.Eval(StripSpace(val.ToString()));
}
--- 281,287 ----
}
! public override bool Eval(object val)
{
! return p.Eval(StripSpace(ExtractActualValue(val).ToString()));
}
***************
*** 295,299 ****
}
! public string Message
{
get { return p.Message; }
--- 309,313 ----
}
! public override string Message
{
get { return p.Message; }
***************
*** 301,305 ****
}
! public class IsMatch : IConstraint
{
private Regex regex;
--- 315,319 ----
}
! public class IsMatch : BaseConstraint
{
private Regex regex;
***************
*** 319,328 ****
}
! public bool Eval(object val)
{
! return val == null ? false : regex.IsMatch(val.ToString());
}
! public string Message
{
get { return "<" + regex.ToString() + ">"; }
--- 333,343 ----
}
! public override bool Eval(object val)
{
! object actualValue = ExtractActualValue(val);
! return actualValue == null ? false : regex.IsMatch(actualValue.ToString());
}
! public override string Message
{
get { return "<" + regex.ToString() + ">"; }
***************
*** 330,334 ****
}
! public class IsCloseTo : IConstraint
{
--- 345,349 ----
}
! public class IsCloseTo : BaseConstraint
{
***************
*** 342,350 ****
}
! public bool Eval(object val)
{
try
{
! double actual = Convert.ToDouble(val);
return Math.Abs(actual - expected) <= error;
}
--- 357,365 ----
}
! public override bool Eval(object val)
{
try
{
! double actual = Convert.ToDouble(ExtractActualValue(val));
return Math.Abs(actual - expected) <= error;
}
***************
*** 355,359 ****
}
! public string Message
{
get { return "<" + expected + ">"; }
--- 370,374 ----
}
! public override string Message
{
get { return "<" + expected + ">"; }
***************
*** 368,372 ****
/// "Property.SubProperty" notation.
/// </summary>
! public class PropertyIs : IConstraint
{
private string property;
--- 383,387 ----
/// "Property.SubProperty" notation.
/// </summary>
! public class PropertyIs : BaseConstraint
{
private string property;
***************
*** 383,394 ****
}
! public bool Eval(object val)
{
! if (val == null)
{
return false;
}
// split "a.b.c" into "a", "b", "c"
! object propertyValue = val;
foreach(string propertyBit in property.Split(new char[] {'.'}))
{
--- 398,410 ----
}
! public override bool Eval(object val)
{
! object actualValue = ExtractActualValue(val);
! if (actualValue == null)
{
return false;
}
// split "a.b.c" into "a", "b", "c"
! object propertyValue = actualValue;
foreach(string propertyBit in property.Split(new char[] {'.'}))
{
***************
*** 405,409 ****
}
! public string Message
{
get { return String.Format("Property {0}: {1}", property, constraint.Message); }
--- 421,425 ----
}
! public override string Message
{
get { return String.Format("Property {0}: {1}", property, constraint.Message); }
***************
*** 411,415 ****
}
! public class Constraint : IConstraint
{
public delegate bool Method(object val);
--- 427,431 ----
}
! public class Constraint : BaseConstraint
{
public delegate bool Method(object val);
***************
*** 421,430 ****
}
! public bool Eval(object val)
{
! return m(val);
}
! public string Message
{
get { return "Custom Constraint"; }
--- 437,446 ----
}
! public override bool Eval(object val)
{
! return m(ExtractActualValue(val));
}
! public override string Message
{
get { return "Custom Constraint"; }
***************
*** 433,437 ****
! public class CollectingConstraint : IConstraint
{
private object parameter;
--- 449,453 ----
! public class CollectingConstraint : BaseConstraint
{
private object parameter;
***************
*** 442,452 ****
}
! public bool Eval(object val)
{
! parameter = val;
return true;
}
! public string Message
{
get { return "Collecting Constraint"; }
--- 458,468 ----
}
! public override bool Eval(object val)
{
! parameter = ExtractActualValue(val);
return true;
}
! public override string Message
{
get { return "Collecting Constraint"; }
|
|
From: <sm...@us...> - 2003-02-10 13:26:20
|
Update of /cvsroot/nmock/nmock/test/NMock/Constraints
In directory sc8-pr-cvs1:/tmp/cvs-serv32401/test/NMock/Constraints
Modified Files:
ConstraintsTest.cs
Log Message:
Added
public object ExtractActualValue(object actual)
to IConstraint interface
Index: ConstraintsTest.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/test/NMock/Constraints/ConstraintsTest.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ConstraintsTest.cs 21 Jan 2003 18:16:13 -0000 1.4
--- ConstraintsTest.cs 10 Feb 2003 13:26:17 -0000 1.5
***************
*** 234,237 ****
--- 234,238 ----
}
+ #region Property Tests
[Test]
public void PropertyIs()
***************
*** 274,278 ****
}
}
!
[Test]
public void CollectingConstraint()
--- 275,280 ----
}
}
! #endregion
!
[Test]
public void CollectingConstraint()
***************
*** 337,340 ****
--- 339,347 ----
get { return null; }
}
+
+ public object ExtractActualValue(object actual)
+ {
+ return actual;
+ }
}
***************
*** 350,353 ****
--- 357,365 ----
get { return null; }
}
+
+ public object ExtractActualValue(object actual)
+ {
+ return actual;
+ }
}
***************
*** 363,369 ****
get { return "DUMMY"; }
}
!
}
}
--- 375,407 ----
get { return "DUMMY"; }
}
!
! public object ExtractActualValue(object actual)
! {
! return actual;
! }
}
+ #region ExtractActualValue test
+ class ExtractingConstraint : IsEqual
+ {
+ public ExtractingConstraint(object expected) : base(expected) {}
+
+
+ public override object ExtractActualValue(object actual)
+ {
+ return ((string)actual)[0].ToString();
+ }
+ }
+
+ [Test]
+ public void ExtractingActualValue()
+ {
+ ExtractingConstraint constraint = new ExtractingConstraint("E");
+
+ Assertion.AssertEquals("Should be modified value", "A", constraint.ExtractActualValue("ACTUAL"));
+ Assertion.Assert("Should match", constraint.Eval("EQUALS FIRST CHAR"));
+ Assertion.Assert("Should be different", new Not(constraint).Eval("NOT EQUAL"));
+ }
+ #endregion
}
|
|
From: <sm...@us...> - 2003-02-10 13:25:00
|
Update of /cvsroot/nmock/nmock/src/NMock/Constraints
In directory sc8-pr-cvs1:/tmp/cvs-serv31631/src/NMock/Constraints
Modified Files:
IConstraint.cs
Log Message:
*** keyword substitution change ***
Index: IConstraint.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/Constraints/IConstraint.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** IConstraint.cs 15 Nov 2002 22:48:20 -0000 1.1
--- IConstraint.cs 10 Feb 2003 13:24:57 -0000 1.2
***************
*** 1,12 ****
! namespace NMock.Constraints
! {
!
! public interface IConstraint
! {
!
! bool Eval(object val);
! string Message { get; }
!
! }
!
! }
--- 1,10 ----
! namespace NMock.Constraints
! {
! public interface IConstraint
! {
! bool Eval(object val);
! object ExtractActualValue(object actual);
! string Message { get; }
! }
!
! }
|
|
From: <sm...@us...> - 2003-02-10 12:29:55
|
Update of /cvsroot/nmock/nmock In directory sc8-pr-cvs1:/tmp/cvs-serv8894 Removed Files: nmock.suo Log Message: VisualStudio artifact. Doesn't need to be checked in --- nmock.suo DELETED --- |
|
From: Joe W. <jo...@tr...> - 2003-02-09 09:39:10
|
Looks good - go for it!
Steve Freeman wrote:
> How about ExtractActualValue() ?
>
> S.
>
> Joe Walnes wrote:
>
>> Ok, I get it. Looks good. Can we think of a less confusing name than
>> TestValue?
>>
>> -j
>>
>> Steve Freeman wrote:
>>
>>> Joe Walnes wrote:
>>>
>>>> st...@m3... wrote:
>>>> I'm not getting the TestValue option. Could you provide an example...
>>>
>>>
>>>
>>>
>>>
>>> public void Verify(IConstraint constraint, Object actual)
>>> {
>>> Assert("Constraint, expected: " + constraint.Message
>>> + " actual: " + constraint.TestValue(actual),
>>> constraint.Eval(actual));
>>> }
>>>
>>> public class Equals implements IConstraint {
>>> public bool Eval(object actual) {
>>> return expected.Equals(TestValue(actual));
>>> }
>>> public virutal object TestValue(object actual) {
>>> // default implementation
>>> return actual;
>>> }
>>> // ...
>>> }
>>
>
>
>
>
> -------------------------------------------------------
> This SF.NET email is sponsored by:
> SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
> http://www.vasoftware.com
> _______________________________________________
> Nmock-general mailing list
> Nmo...@li...
> https://lists.sourceforge.net/lists/listinfo/nmock-general
|
|
From: Steve F. <st...@m3...> - 2003-02-08 22:39:52
|
How about ExtractActualValue() ?
S.
Joe Walnes wrote:
> Ok, I get it. Looks good. Can we think of a less confusing name than
> TestValue?
>
> -j
>
> Steve Freeman wrote:
>
>> Joe Walnes wrote:
>>
>>> st...@m3... wrote:
>>> I'm not getting the TestValue option. Could you provide an example...
>>
>>
>>
>>
>> public void Verify(IConstraint constraint, Object actual)
>> {
>> Assert("Constraint, expected: " + constraint.Message
>> + " actual: " + constraint.TestValue(actual),
>> constraint.Eval(actual));
>> }
>>
>> public class Equals implements IConstraint {
>> public bool Eval(object actual) {
>> return expected.Equals(TestValue(actual));
>> }
>> public virutal object TestValue(object actual) {
>> // default implementation
>> return actual;
>> }
>> // ...
>> }
|
|
From: Joe W. <jo...@tr...> - 2003-02-08 10:07:22
|
Ok, I get it. Looks good. Can we think of a less confusing name than
TestValue?
-j
Steve Freeman wrote:
> Joe Walnes wrote:
>
>> st...@m3... wrote:
>> I'm not getting the TestValue option. Could you provide an example...
>
>
>
> public void Verify(IConstraint constraint, Object actual)
> {
> Assert("Constraint, expected: " + constraint.Message
> + " actual: " + constraint.TestValue(actual),
> constraint.Eval(actual));
> }
>
> public class Equals implements IConstraint {
> public bool Eval(object actual) {
> return expected.Equals(TestValue(actual));
> }
> public virutal object TestValue(object actual) {
> // default implementation
> return actual;
> }
> // ...
> }
>
> [Come to http://www.ot2003.org]
>
>
>
>
> -------------------------------------------------------
> This SF.NET email is sponsored by:
> SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
> http://www.vasoftware.com
> _______________________________________________
> Nmock-general mailing list
> Nmo...@li...
> https://lists.sourceforge.net/lists/listinfo/nmock-general
|
|
From: Steve F. <st...@m3...> - 2003-02-08 01:11:27
|
Joe Walnes wrote:
> st...@m3... wrote:
> I'm not getting the TestValue option. Could you provide an example...
public void Verify(IConstraint constraint, Object actual)
{
Assert("Constraint, expected: " + constraint.Message
+ " actual: " + constraint.TestValue(actual),
constraint.Eval(actual));
}
public class Equals implements IConstraint {
public bool Eval(object actual) {
return expected.Equals(TestValue(actual));
}
public virutal object TestValue(object actual) {
// default implementation
return actual;
}
// ...
}
[Come to http://www.ot2003.org]
|
|
From: Joe W. <jo...@tr...> - 2003-02-07 15:42:02
|
st...@m3... wrote:
>>How about changing the interface of IConstraint (is this the kind of
>>thing you meant with the TestValue approach?).
>>To:
>>
>> interface IConstraint {
>> bool Eval(object actual);
>> string Message(object actual);
>> }
>>
>>The LastValue suggestion doesn't quite feel right. Could make
>>IConstraints harder to implement (they're very clean at the moment) and
>>could get confusing if reusing constraints.
>>
>>
>
>I hadn't thought of that, but it does mean that the constraint gets to write the message, whereas that's really the job of the assertion (c.f. all the trouble with the new JUnit string compressor). I'd be more inclined to go with the TestValue() option, not least of which because the Eval code can be refactored to use it as well (once and only once) -- I think we might get some reuse out of that.
>
>
I'm not getting the TestValue option. Could you provide an example...
-Joe
|
|
From: <st...@m3...> - 2003-02-07 13:42:55
|
> How about changing the interface of IConstraint (is this the kind of=20
> thing you meant with the TestValue approach?).
> To:
>=20
> interface IConstraint {
> bool Eval(object actual);
> string Message(object actual);
> }
>=20
> The LastValue suggestion doesn't quite feel right. Could make=20
> IConstraints harder to implement (they're very clean at the moment) and=
=20
> could get confusing if reusing constraints.
I hadn't thought of that, but it does mean that the constraint gets to writ=
e the message, whereas that's really the job of the assertion (c.f. all the=
trouble with the new JUnit string compressor). I'd be more inclined to go =
with the TestValue() option, not least of which because the Eval code can b=
e refactored to use it as well (once and only once) -- I think we might get=
some reuse out of that.
S.
|
|
From: Joe W. <jo...@tr...> - 2003-02-07 12:03:57
|
I have a need for this too.
How about changing the interface of IConstraint (is this the kind of
thing you meant with the TestValue approach?).
From:
interface IConstraint {
bool Eval(object actual);
string Message { get; };
}
To:
interface IConstraint {
bool Eval(object actual);
string Message(object actual);
}
The LastValue suggestion doesn't quite feel right. Could make
IConstraints harder to implement (they're very clean at the moment) and
could get confusing if reusing constraints.
So when are we gonna see the IExplorer/DOM stuff then? I'm intrigued.... :)
-joe
Steve Freeman wrote:
> We've been using the NMock constraints and have come across a little
> problem. We're using it for testing the contents of DOM elements by
> driving IExplorer through its API. We've written some extra
> constraints that match parts of an element, which works fine, but we
> means we have a hard time printing meaningful error messages because
> it's only the constraint that extracts the final value to check, we
> can't tell from the containing assertion. For example:
>
> IConstraint constraint = new IElementTextEquals("some text");
>
> Assert("Expected " + constraint.Message + " got " + ielement,
> constraint.Eval(ielement));
>
> will only show the class of ielement when it fails. We can't find its
> text contents.
>
> The object that /does/ know the actual value is the constraint, so
> that seems like the right object to ask. I can see two ways of doing
> this:
>
> - add a method, say,
> object TestValue(object actual)
> that unpacks the value you want to test against, in this case the
> element text,
> by default the 'actual' object.
>
> - hang on to the the last test value during the Eval and make it
> available via a LastValue property.
>
> Thoughts?
>
> S.
>
|
|
From: Steve F. <st...@m3...> - 2003-02-07 01:11:49
|
We've been using the NMock constraints and have come across a little
problem. We're using it for testing the contents of DOM elements by
driving IExplorer through its API. We've written some extra constraints
that match parts of an element, which works fine, but we means we have a
hard time printing meaningful error messages because it's only the
constraint that extracts the final value to check, we can't tell from
the containing assertion. For example:
IConstraint constraint = new IElementTextEquals("some text");
Assert("Expected " + constraint.Message + " got " + ielement,
constraint.Eval(ielement));
will only show the class of ielement when it fails. We can't find its
text contents.
The object that /does/ know the actual value is the constraint, so that
seems like the right object to ask. I can see two ways of doing this:
- add a method, say,
object TestValue(object actual)
that unpacks the value you want to test against, in this case the
element text,
by default the 'actual' object.
- hang on to the the last test value during the Eval and make it
available via a LastValue property.
Thoughts?
S.
|