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
(21) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
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.
|
|
From: <joe...@us...> - 2003-01-21 18:16:16
|
Update of /cvsroot/nmock/nmock/test/NMock/Constraints
In directory sc8-pr-cvs1:/tmp/cvs-serv16434/test/NMock/Constraints
Modified Files:
ConstraintsTest.cs
Log Message:
PropertyIs can now support properties of properties.... eg "Name.FirstName.Length"
Index: ConstraintsTest.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/test/NMock/Constraints/ConstraintsTest.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ConstraintsTest.cs 21 Jan 2003 17:36:00 -0000 1.3
--- ConstraintsTest.cs 21 Jan 2003 18:16:13 -0000 1.4
***************
*** 258,261 ****
--- 258,270 ----
}
+ [Test]
+ public void PropertyIsWithNestedProperties()
+ {
+ ThingWithProps t = new ThingWithProps();
+
+ Assertion.Assert(new PropertyIs("MyProp.Length", 5).Eval(t));
+ Assertion.Assert(!new PropertyIs("MyProp.Length", 9).Eval(t));
+ }
+
class ThingWithProps
{
|
|
From: <joe...@us...> - 2003-01-21 18:16:15
|
Update of /cvsroot/nmock/nmock/src/NMock/Constraints
In directory sc8-pr-cvs1:/tmp/cvs-serv16434/src/NMock/Constraints
Modified Files:
Constraints.cs
Log Message:
PropertyIs can now support properties of properties.... eg "Name.FirstName.Length"
Index: Constraints.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/Constraints/Constraints.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Constraints.cs 21 Jan 2003 17:36:00 -0000 1.4
--- Constraints.cs 21 Jan 2003 18:16:13 -0000 1.5
***************
*** 364,367 ****
--- 364,370 ----
/// This constraint decorates another constraint, allowing it to test
/// a property of the object, rather than the property itself.
+ ///
+ /// Properties of properties can be specified by using the
+ /// "Property.SubProperty" notation.
/// </summary>
public class PropertyIs : IConstraint
***************
*** 386,393 ****
return false;
}
Type type = val.GetType();
PropertyInfo propertyInfo = type.GetProperty(property);
! object propertyValue = propertyInfo.GetValue(val, null);
! return constraint.Eval(propertyValue);
}
--- 389,406 ----
return false;
}
+ // split "a.b.c" into "a", "b", "c"
+ object propertyValue = val;
+ foreach(string propertyBit in property.Split(new char[] {'.'}))
+ {
+ propertyValue = getProperty(propertyValue, propertyBit);
+ }
+ return constraint.Eval(propertyValue);
+ }
+
+ private object getProperty(object val, string property)
+ {
Type type = val.GetType();
PropertyInfo propertyInfo = type.GetProperty(property);
! return propertyInfo.GetValue(val, null);
}
|
|
From: <joe...@us...> - 2003-01-21 17:36:04
|
Update of /cvsroot/nmock/nmock/src/NMock/Constraints
In directory sc8-pr-cvs1:/tmp/cvs-serv30252/src/NMock/Constraints
Modified Files:
Constraints.cs
Log Message:
Added PropertyIs decorator for constraints to allow a constraint to test the value of a property rather than the object itself.
Index: Constraints.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/Constraints/Constraints.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Constraints.cs 31 Dec 2002 21:36:37 -0000 1.3
--- Constraints.cs 21 Jan 2003 17:36:00 -0000 1.4
***************
*** 2,5 ****
--- 2,6 ----
using System.Text;
using System.Text.RegularExpressions;
+ using System.Reflection;
namespace NMock.Constraints
***************
*** 357,360 ****
--- 358,398 ----
{
get { return "<" + expected + ">"; }
+ }
+ }
+
+ /// <summary>
+ /// This constraint decorates another constraint, allowing it to test
+ /// a property of the object, rather than the property itself.
+ /// </summary>
+ public class PropertyIs : IConstraint
+ {
+ private string property;
+ private IConstraint constraint;
+
+ public PropertyIs(string property, object expected)
+ {
+ this.property = property;
+ constraint = expected as IConstraint;
+ if (constraint == null)
+ {
+ constraint = new IsEqual(expected);
+ }
+ }
+
+ public bool Eval(object val)
+ {
+ if (val == null)
+ {
+ return false;
+ }
+ Type type = val.GetType();
+ PropertyInfo propertyInfo = type.GetProperty(property);
+ object propertyValue = propertyInfo.GetValue(val, null);
+ return constraint.Eval(propertyValue);
+ }
+
+ public string Message
+ {
+ get { return String.Format("Property {0}: {1}", property, constraint.Message); }
}
}
|
|
From: <joe...@us...> - 2003-01-21 17:36:04
|
Update of /cvsroot/nmock/nmock/test/NMock/Constraints
In directory sc8-pr-cvs1:/tmp/cvs-serv30252/test/NMock/Constraints
Modified Files:
ConstraintsTest.cs
Log Message:
Added PropertyIs decorator for constraints to allow a constraint to test the value of a property rather than the object itself.
Index: ConstraintsTest.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/test/NMock/Constraints/ConstraintsTest.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ConstraintsTest.cs 31 Dec 2002 21:36:40 -0000 1.2
--- ConstraintsTest.cs 21 Jan 2003 17:36:00 -0000 1.3
***************
*** 235,238 ****
--- 235,270 ----
[Test]
+ public void PropertyIs()
+ {
+ ThingWithProps t = new ThingWithProps();
+
+ // test property equals a value
+ Assertion.Assert(new PropertyIs("MyProp", "hello").Eval(t));
+ Assertion.Assert(!new PropertyIs("MyProp", "bye").Eval(t));
+
+ // test property using another constraint
+ Assertion.Assert(new PropertyIs("MyProp", new IsMatch("ell")).Eval(t));
+ Assertion.Assert(!new PropertyIs("MyProp", new IsMatch("sfsl")).Eval(t));
+
+ Assertion.AssertEquals(
+ "Property MyProp: <x>",
+ new PropertyIs("MyProp", new IsEqual("x")).Message);
+ }
+
+ [Test]
+ public void PropertyIsWithNullValue()
+ {
+ Assertion.Assert(!new PropertyIs("Blah", new IsAnything()).Eval(null));
+ }
+
+ class ThingWithProps
+ {
+ public string MyProp
+ {
+ get { return "hello"; }
+ }
+ }
+
+ [Test]
public void CollectingConstraint()
{
|
|
From: <joe...@us...> - 2003-01-21 16:44:15
|
Update of /cvsroot/nmock/nmock/src/NMock
In directory sc8-pr-cvs1:/tmp/cvs-serv2740/src/NMock
Modified Files:
DynamicMock.cs
Log Message:
Dull formatting change
Index: DynamicMock.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/DynamicMock.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** DynamicMock.cs 3 Jan 2003 15:59:57 -0000 1.4
--- DynamicMock.cs 21 Jan 2003 16:44:08 -0000 1.5
***************
*** 14,20 ****
public DynamicMock(Type type) : this(type, null)
{
! ignore = new ArrayList();
Name = "Mock" + StripLeadingIifInterface(type);
! }
public DynamicMock(Type type, string name) : base(name)
--- 14,20 ----
public DynamicMock(Type type) : this(type, null)
{
! ignore = new ArrayList();
Name = "Mock" + StripLeadingIifInterface(type);
! }
public DynamicMock(Type type, string name) : base(name)
***************
*** 43,52 ****
}
! private string StripLeadingIifInterface(Type type) {
! string name = type.Name;
! return name.StartsWith("I") ? name.Substring(1) : name;
! }
! private void generate()
{
ClassGenerator cg = new ClassGenerator();
--- 43,53 ----
}
! private string StripLeadingIifInterface(Type type)
! {
! string name = type.Name;
! return name.StartsWith("I") ? name.Substring(1) : name;
! }
! private void generate()
{
ClassGenerator cg = new ClassGenerator();
|
|
From: <sm...@us...> - 2003-01-03 16:00:51
|
Update of /cvsroot/nmock/nmock/src/NMock/Dynamic
In directory sc8-pr-cvs1:/tmp/cvs-serv13198/src/NMock/Dynamic
Modified Files:
ClassGenerator.cs
Log Message:
Extracted MethodImplementor and BoxingOpCodes from ClassGenerator
Index: ClassGenerator.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/Dynamic/ClassGenerator.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** ClassGenerator.cs 31 Dec 2002 21:36:38 -0000 1.5
--- ClassGenerator.cs 3 Jan 2003 16:00:47 -0000 1.6
***************
*** 9,13 ****
public class ClassGenerator
{
! private static IDictionary boxingOpCodes;
public virtual object Generate(Type type, IMock mock)
--- 9,14 ----
public class ClassGenerator
{
! private const System.Reflection.BindingFlags ALL_INSTANCE_METHODS
! = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
public virtual object Generate(Type type, IMock mock)
***************
*** 16,46 ****
}
! public virtual object Generate(Type type, IMock mock, IList methodsToIgnore)
! {
! methodsToIgnore.Add("Equals");
! methodsToIgnore.Add("ToString");
! 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 (IsOverridable(m) && !methodsToIgnore.Contains(m.Name))
! {
! implementMethod(type, typeBuilder, m, mockFieldBuilder);
! }
! }
! Type proxyType = typeBuilder.CreateType();
! object result = Activator.CreateInstance(proxyType);
! FieldInfo underlyingMock = proxyType.GetField("underlyingMock");
! underlyingMock.SetValue(result, mock);
! return result;
! }
!
! private bool IsOverridable(MethodInfo m)
{
return (m.IsVirtual && ! m.IsFinal);
}
! private TypeBuilder getTypeBuilder(string name, Type originalType)
{
AppDomain appDomain = AppDomain.CurrentDomain;
--- 17,44 ----
}
! public virtual object Generate(Type type, IMock mock, IList methodsToIgnore)
! {
! methodsToIgnore.Add("Equals");
! methodsToIgnore.Add("ToString");
!
! TypeBuilder typeBuilder = GetTypeBuilder("Mock" + type.Name, type);
! MethodImplementor methodImplementor = new MethodImplementor(typeBuilder);
!
! foreach ( MethodInfo methodInfo in type.GetMethods(ALL_INSTANCE_METHODS) )
! {
! if (IsOverridable(methodInfo) && !methodsToIgnore.Contains(methodInfo.Name))
! {
! methodImplementor.Implement(methodInfo);
! }
! }
! return CreateProxyInstance(typeBuilder, mock);
! }
!
! bool IsOverridable(MethodInfo m)
{
return (m.IsVirtual && ! m.IsFinal);
}
! TypeBuilder GetTypeBuilder(string name, Type originalType)
{
AppDomain appDomain = AppDomain.CurrentDomain;
***************
*** 64,170 ****
}
! private void implementMethod(Type type, TypeBuilder typeBuilder, MethodInfo m, FieldBuilder mockFieldBuilder)
! {
! Type returnType = m.ReturnType;
! ArrayList types = new ArrayList();
! foreach (ParameterInfo param in m.GetParameters())
! {
! types.Add(param.ParameterType);
! }
! Type[] paramTypes = (Type[])types.ToArray(typeof(Type));
! MethodBuilder methodBuilder = typeBuilder.DefineMethod(m.Name, MethodAttributes.Public | MethodAttributes.Virtual, returnType, paramTypes);
!
! ILGenerator il = methodBuilder.GetILGenerator();
! foreach (ParameterInfo param in m.GetParameters())
! {
! il.DeclareLocal(param.ParameterType);
! }
!
! string methodName = m.Name;
! if (methodName.StartsWith("get_") || methodName.StartsWith("set_"))
! {
! methodName = methodName.Substring(4);
! }
! il.Emit(OpCodes.Ldarg_0);
! il.Emit(OpCodes.Ldfld, mockFieldBuilder);
! il.Emit(OpCodes.Ldstr, methodName);
! il.Emit(OpCodes.Ldc_I4_S, paramTypes.Length);
! il.Emit(OpCodes.Newarr, typeof(object));
! if (paramTypes.Length > 0)
! {
! il.Emit(OpCodes.Stloc_0);
! il.Emit(OpCodes.Ldloc_0);
! for(int i = 0; i < paramTypes.Length; i++)
! {
! il.Emit(OpCodes.Ldc_I4_S, i);
! il.Emit(OpCodes.Ldarg_S, i + 1);
! if (paramTypes[i].IsPrimitive)
! {
! il.Emit(OpCodes.Box, paramTypes[i]);
! }
! il.Emit(OpCodes.Stelem_Ref);
! il.Emit(OpCodes.Ldloc_0);
! }
! }
! MethodInfo call = typeof(IMock).GetMethod("Call");
! il.EmitCall(OpCodes.Callvirt, call, null);
! if (returnType == typeof(void))
! {
! il.Emit(OpCodes.Pop);
! }
! else
! {
! if (returnType.IsPrimitive)
! {
! il.Emit(OpCodes.Unbox, returnType);
! il.Emit(getBoxingOpCode(returnType));
! }
! il.DeclareLocal(returnType);
! il.Emit(OpCodes.Stloc_0);
! Label l = il.DefineLabel();
! il.Emit(OpCodes.Br_S, l);
! il.MarkLabel(l);
! il.Emit(OpCodes.Ldloc_0);
! }
! il.Emit(OpCodes.Ret);
! }
! public OpCode getBoxingOpCode( Type aType )
! {
! if (boxingOpCodes == null)
! {
! boxingOpCodes = new Hashtable();
! boxingOpCodes[typeof(sbyte)] = OpCodes.Ldind_I1;
! boxingOpCodes[typeof(short)] = OpCodes.Ldind_I2;
! boxingOpCodes[typeof(int)] = OpCodes.Ldind_I4;
! boxingOpCodes[typeof(long)] = OpCodes.Ldind_I8;
! boxingOpCodes[typeof(byte)] = OpCodes.Ldind_U1;
! boxingOpCodes[typeof(ushort)] = OpCodes.Ldind_U2;
! boxingOpCodes[typeof(uint)] = OpCodes.Ldind_U4;
! boxingOpCodes[typeof(ulong)] = OpCodes.Ldind_I8;
! boxingOpCodes[typeof(float)] = OpCodes.Ldind_R4;
! boxingOpCodes[typeof(double)] = OpCodes.Ldind_R8;
! boxingOpCodes[typeof(char)] = OpCodes.Ldind_U2;
! boxingOpCodes[typeof(bool)] = OpCodes.Ldind_I1;
! }
! if (boxingOpCodes.Contains(aType))
! {
! return (OpCode)boxingOpCodes[aType];
! }
! else
! {
! return OpCodes.Ldind_I1;
! }
! }
! }
!
!
}
--- 62,233 ----
}
! object CreateProxyInstance(TypeBuilder typeBuilder, IMock mock)
! {
! Type proxyType = typeBuilder.CreateType();
! object result = Activator.CreateInstance(proxyType);
! FieldInfo underlyingMock = proxyType.GetField("underlyingMock");
! underlyingMock.SetValue(result, mock);
!
! return result;
! }
!
! }
!
! public class MethodImplementor
! {
! private BoxingOpCodes boxingOpCodes = new BoxingOpCodes();
! private TypeBuilder typeBuilder;
! private FieldBuilder mockFieldBuilder;
!
! public MethodImplementor(TypeBuilder aTypeBuilder)
! {
! typeBuilder = aTypeBuilder;
! mockFieldBuilder = typeBuilder.DefineField("underlyingMock", typeof(IMock), FieldAttributes.Public);
! }
!
! public virtual void Implement(MethodInfo methodInfo)
! {
! Type returnType = methodInfo.ReturnType;
! ParameterInfo[] parameterInfo = methodInfo.GetParameters();
! Type[] paramTypes = ExtractParameterTypes(parameterInfo);
! ILGenerator il = CreateILGenerator(methodInfo, returnType, paramTypes);
!
! EmitMethodSignature(methodInfo, paramTypes, il);
! EmitMethodCall(il);
! EmitMethodReturn(returnType, il);
! }
!
! private Type[] ExtractParameterTypes(ParameterInfo[] parameters)
! {
! Type[] paramTypes = new Type[parameters.Length];
! for (int i = 0; i < parameters.Length; ++i)
! {
! paramTypes[i] = parameters[i].ParameterType;
! }
! return paramTypes;
! }
!
! private ILGenerator CreateILGenerator(MethodInfo methodInfo, Type returnType, Type[] paramTypes)
! {
! MethodBuilder methodBuilder =
! typeBuilder.DefineMethod(methodInfo.Name, MethodAttributes.Public | MethodAttributes.Virtual, returnType, paramTypes);
!
! return methodBuilder.GetILGenerator();
! }
!
! private void EmitMethodSignature(MethodInfo methodInfo, Type[] paramTypes, ILGenerator il)
! {
! foreach (Type paramType in paramTypes)
! {
! il.DeclareLocal(paramType);
! }
! il.Emit(OpCodes.Ldarg_0);
! il.Emit(OpCodes.Ldfld, mockFieldBuilder);
! il.Emit(OpCodes.Ldstr, StripGetSetPrefix(methodInfo));
! il.Emit(OpCodes.Ldc_I4_S, paramTypes.Length);
! il.Emit(OpCodes.Newarr, typeof(object));
! if (paramTypes.Length > 0)
! {
! il.Emit(OpCodes.Stloc_0);
! il.Emit(OpCodes.Ldloc_0);
! for(int i = 0; i < paramTypes.Length; i++)
! {
! il.Emit(OpCodes.Ldc_I4_S, i);
! il.Emit(OpCodes.Ldarg_S, i + 1);
! if (paramTypes[i].IsPrimitive)
! {
! il.Emit(OpCodes.Box, paramTypes[i]);
! }
! il.Emit(OpCodes.Stelem_Ref);
! il.Emit(OpCodes.Ldloc_0);
! }
! }
! }
!
! private void EmitMethodCall(ILGenerator il)
! {
! MethodInfo call = typeof(IMock).GetMethod("Call");
! il.EmitCall(OpCodes.Callvirt, call, null);
! }
! private void EmitMethodReturn(Type returnType, ILGenerator il)
! {
! if (returnType == typeof(void))
! {
! il.Emit(OpCodes.Pop);
! }
! else
! {
! if (returnType.IsPrimitive)
! {
! il.Emit(OpCodes.Unbox, returnType);
! il.Emit(boxingOpCodes[returnType]);
! }
! il.DeclareLocal(returnType);
! il.Emit(OpCodes.Stloc_0);
! Label l = il.DefineLabel();
! il.Emit(OpCodes.Br_S, l);
! il.MarkLabel(l);
! il.Emit(OpCodes.Ldloc_0);
! }
! il.Emit(OpCodes.Ret);
! }
! private string StripGetSetPrefix(MethodInfo methodInfo)
! {
! string methodName;
! methodName = methodInfo.Name;
! if (methodName.StartsWith("get_") || methodName.StartsWith("set_"))
! {
! methodName = methodName.Substring(4);
! }
! return methodName;
! }
! }
! public class BoxingOpCodes
! {
! private static IDictionary boxingOpCodes;
! public OpCode this[Type aType]
! {
! get
! {
! return GetOpCode(aType);
! }
! }
!
! private static OpCode GetOpCode( Type aType )
! {
! if (boxingOpCodes == null)
! {
! boxingOpCodes = new Hashtable();
! boxingOpCodes[typeof(sbyte)] = OpCodes.Ldind_I1;
! boxingOpCodes[typeof(short)] = OpCodes.Ldind_I2;
! boxingOpCodes[typeof(int)] = OpCodes.Ldind_I4;
! boxingOpCodes[typeof(long)] = OpCodes.Ldind_I8;
! boxingOpCodes[typeof(byte)] = OpCodes.Ldind_U1;
! boxingOpCodes[typeof(ushort)] = OpCodes.Ldind_U2;
! boxingOpCodes[typeof(uint)] = OpCodes.Ldind_U4;
! boxingOpCodes[typeof(ulong)] = OpCodes.Ldind_I8;
! boxingOpCodes[typeof(float)] = OpCodes.Ldind_R4;
! boxingOpCodes[typeof(double)] = OpCodes.Ldind_R8;
! boxingOpCodes[typeof(char)] = OpCodes.Ldind_U2;
! boxingOpCodes[typeof(bool)] = OpCodes.Ldind_I1;
! }
! if (boxingOpCodes.Contains(aType))
! {
! return (OpCode)boxingOpCodes[aType];
! }
! else
! {
! return OpCodes.Ldind_I1;
! }
! }
! }
}
|
|
From: <sm...@us...> - 2003-01-03 16:00:50
|
Update of /cvsroot/nmock/nmock/test/NMock/Dynamic
In directory sc8-pr-cvs1:/tmp/cvs-serv13198/test/NMock/Dynamic
Modified Files:
ClassGeneratorTest.cs
Log Message:
Extracted MethodImplementor and BoxingOpCodes from ClassGenerator
Index: ClassGeneratorTest.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/test/NMock/Dynamic/ClassGeneratorTest.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ClassGeneratorTest.cs 31 Dec 2002 21:36:40 -0000 1.4
--- ClassGeneratorTest.cs 3 Jan 2003 16:00:46 -0000 1.5
***************
*** 257,274 ****
[Test]
! public void BoxingOpCodes()
{
! Assertion.AssertEquals( OpCodes.Ldind_I1, cg.getBoxingOpCode(typeof(sbyte)) );
! Assertion.AssertEquals( OpCodes.Ldind_I2, cg.getBoxingOpCode(typeof(short)) );
! Assertion.AssertEquals( OpCodes.Ldind_I4, cg.getBoxingOpCode(typeof(int)) );
! Assertion.AssertEquals( OpCodes.Ldind_I8, cg.getBoxingOpCode(typeof(long)) );
! Assertion.AssertEquals( OpCodes.Ldind_U1, cg.getBoxingOpCode(typeof(byte)) );
! Assertion.AssertEquals( OpCodes.Ldind_U2, cg.getBoxingOpCode(typeof(ushort)) );
! Assertion.AssertEquals( OpCodes.Ldind_U4, cg.getBoxingOpCode(typeof(uint)) );
! Assertion.AssertEquals( OpCodes.Ldind_I8, cg.getBoxingOpCode(typeof(ulong)) );
! Assertion.AssertEquals( OpCodes.Ldind_R4, cg.getBoxingOpCode(typeof(float)) );
! Assertion.AssertEquals( OpCodes.Ldind_R8, cg.getBoxingOpCode(typeof(double)) );
! Assertion.AssertEquals( OpCodes.Ldind_U2, cg.getBoxingOpCode(typeof(char)) );
! Assertion.AssertEquals( OpCodes.Ldind_I1, cg.getBoxingOpCode(typeof(bool)) );
}
--- 257,276 ----
[Test]
! public void CheckBoxingOpCodes()
{
! BoxingOpCodes opCodes = new BoxingOpCodes();
!
! Assertion.AssertEquals( OpCodes.Ldind_I1, opCodes[typeof(sbyte)] );
! Assertion.AssertEquals( OpCodes.Ldind_I2, opCodes[typeof(short)] );
! Assertion.AssertEquals( OpCodes.Ldind_I4, opCodes[typeof(int)] );
! Assertion.AssertEquals( OpCodes.Ldind_I8, opCodes[typeof(long)] );
! Assertion.AssertEquals( OpCodes.Ldind_U1, opCodes[typeof(byte)] );
! Assertion.AssertEquals( OpCodes.Ldind_U2, opCodes[typeof(ushort)] );
! Assertion.AssertEquals( OpCodes.Ldind_U4, opCodes[typeof(uint)] );
! Assertion.AssertEquals( OpCodes.Ldind_I8, opCodes[typeof(ulong)] );
! Assertion.AssertEquals( OpCodes.Ldind_R4, opCodes[typeof(float)] );
! Assertion.AssertEquals( OpCodes.Ldind_R8, opCodes[typeof(double)] );
! Assertion.AssertEquals( OpCodes.Ldind_U2, opCodes[typeof(char)] );
! Assertion.AssertEquals( OpCodes.Ldind_I1, opCodes[typeof(bool)] );
}
|
|
From: <sm...@us...> - 2003-01-03 16:00:08
|
Update of /cvsroot/nmock/nmock/src/NMock
In directory sc8-pr-cvs1:/tmp/cvs-serv12763/src/NMock
Modified Files:
DynamicMock.cs
Log Message:
Extracted method for stripping leading 'I'
Index: DynamicMock.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/DynamicMock.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** DynamicMock.cs 15 Nov 2002 22:31:09 -0000 1.3
--- DynamicMock.cs 3 Jan 2003 15:59:57 -0000 1.4
***************
*** 14,26 ****
public DynamicMock(Type type) : this(type, null)
{
! string name = type.Name;
! ignore = new ArrayList();
! if (name.StartsWith("I"))
! {
! name = name.Substring(1);
! }
! Name = "Mock" + name;
! }
!
public DynamicMock(Type type, string name) : base(name)
{
--- 14,21 ----
public DynamicMock(Type type) : this(type, null)
{
! ignore = new ArrayList();
! Name = "Mock" + StripLeadingIifInterface(type);
! }
!
public DynamicMock(Type type, string name) : base(name)
{
***************
*** 48,52 ****
}
! private void generate()
{
ClassGenerator cg = new ClassGenerator();
--- 43,52 ----
}
! private string StripLeadingIifInterface(Type type) {
! string name = type.Name;
! return name.StartsWith("I") ? name.Substring(1) : name;
! }
!
! private void generate()
{
ClassGenerator cg = new ClassGenerator();
|
|
From: <exo...@us...> - 2002-12-31 21:37:11
|
Update of /cvsroot/nmock/nmock/src/NMock/Constraints
In directory sc8-pr-cvs1:/tmp/cvs-serv31302/src/NMock/Constraints
Modified Files:
Constraints.cs
Log Message:
modified nant build file to build separate core and test assemblies
added new CollectingConstraint for post-test parameter validation
modified ClassGenerator to support overriding of internal and protected internal methods
fixed exception message in MockCall.checkArguments
Index: Constraints.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/Constraints/Constraints.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Constraints.cs 12 Dec 2002 21:42:35 -0000 1.2
--- Constraints.cs 31 Dec 2002 21:36:37 -0000 1.3
***************
*** 381,383 ****
--- 381,404 ----
}
+
+ public class CollectingConstraint : IConstraint
+ {
+ private object parameter;
+
+ public object Parameter
+ {
+ get { return parameter; }
+ }
+
+ public bool Eval(object val)
+ {
+ parameter = val;
+ return true;
+ }
+
+ public string Message
+ {
+ get { return "Collecting Constraint"; }
+ }
+ }
}
|