Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Right-click on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
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
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
|
|
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10
|
11
|
12
|
13
(7) |
14
(1) |
15
|
16
|
17
|
18
|
19
(1) |
20
|
21
|
22
(18) |
23
|
24
|
25
|
26
|
27
|
28
(3) |
29
(1) |
30
|
31
|
|
|
|
|
|
|
From: Jim Arnold <JArnold@th...> - 2004-10-29 09:17:04
|
<FONT face=3D"Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size= =3D2><DIV>+1</DIV><DIV> </DIV><DIV>Jim</DIV><DIV><BR> </DIV><FONT= color=3D#990099>-----nmock-general-admin@... wrote: ----= -<BR><BR></FONT><blockquote style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px;= MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">To: O= wen Rogers <orogers@...><BR>From: Mike Roberts <mike.= b.roberts@...><BR>Sent by: nmock-general-admin@...= et<BR>Date: 10/28/2004 08:55PM<BR>cc: Levi Khatskevitch <lkhatske@...= tworks.com>, nmock-general@...<BR>Subject: Re: [Nmock-= general] Re: Strong naming nmock.dll<BR><BR><FONT face=3Dmonospace size=3D2= >+1 to strong-naming assemblies.<BR><BR>-1 to keeping unit tests in the sam= e assemblies as the code they are<BR>testing. But that's just my opinion...= <BR><BR>Mike<BR><BR>On Thu, 28 Oct 2004 21:34:21 +0630, Owen Rogers<BR><ORO= GERS@...>wrote:<BR>> <BR>> definitely +1. i = was going through and doing this for some of my other<BR>> projects this= weekend. it's long overdue for nmock. <BR>> cheers, <BR>> owen= . <BR>> <BR>> <BR>> ---<BR>> R. Owen Rogers<B= R>> ThoughtWorks Technologies (India) Pvt Ltd.<BR>> <BR>&= gt; ThoughtWorks - Deliver with passion!<BR>> <BR>>  = ;ThoughtWorks is always looking for talented people who are passionate abou= t<BR>> technology. To find out more about a career at ThoughtWorks= go to<BR>> <A href=3D"http://www.thoughtworks.com/career/"; target=3Db= lank>http://www.thoughtworks.com/career/</A>. <BR>> <BR>>  = ;<BR>> <BR>> Levi Khatskevitch <BR>> <BR>> 28/10/20= 04 21:32 <BR>> T= o: nmock-general@... <BR>> = cc: Owen Rogers/Cana= da/ThoughtWorks@... <BR>> Subject: = Strong naming nmock.dll <BR>> <BR>> = On my current project we keep most of our unit tests in the same assembly a= s<BR>> the code they're testing. There are two reasons for that: <BR>>= ; <BR>> 1) It keeps things simple with regards to references and t= he number of<BR>> assemblies involved <BR>> 2) It's easy to test inte= rnal types since we don't have to make them public<BR>> or use reflectio= n <BR>> <BR>> We keep tests in a sub-folder within each project= and exclude it from<BR>> release builds. <BR>> <BR>> It all= worked nicely until we needed to strong name one of our assemblies<BR>>= since strongly named assemblies obviously can't reference non-strongly nam= ed<BR>> nmock.dll. I see no harm in strongly naming nmock.dll, especiall= y since<BR>> NUnit.Framework.dll is already strongly named. So if I don'= t hear any<BR>> objections from you I'll just go ahead and add signing t= o the NAnt build<BR>> script. <BR>> <BR>> Please tell me if = you think it's a bad idea. <BR>> <BR>> Regards, <BR>> = - Levi <BR>> <BR><BR><BR>-- <BR>mike roberts | <A href=3D"http://m= ikeroberts.thoughtworks.net/" target=3Dblank >http://mikeroberts.thoughtwo= rks.net/</A>|<BR><A href=3D"http://www.thoughtworks.com/"; target=3Dblank >= http://www.thoughtworks.com/</A><BR><BR><BR>-------------------------------= ------------------------<BR>This Newsletter Sponsored by: Macrovision <BR>F= or reliable Linux application installations, use the industry's leading<BR>= setup authoring tool, InstallShield X. Learn more and evaluate <BR>today. <= A href=3D"http://clk.atdmt.com/MSI/go/ins0030000001msi/direct/01/"; target= =3Dblank >http://clk.atdmt.com/MSI/go/ins0030000001msi/direct/01/</A><BR>= =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F<BR>Nmock= -general mailing list<BR>Nmock-general@...<BR><A href=3D"= https://lists.sourceforge.net/lists/listinfo/nmock-general"; target=3Dblank = >https://lists.sourceforge.net/lists/listinfo/nmock-general</A><BR></FONT><= /blockquote><br></FONT>= |
From: Mike Roberts <mike.b.roberts@gm...> - 2004-10-28 19:55:54
|
+1 to strong-naming assemblies. -1 to keeping unit tests in the same assemblies as the code they are testing. But that's just my opinion... Mike On Thu, 28 Oct 2004 21:34:21 +0630, Owen Rogers <orogers@...> wrote: > > definitely +1. i was going through and doing this for some of my other > projects this weekend. it's long overdue for nmock. > cheers, > owen. > > > --- > R. Owen Rogers > ThoughtWorks Technologies (India) Pvt Ltd. > > ThoughtWorks - Deliver with passion! > > ThoughtWorks is always looking for talented people who are passionate about > technology. To find out more about a career at ThoughtWorks go to > http://www.thoughtworks.com/career/. > > > > Levi Khatskevitch > > 28/10/2004 21:32 > To: nmock-general@... > cc: Owen Rogers/Canada/ThoughtWorks@... > Subject: Strong naming nmock.dll > > On my current project we keep most of our unit tests in the same assembly as > the code they're testing. There are two reasons for that: > > 1) It keeps things simple with regards to references and the number of > assemblies involved > 2) It's easy to test internal types since we don't have to make them public > or use reflection > > We keep tests in a sub-folder within each project and exclude it from > release builds. > > It all worked nicely until we needed to strong name one of our assemblies > since strongly named assemblies obviously can't reference non-strongly named > nmock.dll. I see no harm in strongly naming nmock.dll, especially since > NUnit.Framework.dll is already strongly named. So if I don't hear any > objections from you I'll just go ahead and add signing to the NAnt build > script. > > Please tell me if you think it's a bad idea. > > Regards, > - Levi > -- mike roberts | http://mikeroberts.thoughtworks.net/ | http://www.thoughtworks.com/ |
From: Owen Rogers <ORogers@th...> - 2004-10-28 16:17:28
|
definitely +1. i was going through and doing this for some of my other projects this weekend. it's long overdue for nmock. cheers, owen. --- R. Owen Rogers ThoughtWorks Technologies (India) Pvt Ltd. ThoughtWorks - Deliver with passion! ThoughtWorks is always looking for talented people who are passionate about technology. To find out more about a career at ThoughtWorks go to http://www.thoughtworks.com/career/. Levi Khatskevitch 28/10/2004 21:32 To: nmock-general@... cc: Owen Rogers/Canada/ThoughtWorks@... Subject: Strong naming nmock.dll On my current project we keep most of our unit tests in the same assembly as the code they're testing. There are two reasons for that: 1) It keeps things simple with regards to references and the number of assemblies involved 2) It's easy to test internal types since we don't have to make them public or use reflection We keep tests in a sub-folder within each project and exclude it from release builds. It all worked nicely until we needed to strong name one of our assemblies since strongly named assemblies obviously can't reference non-strongly named nmock.dll. I see no harm in strongly naming nmock.dll, especially since NUnit.Framework.dll is already strongly named. So if I don't hear any objections from you I'll just go ahead and add signing to the NAnt build script. Please tell me if you think it's a bad idea. Regards, - Levi |
From: Levi Khatskevitch <LKhatskevitch@th...> - 2004-10-28 16:01:13
|
On my current project we keep most of our unit tests in the same assembly as the code they're testing. There are two reasons for that: 1) It keeps things simple with regards to references and the number of assemblies involved 2) It's easy to test internal types since we don't have to make them public or use reflection We keep tests in a sub-folder within each project and exclude it from release builds. It all worked nicely until we needed to strong name one of our assemblies since strongly named assemblies obviously can't reference non-strongly named nmock.dll. I see no harm in strongly naming nmock.dll, especially since NUnit.Framework.dll is already strongly named. So if I don't hear any objections from you I'll just go ahead and add signing to the NAnt build script. Please tell me if you think it's a bad idea. Regards, - Levi |
From: Owen Rogers <exortech@us...> - 2004-10-22 12:24:02
|
Update of /cvsroot/nmock/nmock In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27533 Modified Files: nmock.build Log Message: fixing nant warnings Index: nmock.build =================================================================== RCS file: /cvsroot/nmock/nmock/nmock.build,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** nmock.build 22 Oct 2004 11:46:26 -0000 1.10 --- nmock.build 22 Oct 2004 12:23:50 -0000 1.11 *************** *** 74,89 **** <zip zipfile="dist\nmock.source.zip"> <fileset> ! <includes name="**\*" /> ! <excludes name="build\**\*" /> ! <excludes name="dist\**\*" /> ! <excludes name="tools\**\*" /> ! <excludes name="**\bin\**\*" /> ! <excludes name="**\obj\**\*" /> ! <excludes name="**\CVS\**\*" /> ! <excludes name="*.suo" /> ! <excludes name="*.resharper*" /> ! <excludes name="**\*.csproj.user" /> ! <excludes name="*.resharper*\**\*" /> </fileset> </zip> --- 74,89 ---- <zip zipfile="dist\nmock.source.zip"> <fileset> ! <include name="**\*" /> ! <exclude name="build\**\*" /> ! <exclude name="dist\**\*" /> ! <exclude name="tools\**\*" /> ! <exclude name="**\bin\**\*" /> ! <exclude name="**\obj\**\*" /> ! <exclude name="**\CVS\**\*" /> ! <exclude name="*.suo" /> ! <exclude name="*.resharper*" /> ! <exclude name="**\*.csproj.user" /> ! <exclude name="*.resharper*\**\*" /> </fileset> </zip> *************** *** 100,104 **** <copy todir="${publish.dir}"> <fileset basedir="dist"> ! <includes name="*"/> </fileset> </copy> --- 100,104 ---- <copy todir="${publish.dir}"> <fileset basedir="dist"> ! <include name="*"/> </fileset> </copy> |
From: Owen Rogers <exortech@us...> - 2004-10-22 12:19:27
|
Update of /cvsroot/nmock/nmock/tools/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26479/tools/lib Added Files: ICSharpCode.SharpCvsLib.Console.dll ICSharpCode.SharpCvsLib.dll ICSharpCode.SharpZipLib.dll Log Message: adding missing nant libs --- NEW FILE: ICSharpCode.SharpCvsLib.Console.dll --- (This appears to be a binary file; contents omitted.) --- NEW FILE: ICSharpCode.SharpZipLib.dll --- (This appears to be a binary file; contents omitted.) --- NEW FILE: ICSharpCode.SharpCvsLib.dll --- (This appears to be a binary file; contents omitted.) |
From: Owen Rogers <exortech@us...> - 2004-10-22 12:07:19
|
Update of /cvsroot/nmock/nmock In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24037 Removed Files: continuousintegration.build Log Message: removing ccnet bootstrappers --- continuousintegration.build DELETED --- |
From: Owen Rogers <exortech@us...> - 2004-10-22 12:07:18
|
Update of /cvsroot/nmock/nmock/ccnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24037/ccnet Removed Files: ccnet-nmock.bat ccnet.config Log Message: removing ccnet bootstrappers --- ccnet-nmock.bat DELETED --- --- ccnet.config DELETED --- |
From: Owen Rogers <exortech@us...> - 2004-10-22 11:47:09
|
Update of /cvsroot/nmock/nmock/test/NMock/Proxy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19470/test/NMock/Proxy Modified Files: MockRealProxyTest.cs Log Message: upgraded to nunit 2.2 upgraded to new version of NAnt Index: MockRealProxyTest.cs =================================================================== RCS file: /cvsroot/nmock/nmock/test/NMock/Proxy/MockRealProxyTest.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MockRealProxyTest.cs 13 Oct 2004 18:03:57 -0000 1.2 --- MockRealProxyTest.cs 22 Oct 2004 11:46:28 -0000 1.3 *************** *** 2,17 **** using System.Collections; using System.IO; - using System.Reflection; - using System.Reflection.Emit; - - - using NUnit.Framework; - using NMock; using NMock.Constraints; namespace NMock.Proxy { #region types ! public interface IThingy { void NoArgs(); --- 2,14 ---- using System.Collections; using System.IO; using NMock.Constraints; + using NUnit.Framework; namespace NMock.Proxy { + #region types ! ! public interface IThingy { void NoArgs(); *************** *** 42,60 **** { } ! ! public struct MyStruct { public int x; } ! ! class X { private IMock mock = null; ! ! string stringReturn() { return (string)mock.Invoke("stringReturn", new object[0]); } ! decimal decimalReturn() { return (decimal)mock.Invoke("decimalReturn", new object[0]); } ! MyStruct structReturn() { return (MyStruct)mock.Invoke("structReturn", new object[0]); } } ! public interface ISolidThingy { --- 39,68 ---- { } ! ! public struct MyStruct { public int x; } ! ! internal class X { private IMock mock = null; ! ! private string stringReturn() ! { ! return (string) mock.Invoke("stringReturn", new object[0]); ! } ! ! private decimal decimalReturn() ! { ! return (decimal) mock.Invoke("decimalReturn", new object[0]); ! } ! ! private MyStruct structReturn() ! { ! return (MyStruct) mock.Invoke("structReturn", new object[0]); ! } } ! public interface ISolidThingy { *************** *** 65,80 **** { // internal and protected internal methods must be overridable! ! public virtual string VirtualMethod() { return "xx"; } public abstract string AbstractMethod(); ! protected internal virtual string ProtectedInternalMethod() { return "xx"; } // cannot override ! public static string StaticMethod() { return "xx"; } ! public string NonVirtualMethod() { return "xx"; } ! internal string NonVirtualInternalMethod() { return "xx"; } ! private string privateMethod() { return "xx"; } ! protected virtual string protectedMethod() { return "xx"; } ! string defaultInternalMethod() { return "xx"; } ! public override string ToString() { return "xx"; } // method is ignored // implemented interface members/methods are defined as final (ie. non-virtual) --- 73,123 ---- { // internal and protected internal methods must be overridable! ! public virtual string VirtualMethod() ! { ! return "xx"; ! } ! public abstract string AbstractMethod(); ! ! protected internal virtual string ProtectedInternalMethod() ! { ! return "xx"; ! } // cannot override ! public static string StaticMethod() ! { ! return "xx"; ! } ! ! public string NonVirtualMethod() ! { ! return "xx"; ! } ! ! internal string NonVirtualInternalMethod() ! { ! return "xx"; ! } ! ! private string privateMethod() ! { ! return "xx"; ! } ! ! protected virtual string protectedMethod() ! { ! return "xx"; ! } ! ! private string defaultInternalMethod() ! { ! return "xx"; ! } ! ! public override string ToString() ! { ! return "xx"; ! } // method is ignored // implemented interface members/methods are defined as final (ie. non-virtual) *************** *** 85,101 **** } ! public class ClassWithInternalMethod { ! internal virtual string InternalMethod() { return "xx"; } } ! public enum MyEnum { ! A, B, C, D } public class ConcreteThing : MarshalByRefObject { ! public virtual void NoArgs() { Assertion.Fail("Should have been overriden"); } } --- 128,153 ---- } ! public class ClassWithInternalMethod { ! internal virtual string InternalMethod() ! { ! return "xx"; ! } } ! public enum MyEnum { ! A, ! B, ! C, ! D } public class ConcreteThing : MarshalByRefObject { ! public virtual void NoArgs() ! { ! Assert.Fail("Should have been overriden"); ! } } *************** *** 111,130 **** public class SimpleThingy : MarshalByRefObject, ISimpleThingy { ! void ISimpleThingy.NoArgs() { Assertion.Fail("Should have been overriden"); } } #endregion ! [TestFixture] public class MockRealProxyInvocationHandlerTest { ! public class InvocationHandlerImpl : IInvocationHandler { public string expectedMethodName; public bool wasCalled = false; ! public object Invoke(string methodName, params object[] args) { ! Assertion.AssertEquals("should be method name", expectedMethodName, methodName); ! Assertion.AssertEquals("Should be no args", 0, args.Length); wasCalled = true; return null; --- 163,186 ---- public class SimpleThingy : MarshalByRefObject, ISimpleThingy { ! void ISimpleThingy.NoArgs() ! { ! Assert.Fail("Should have been overriden"); ! } } #endregion ! [TestFixture] ! public class MockRealProxyInvocationHandlerTest { ! public class InvocationHandlerImpl : IInvocationHandler { public string expectedMethodName; public bool wasCalled = false; ! public object Invoke(string methodName, params object[] args) { ! Assert.AreEqual(expectedMethodName, methodName, "should be method name"); ! Assert.AreEqual(0, args.Length, "Should be no args"); wasCalled = true; return null; *************** *** 137,168 **** } ! [Test] public void CreateRealProxy() { InvocationHandlerImpl handler = new InvocationHandlerImpl(); ! MockRealProxy rp = new MockRealProxy(typeof(IThingy), handler); ! IThingy thingy = (IThingy)rp.GetTransparentProxy(); ! handler.expectedMethodName = "NoArgs"; thingy.NoArgs(); ! Assertion.Assert("Should have been called ", handler.wasCalled); } } ! [TestFixture] public class MockRealProxyTest { private MockRealProxy rp; private IMock mock; private IThingy thingy; ! ! [SetUp] public void SetUp() { mock = new Mock("Test Mock"); ! rp = new MockRealProxy(typeof(IThingy), mock); ! thingy = (IThingy)rp.GetTransparentProxy(); } ! [Test] public void CallMethodIsCalled() { mock.Expect("NoArgs"); --- 193,228 ---- } ! [Test] ! public void CreateRealProxy() { InvocationHandlerImpl handler = new InvocationHandlerImpl(); ! MockRealProxy rp = new MockRealProxy(typeof (IThingy), handler); ! IThingy thingy = (IThingy) rp.GetTransparentProxy(); ! handler.expectedMethodName = "NoArgs"; thingy.NoArgs(); ! Assert.IsTrue(handler.wasCalled, "Should have been called "); } } ! [TestFixture] ! public class MockRealProxyTest { private MockRealProxy rp; private IMock mock; private IThingy thingy; ! ! [SetUp] ! public void SetUp() { mock = new Mock("Test Mock"); ! rp = new MockRealProxy(typeof (IThingy), mock); ! thingy = (IThingy) rp.GetTransparentProxy(); } ! [Test] ! public void CallMethodIsCalled() { mock.Expect("NoArgs"); *************** *** 171,230 **** } ! [Test] public void CallMethodWithReturn() { object x = "sdfs"; mock.ExpectAndReturn("simpleReturn", x); object result = thingy.simpleReturn(); ! Assertion.AssertEquals(x, result); mock.Verify(); } ! [Test] public void CallMethodWithReturnAndCast() { string x = "sdfs"; mock.ExpectAndReturn("stringReturn", x); string result = thingy.stringReturn(); ! Assertion.AssertEquals(x, result); mock.Verify(); } ! [Test] public void CallMethodWithWeirdObjectReturn() { IThingy t = thingy; mock.ExpectAndReturn("AThingy", t); IThingy result = thingy.AThingy(); ! Assertion.AssertSame(thingy, result); mock.Verify(); } ! [Test] public void CallMethodWithReturnInt() { mock.ExpectAndReturn("intReturn", 7); int result = thingy.intReturn(); ! Assertion.AssertEquals(7, result); mock.Verify(); } ! [Test] public void CallMethodWithReturnBoxings() { mock.ExpectAndReturn("boolReturn", true); mock.ExpectAndReturn("doubleReturn", 1234567891234E+10); ! Assertion.Assert(thingy.boolReturn()); ! Assertion.AssertEquals(1234567891234E+10, thingy.doubleReturn()); mock.Verify(); } ! [Test] ! public void CallMethodWithReturnDecimal() { decimal d = new decimal(3); mock.ExpectAndReturn("decimalReturn", d); decimal result = thingy.decimalReturn(); ! Assertion.AssertEquals(new decimal(3), result); mock.Verify(); } ! [Test] ! public void CallMethodWithStruct() { MyStruct str = new MyStruct(); --- 231,295 ---- } ! [Test] ! public void CallMethodWithReturn() { object x = "sdfs"; mock.ExpectAndReturn("simpleReturn", x); object result = thingy.simpleReturn(); ! Assert.AreEqual(x, result); mock.Verify(); } ! [Test] ! public void CallMethodWithReturnAndCast() { string x = "sdfs"; mock.ExpectAndReturn("stringReturn", x); string result = thingy.stringReturn(); ! Assert.AreEqual(x, result); mock.Verify(); } ! [Test] ! public void CallMethodWithWeirdObjectReturn() { IThingy t = thingy; mock.ExpectAndReturn("AThingy", t); IThingy result = thingy.AThingy(); ! Assert.AreSame(thingy, result); mock.Verify(); } ! [Test] ! public void CallMethodWithReturnInt() { mock.ExpectAndReturn("intReturn", 7); int result = thingy.intReturn(); ! Assert.AreEqual(7, result); mock.Verify(); } ! [Test] ! public void CallMethodWithReturnBoxings() { mock.ExpectAndReturn("boolReturn", true); mock.ExpectAndReturn("doubleReturn", 1234567891234E+10); ! Assert.IsTrue(thingy.boolReturn()); ! Assert.AreEqual(1234567891234E+10, thingy.doubleReturn()); mock.Verify(); } ! [Test] ! public void CallMethodWithReturnDecimal() { decimal d = new decimal(3); mock.ExpectAndReturn("decimalReturn", d); decimal result = thingy.decimalReturn(); ! Assert.AreEqual(new decimal(3), result); mock.Verify(); } ! [Test] ! public void CallMethodWithStruct() { MyStruct str = new MyStruct(); *************** *** 232,254 **** mock.ExpectAndReturn("structReturn", str); MyStruct result = thingy.structReturn(); ! Assertion.AssertEquals(str, result); mock.Verify(); ! } ! ! [Test] public void CallMethodWithReturnEnum() { mock.ExpectAndReturn("getEnum", MyEnum.C); MyEnum result = thingy.getEnum(); ! Assertion.AssertEquals(MyEnum.C, result); mock.Verify(); } ! ! [Test] [ExpectedException(typeof(IOException))] public void CallMethodTheThrowsException() { ! mock.ExpectAndThrow("boolReturn", new System.IO.IOException()); thingy.boolReturn(); } ! [Test] public void CallMethodWithStringParameterExpectation() { mock.Expect("WithSimpleArg", new StartsWith("he")); --- 297,323 ---- mock.ExpectAndReturn("structReturn", str); MyStruct result = thingy.structReturn(); ! Assert.AreEqual(str, result); mock.Verify(); ! } ! ! [Test] ! public void CallMethodWithReturnEnum() { mock.ExpectAndReturn("getEnum", MyEnum.C); MyEnum result = thingy.getEnum(); ! Assert.AreEqual(MyEnum.C, result); mock.Verify(); } ! ! [Test] ! [ExpectedException(typeof (IOException))] ! public void CallMethodTheThrowsException() { ! mock.ExpectAndThrow("boolReturn", new IOException()); thingy.boolReturn(); } ! [Test] ! public void CallMethodWithStringParameterExpectation() { mock.Expect("WithSimpleArg", new StartsWith("he")); *************** *** 256,261 **** mock.Verify(); } ! ! [Test] public void CallMethodWithStringParameter() { mock.Expect("WithSimpleArg", "hello"); --- 325,331 ---- mock.Verify(); } ! ! [Test] ! public void CallMethodWithStringParameter() { mock.Expect("WithSimpleArg", "hello"); *************** *** 264,274 **** } ! [Test] public void CallMethodWithIntParameter() { mock.Expect("WithIntParam", 1); thingy.WithIntParam(1); mock.Verify(); ! } ! [Test] [ExpectedException(typeof(VerifyException))] public void CallMethodWithParamExpectationsThatFails() { mock.Expect("WithSimpleArg", new IsEqual("hello")); --- 334,348 ---- } ! [Test] ! public void CallMethodWithIntParameter() { mock.Expect("WithIntParam", 1); thingy.WithIntParam(1); mock.Verify(); ! } ! ! [Test] ! [ExpectedException(typeof (VerifyException))] ! public void CallMethodWithParamExpectationsThatFails() { mock.Expect("WithSimpleArg", new IsEqual("hello")); *************** *** 276,281 **** mock.Verify(); } ! ! [Test] public void CallMethodWithTwoParamExpectations() { mock.Expect("WithTwoArgs", new IsEqual("hello"), new IsEqual("world")); --- 350,356 ---- mock.Verify(); } ! ! [Test] ! public void CallMethodWithTwoParamExpectations() { mock.Expect("WithTwoArgs", new IsEqual("hello"), new IsEqual("world")); *************** *** 283,288 **** mock.Verify(); } ! ! [Test] [ExpectedException(typeof(VerifyException))] public void CallMethodWithTwoParamExpectationsThatFails() { mock.Expect("WithTwoArgs", new IsEqual("hello"), new IsEqual("world")); --- 358,365 ---- mock.Verify(); } ! ! [Test] ! [ExpectedException(typeof (VerifyException))] ! public void CallMethodWithTwoParamExpectationsThatFails() { mock.Expect("WithTwoArgs", new IsEqual("hello"), new IsEqual("world")); *************** *** 290,295 **** mock.Verify(); } ! ! [Test] public void CallMethodWithThreeParamExpectations() { mock.Expect("WithThreeArgs", new IsEqual("hello"), new IsEqual("the"), new IsEqual("world")); --- 367,373 ---- mock.Verify(); } ! ! [Test] ! public void CallMethodWithThreeParamExpectations() { mock.Expect("WithThreeArgs", new IsEqual("hello"), new IsEqual("the"), new IsEqual("world")); *************** *** 297,302 **** mock.Verify(); } ! ! [Test] public void CallMethodWithLotsOfArgsExpectations() { mock.Expect("WithLotsOfArgs", new IsEqual("hello"), new IsEqual("world"), new IsEqual("is"), new IsEqual("this"), new IsEqual("the"), new IsEqual("end")); --- 375,381 ---- mock.Verify(); } ! ! [Test] ! public void CallMethodWithLotsOfArgsExpectations() { mock.Expect("WithLotsOfArgs", new IsEqual("hello"), new IsEqual("world"), new IsEqual("is"), new IsEqual("this"), new IsEqual("the"), new IsEqual("end")); *************** *** 305,309 **** } ! [Test] public void CallMethodWithOtherArgs() { IList l = new ArrayList(); --- 384,389 ---- } ! [Test] ! public void CallMethodWithOtherArgs() { IList l = new ArrayList(); *************** *** 312,322 **** mock.Verify(); } ! [Test] public void CallMethodWithVariableNumberOfParams() { ! mock.Expect("WithParams", 1, new object[]{"string1", "string2"}); thingy.WithParams(1, "string1", "string2"); mock.Verify(); } ! [Test] public void CallMethodWithLongParam() { mock.Expect("WithLongParam", 5L); --- 392,406 ---- mock.Verify(); } ! ! [Test] ! public void CallMethodWithVariableNumberOfParams() { ! mock.Expect("WithParams", 1, new object[] {"string1", "string2"}); thingy.WithParams(1, "string1", "string2"); mock.Verify(); } ! ! [Test] ! public void CallMethodWithLongParam() { mock.Expect("WithLongParam", 5L); *************** *** 325,332 **** } ! [Test] public void CallMethodOfImplementedInterface() { ! rp = new MockRealProxy(typeof(SimpleThingy), mock); ! ISimpleThingy thingy = (ISimpleThingy)rp.GetTransparentProxy(); mock.SetupResult("NonVirtualProperty", "foo"); --- 409,417 ---- } ! [Test] ! public void CallMethodOfImplementedInterface() { ! rp = new MockRealProxy(typeof (SimpleThingy), mock); ! ISimpleThingy thingy = (ISimpleThingy) rp.GetTransparentProxy(); mock.SetupResult("NonVirtualProperty", "foo"); *************** *** 335,342 **** } ! [Test] public void CallMethodOfInheritedInterface() { ! rp = new MockRealProxy(typeof(IDerivedThingy), mock); ! thingy = (IThingy)rp.GetTransparentProxy(); mock.Expect("NoArgs"); --- 420,428 ---- } ! [Test] ! public void CallMethodOfInheritedInterface() { ! rp = new MockRealProxy(typeof (IDerivedThingy), mock); ! thingy = (IThingy) rp.GetTransparentProxy(); mock.Expect("NoArgs"); *************** *** 345,352 **** } ! [Test] public void CallMethodOfInheritedClass() { ! rp = new MockRealProxy(typeof(DerivedThing), mock); ! DerivedThing derived = (DerivedThing)rp.GetTransparentProxy(); mock.Expect("NoArgs"); --- 431,439 ---- } ! [Test] ! public void CallMethodOfInheritedClass() { ! rp = new MockRealProxy(typeof (DerivedThing), mock); ! DerivedThing derived = (DerivedThing) rp.GetTransparentProxy(); mock.Expect("NoArgs"); *************** *** 355,368 **** } ! [Test] public void CallReadOnlyProperty() { mock.ExpectAndReturn("ReadProperty", "hello"); mock.ExpectAndReturn("ReadProperty", "world"); ! Assertion.AssertEquals("hello", thingy.ReadProperty); ! Assertion.AssertEquals("world", thingy.ReadProperty); mock.Verify(); } ! [Test] public void WriteOnlyPropertyExpectations() { mock.Expect("WriteProperty", "hello"); --- 442,457 ---- } ! [Test] ! public void CallReadOnlyProperty() { mock.ExpectAndReturn("ReadProperty", "hello"); mock.ExpectAndReturn("ReadProperty", "world"); ! Assert.AreEqual("hello", thingy.ReadProperty); ! Assert.AreEqual("world", thingy.ReadProperty); mock.Verify(); } ! [Test] ! public void WriteOnlyPropertyExpectations() { mock.Expect("WriteProperty", "hello"); *************** *** 373,377 **** } ! [Test] public void ReadAndWriteProperty() { mock.Expect("AProperty", "hello"); --- 462,467 ---- } ! [Test] ! public void ReadAndWriteProperty() { mock.Expect("AProperty", "hello"); *************** *** 381,393 **** thingy.AProperty = "hello"; thingy.AProperty = "world"; ! Assertion.AssertEquals("good", thingy.AProperty); ! Assertion.AssertEquals("bye", thingy.AProperty); mock.Verify(); } ! [Test] public void CanProxyAbstractClass() { ! rp = new MockRealProxy(typeof(AbstractThingy), mock); ! AbstractThingy s = (AbstractThingy)rp.GetTransparentProxy(); mock.ExpectAndReturn("VirtualMethod", "hello"); --- 471,484 ---- thingy.AProperty = "hello"; thingy.AProperty = "world"; ! Assert.AreEqual("good", thingy.AProperty); ! Assert.AreEqual("bye", thingy.AProperty); mock.Verify(); } ! [Test] ! public void CanProxyAbstractClass() { ! rp = new MockRealProxy(typeof (AbstractThingy), mock); ! AbstractThingy s = (AbstractThingy) rp.GetTransparentProxy(); mock.ExpectAndReturn("VirtualMethod", "hello"); *************** *** 396,411 **** mock.ExpectAndReturn("ProtectedInternalMethod", "white"); ! Assertion.AssertEquals("hello", s.VirtualMethod()); ! Assertion.AssertEquals(123, s.GetHashCode()); ! Assertion.AssertEquals("fish", s.AbstractMethod()); ! Assertion.AssertEquals("white", s.ProtectedInternalMethod()); mock.Verify(); } ! [Test] public void CanProxyConcreteClass() { ! rp = new MockRealProxy(typeof(ConcreteThing), mock); ! ConcreteThing concrete = (ConcreteThing)rp.GetTransparentProxy(); mock.Expect("NoArgs"); --- 487,503 ---- mock.ExpectAndReturn("ProtectedInternalMethod", "white"); ! Assert.AreEqual("hello", s.VirtualMethod()); ! Assert.AreEqual(123, s.GetHashCode()); ! Assert.AreEqual("fish", s.AbstractMethod()); ! Assert.AreEqual("white", s.ProtectedInternalMethod()); mock.Verify(); } ! [Test] ! public void CanProxyConcreteClass() { ! rp = new MockRealProxy(typeof (ConcreteThing), mock); ! ConcreteThing concrete = (ConcreteThing) rp.GetTransparentProxy(); mock.Expect("NoArgs"); *************** *** 414,434 **** } ! [Test] public void CanHandleNonVirtualFeatures() { ! rp = new MockRealProxy(typeof(AbstractThingy), mock); ! AbstractThingy s = (AbstractThingy)rp.GetTransparentProxy(); mock.SetupResult("NonVirtualMethod", "non virtual method"); mock.SetupResult("NonVirtualProperty", "non virtual property"); ! Assertion.AssertEquals("non virtual method", s.NonVirtualMethod()); ! Assertion.AssertEquals("non virtual property", s.NonVirtualProperty); mock.Verify(); } ! [Test] public void CanHandleObjectMethodOnInterface() { ! Assertion.AssertNull(thingy.ToString()); } } ! } --- 506,528 ---- } ! [Test] ! public void CanHandleNonVirtualFeatures() { ! rp = new MockRealProxy(typeof (AbstractThingy), mock); ! AbstractThingy s = (AbstractThingy) rp.GetTransparentProxy(); mock.SetupResult("NonVirtualMethod", "non virtual method"); mock.SetupResult("NonVirtualProperty", "non virtual property"); ! Assert.AreEqual("non virtual method", s.NonVirtualMethod()); ! Assert.AreEqual("non virtual property", s.NonVirtualProperty); mock.Verify(); } ! [Test] ! public void CanHandleObjectMethodOnInterface() { ! Assert.IsNull(thingy.ToString()); } } ! } \ No newline at end of file |
From: Owen Rogers <exortech@us...> - 2004-10-22 11:47:09
|
Update of /cvsroot/nmock/nmock/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19470/test Modified Files: test.csproj Log Message: upgraded to nunit 2.2 upgraded to new version of NAnt Index: test.csproj =================================================================== RCS file: /cvsroot/nmock/nmock/test/test.csproj,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** test.csproj 13 Oct 2004 15:43:15 -0000 1.12 --- test.csproj 22 Oct 2004 11:46:28 -0000 1.13 *************** *** 145,148 **** --- 145,153 ---- /> <File + RelPath = "NMock\Constraints\IsArrayEqualTest.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "NMock\Dynamic\ClassGeneratorTest.cs" SubType = "Code" |
From: Owen Rogers <exortech@us...> - 2004-10-22 11:47:09
|
Update of /cvsroot/nmock/nmock/test/NMock/Dynamic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19470/test/NMock/Dynamic Modified Files: ClassGeneratorTest.cs InterfaceListerTest.cs Log Message: upgraded to nunit 2.2 upgraded to new version of NAnt Index: ClassGeneratorTest.cs =================================================================== RCS file: /cvsroot/nmock/nmock/test/NMock/Dynamic/ClassGeneratorTest.cs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** ClassGeneratorTest.cs 23 Jun 2004 04:44:53 -0000 1.17 --- ClassGeneratorTest.cs 22 Oct 2004 11:46:27 -0000 1.18 *************** *** 1,16 **** using System; using System.Collections; using System.Reflection; using System.Reflection.Emit; - - - using NUnit.Framework; - using NMock; using NMock.Constraints; namespace NMock.Dynamic { #region types ! public interface IThingy { void NoArgs(); --- 1,16 ---- using System; using System.Collections; + using System.IO; using System.Reflection; using System.Reflection.Emit; using NMock.Constraints; + using NUnit.Framework; namespace NMock.Dynamic { + #region types ! ! public interface IThingy { void NoArgs(); *************** *** 37,55 **** string AProperty { get; set; } } ! ! public struct MyStruct ! { ! public int x; ! } ! ! class X ! { ! private IMock mock = null; ! ! string stringReturn() { return (string)mock.Invoke("stringReturn", new object[0]); } ! decimal decimalReturn() { return (decimal)mock.Invoke("decimalReturn", new object[0]); } ! MyStruct structReturn() { return (MyStruct)mock.Invoke("structReturn", new object[0]); } ! } ! public interface ISolidThingy { --- 37,66 ---- string AProperty { get; set; } } ! ! public struct MyStruct ! { ! public int x; ! } ! ! internal class X ! { ! private IMock mock = null; ! ! private string stringReturn() ! { ! return (string) mock.Invoke("stringReturn", new object[0]); ! } ! ! private decimal decimalReturn() ! { ! return (decimal) mock.Invoke("decimalReturn", new object[0]); ! } ! ! private MyStruct structReturn() ! { ! return (MyStruct) mock.Invoke("structReturn", new object[0]); ! } ! } ! public interface ISolidThingy { *************** *** 60,75 **** { // internal and protected internal methods must be overridable! ! public virtual string VirtualMethod() { return "xx"; } public abstract string AbstractMethod(); ! protected internal virtual string ProtectedInternalMethod() { return "xx"; } // cannot override ! public static string StaticMethod() { return "xx"; } ! public string NonVirtualMethod() { return "xx"; } ! internal string NonVirtualInternalMethod() { return "xx"; } ! private string privateMethod() { return "xx"; } ! protected virtual string protectedMethod() { return "xx"; } ! string defaultInternalMethod() { return "xx"; } ! public override string ToString() { return "xx"; } // method is ignored // implemented interface members/methods are defined as final (ie. non-virtual) --- 71,121 ---- { // internal and protected internal methods must be overridable! ! public virtual string VirtualMethod() ! { ! return "xx"; ! } ! public abstract string AbstractMethod(); ! ! protected internal virtual string ProtectedInternalMethod() ! { ! return "xx"; ! } // cannot override ! public static string StaticMethod() ! { ! return "xx"; ! } ! ! public string NonVirtualMethod() ! { ! return "xx"; ! } ! ! internal string NonVirtualInternalMethod() ! { ! return "xx"; ! } ! ! private string privateMethod() ! { ! return "xx"; ! } ! ! protected virtual string protectedMethod() ! { ! return "xx"; ! } ! ! private string defaultInternalMethod() ! { ! return "xx"; ! } ! ! public override string ToString() ! { ! return "xx"; ! } // method is ignored // implemented interface members/methods are defined as final (ie. non-virtual) *************** *** 80,109 **** } ! public class ClassWithInternalMethod { ! internal virtual string InternalMethod() { return "xx"; } } ! public enum MyEnum { ! A, B, C, D } ! public class ConcreteThing { ! public virtual void NoArgs() { Assertion.Fail("Should have been overriden"); } } #endregion ! [TestFixture] public class ClassGeneratorInvocationHandlerTest { ! public class InvocationHandlerImpl : IInvocationHandler { public string expectedMethodName; public bool wasCalled = false; ! public object Invoke(string methodName, params object[] args) { ! Assertion.AssertEquals("should be method name", expectedMethodName, methodName); ! Assertion.AssertEquals("Should be no args", 0, args.Length); wasCalled = true; return null; --- 126,167 ---- } ! public class ClassWithInternalMethod { ! internal virtual string InternalMethod() ! { ! return "xx"; ! } } ! public enum MyEnum { ! A, ! B, ! C, ! D } ! ! public class ConcreteThing { ! public virtual void NoArgs() ! { ! Assert.Fail("Should have been overriden"); ! } } + #endregion ! [TestFixture] ! public class ClassGeneratorInvocationHandlerTest { ! public class InvocationHandlerImpl : IInvocationHandler { public string expectedMethodName; public bool wasCalled = false; ! public object Invoke(string methodName, params object[] args) { ! Assert.AreEqual(expectedMethodName, methodName, "should be method name"); ! Assert.AreEqual(0, args.Length, "Should be no args"); wasCalled = true; return null; *************** *** 111,142 **** } ! [Test] public void CreateGenericProxy() { InvocationHandlerImpl handler = new InvocationHandlerImpl(); ! ClassGenerator cg = new ClassGenerator(typeof(IThingy), handler); ! IThingy thingy = (IThingy)cg.Generate(); ! handler.expectedMethodName = "NoArgs"; thingy.NoArgs(); ! Assertion.Assert("Should have been called ", handler.wasCalled); } } ! [TestFixture] public class ClassGeneratorTest { private ClassGenerator cg; private IMock mock; private IThingy thingy; ! ! [SetUp] public void SetUp() { mock = new Mock("Test Mock"); ! cg = new ClassGenerator(typeof(IThingy), mock); ! thingy = (IThingy)cg.Generate(); } ! [Test] public void CallMethodIsCalled() { mock.Expect("NoArgs"); --- 169,204 ---- } ! [Test] ! public void CreateGenericProxy() { InvocationHandlerImpl handler = new InvocationHandlerImpl(); ! ClassGenerator cg = new ClassGenerator(typeof (IThingy), handler); ! IThingy thingy = (IThingy) cg.Generate(); ! handler.expectedMethodName = "NoArgs"; thingy.NoArgs(); ! Assert.IsTrue(handler.wasCalled, "Should have been called "); } } ! [TestFixture] ! public class ClassGeneratorTest { private ClassGenerator cg; private IMock mock; private IThingy thingy; ! ! [SetUp] ! public void SetUp() { mock = new Mock("Test Mock"); ! cg = new ClassGenerator(typeof (IThingy), mock); ! thingy = (IThingy) cg.Generate(); } ! [Test] ! public void CallMethodIsCalled() { mock.Expect("NoArgs"); *************** *** 145,228 **** } ! [Test] public void CallMethodWithReturn() { object x = "sdfs"; mock.ExpectAndReturn("simpleReturn", x); object result = thingy.simpleReturn(); ! Assertion.AssertEquals(x, result); mock.Verify(); } ! [Test] public void CallMethodWithReturnAndCast() { string x = "sdfs"; mock.ExpectAndReturn("stringReturn", x); string result = thingy.stringReturn(); ! Assertion.AssertEquals(x, result); mock.Verify(); } ! [Test] public void CallMethodWithWeirdObjectReturn() { IThingy t = thingy; mock.ExpectAndReturn("AThingy", t); IThingy result = thingy.AThingy(); ! Assertion.AssertEquals(thingy, result); mock.Verify(); } ! [Test] public void CallMethodWithReturnInt() { mock.ExpectAndReturn("intReturn", 7); int result = thingy.intReturn(); ! Assertion.AssertEquals(7, result); mock.Verify(); } ! [Test] public void CallMethodWithReturnBoxings() { mock.ExpectAndReturn("boolReturn", true); mock.ExpectAndReturn("doubleReturn", 1234567891234E+10); ! Assertion.Assert(thingy.boolReturn()); ! Assertion.AssertEquals(1234567891234E+10, thingy.doubleReturn()); mock.Verify(); } ! [Test] ! public void CallMethodWithReturnDecimal() ! { ! decimal d = new decimal(3); ! mock.ExpectAndReturn("decimalReturn", d); ! decimal result = thingy.decimalReturn(); ! Assertion.AssertEquals(new decimal(3), result); ! mock.Verify(); ! } ! ! [Test] ! public void CallMethodWithStruct() ! { ! MyStruct str = new MyStruct(); ! str.x = 3; ! mock.ExpectAndReturn("structReturn", str); ! MyStruct result = thingy.structReturn(); ! Assertion.AssertEquals(str, result); ! mock.Verify(); ! } ! ! [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))] public void CallMethodTheThrowsException() { ! mock.ExpectAndThrow("boolReturn", new System.IO.IOException()); thingy.boolReturn(); } ! [Test] public void CallMethodWithStringParameterExpectation() { mock.Expect("WithSimpleArg", new StartsWith("he")); --- 207,298 ---- } ! [Test] ! public void CallMethodWithReturn() { object x = "sdfs"; mock.ExpectAndReturn("simpleReturn", x); object result = thingy.simpleReturn(); ! Assert.AreEqual(x, result); mock.Verify(); } ! [Test] ! public void CallMethodWithReturnAndCast() { string x = "sdfs"; mock.ExpectAndReturn("stringReturn", x); string result = thingy.stringReturn(); ! Assert.AreEqual(x, result); mock.Verify(); } ! [Test] ! public void CallMethodWithWeirdObjectReturn() { IThingy t = thingy; mock.ExpectAndReturn("AThingy", t); IThingy result = thingy.AThingy(); ! Assert.AreEqual(thingy, result); mock.Verify(); } ! [Test] ! public void CallMethodWithReturnInt() { mock.ExpectAndReturn("intReturn", 7); int result = thingy.intReturn(); ! Assert.AreEqual(7, result); mock.Verify(); } ! [Test] ! public void CallMethodWithReturnBoxings() { mock.ExpectAndReturn("boolReturn", true); mock.ExpectAndReturn("doubleReturn", 1234567891234E+10); ! Assert.IsTrue(thingy.boolReturn()); ! Assert.AreEqual(1234567891234E+10, thingy.doubleReturn()); mock.Verify(); } ! [Test] ! public void CallMethodWithReturnDecimal() ! { ! decimal d = new decimal(3); ! mock.ExpectAndReturn("decimalReturn", d); ! decimal result = thingy.decimalReturn(); ! Assert.AreEqual(new decimal(3), result); ! mock.Verify(); ! } ! ! [Test] ! public void CallMethodWithStruct() ! { ! MyStruct str = new MyStruct(); ! str.x = 3; ! mock.ExpectAndReturn("structReturn", str); ! MyStruct result = thingy.structReturn(); ! Assert.AreEqual(str, result); ! mock.Verify(); ! } ! ! [Test] ! public void CallMethodWithReturnEnum() { mock.ExpectAndReturn("getEnum", MyEnum.C); MyEnum result = thingy.getEnum(); ! Assert.AreEqual(MyEnum.C, result); mock.Verify(); } ! ! [Test, ExpectedException(typeof (IOException))] ! public void CallMethodTheThrowsException() { ! mock.ExpectAndThrow("boolReturn", new IOException()); thingy.boolReturn(); } ! [Test] ! public void CallMethodWithStringParameterExpectation() { mock.Expect("WithSimpleArg", new StartsWith("he")); *************** *** 230,235 **** mock.Verify(); } ! ! [Test] public void CallMethodWithStringParameter() { mock.Expect("WithSimpleArg", "hello"); --- 300,306 ---- mock.Verify(); } ! ! [Test] ! public void CallMethodWithStringParameter() { mock.Expect("WithSimpleArg", "hello"); *************** *** 238,248 **** } ! [Test] public void CallMethodWithIntParameter() { mock.Expect("WithIntParam", 1); thingy.WithIntParam(1); mock.Verify(); ! } ! [Test] [ExpectedException(typeof(VerifyException))] public void CallMethodWithParamExpectationsThatFails() { mock.Expect("WithSimpleArg", new IsEqual("hello")); --- 309,322 ---- } ! [Test] ! public void CallMethodWithIntParameter() { mock.Expect("WithIntParam", 1); thingy.WithIntParam(1); mock.Verify(); ! } ! ! [Test, ExpectedException(typeof (VerifyException))] ! public void CallMethodWithParamExpectationsThatFails() { mock.Expect("WithSimpleArg", new IsEqual("hello")); *************** *** 250,255 **** mock.Verify(); } ! ! [Test] public void CallMethodWithTwoParamExpectations() { mock.Expect("WithTwoArgs", new IsEqual("hello"), new IsEqual("world")); --- 324,330 ---- mock.Verify(); } ! ! [Test] ! public void CallMethodWithTwoParamExpectations() { mock.Expect("WithTwoArgs", new IsEqual("hello"), new IsEqual("world")); *************** *** 257,262 **** mock.Verify(); } ! ! [Test] [ExpectedException(typeof(VerifyException))] public void CallMethodWithTwoParamExpectationsThatFails() { mock.Expect("WithTwoArgs", new IsEqual("hello"), new IsEqual("world")); --- 332,338 ---- mock.Verify(); } ! ! [Test, ExpectedException(typeof (VerifyException))] ! public void CallMethodWithTwoParamExpectationsThatFails() { mock.Expect("WithTwoArgs", new IsEqual("hello"), new IsEqual("world")); *************** *** 264,269 **** mock.Verify(); } ! ! [Test] public void CallMethodWithThreeParamExpectations() { mock.Expect("WithThreeArgs", new IsEqual("hello"), new IsEqual("the"), new IsEqual("world")); --- 340,346 ---- mock.Verify(); } ! ! [Test] ! public void CallMethodWithThreeParamExpectations() { mock.Expect("WithThreeArgs", new IsEqual("hello"), new IsEqual("the"), new IsEqual("world")); *************** *** 271,276 **** mock.Verify(); } ! ! [Test] public void CallMethodWithLotsOfArgsExpectations() { mock.Expect("WithLotsOfArgs", new IsEqual("hello"), new IsEqual("world"), new IsEqual("is"), new IsEqual("this"), new IsEqual("the"), new IsEqual("end")); --- 348,354 ---- mock.Verify(); } ! ! [Test] ! public void CallMethodWithLotsOfArgsExpectations() { mock.Expect("WithLotsOfArgs", new IsEqual("hello"), new IsEqual("world"), new IsEqual("is"), new IsEqual("this"), new IsEqual("the"), new IsEqual("end")); *************** *** 279,283 **** } ! [Test] public void CallMethodWithOtherArgs() { IList l = new ArrayList(); --- 357,362 ---- } ! [Test] ! public void CallMethodWithOtherArgs() { IList l = new ArrayList(); *************** *** 286,296 **** mock.Verify(); } ! [Test] public void CallMethodWithVariableNumberOfParams() { ! mock.Expect("WithParams", 1, new object[]{"string1", "string2"}); thingy.WithParams(1, "string1", "string2"); mock.Verify(); } ! [Test] public void CallMethodWithLongParam() { mock.Expect("WithLongParam", 5L); --- 365,379 ---- mock.Verify(); } ! ! [Test] ! public void CallMethodWithVariableNumberOfParams() { ! mock.Expect("WithParams", 1, new object[] {"string1", "string2"}); thingy.WithParams(1, "string1", "string2"); mock.Verify(); } ! ! [Test] ! public void CallMethodWithLongParam() { mock.Expect("WithLongParam", 5L); *************** *** 299,312 **** } ! [Test] public void CallReadOnlyProperty() { mock.ExpectAndReturn("ReadProperty", "hello"); mock.ExpectAndReturn("ReadProperty", "world"); ! Assertion.AssertEquals("hello", thingy.ReadProperty); ! Assertion.AssertEquals("world", thingy.ReadProperty); mock.Verify(); } ! [Test] public void WriteOnlyPropertyExpectations() { mock.Expect("WriteProperty", "hello"); --- 382,397 ---- } ! [Test] ! public void CallReadOnlyProperty() { mock.ExpectAndReturn("ReadProperty", "hello"); mock.ExpectAndReturn("ReadProperty", "world"); ! Assert.AreEqual("hello", thingy.ReadProperty); ! Assert.AreEqual("world", thingy.ReadProperty); mock.Verify(); } ! [Test] ! public void WriteOnlyPropertyExpectations() { mock.Expect("WriteProperty", "hello"); *************** *** 317,321 **** } ! [Test] public void ReadAndWriteProperty() { mock.Expect("AProperty", "hello"); --- 402,407 ---- } ! [Test] ! public void ReadAndWriteProperty() { mock.Expect("AProperty", "hello"); *************** *** 325,337 **** thingy.AProperty = "hello"; thingy.AProperty = "world"; ! Assertion.AssertEquals("good", thingy.AProperty); ! Assertion.AssertEquals("bye", thingy.AProperty); mock.Verify(); } ! [Test] public void CanExtendAbstractClass() { ! cg = new ClassGenerator(typeof(AbstractThingy), mock); ! AbstractThingy s = (AbstractThingy)cg.Generate(); mock.ExpectAndReturn("VirtualMethod", "hello"); --- 411,424 ---- thingy.AProperty = "hello"; thingy.AProperty = "world"; ! Assert.AreEqual("good", thingy.AProperty); ! Assert.AreEqual("bye", thingy.AProperty); mock.Verify(); } ! [Test] ! public void CanExtendAbstractClass() { ! cg = new ClassGenerator(typeof (AbstractThingy), mock); ! AbstractThingy s = (AbstractThingy) cg.Generate(); mock.ExpectAndReturn("VirtualMethod", "hello"); *************** *** 340,371 **** mock.ExpectAndReturn("ProtectedInternalMethod", "white"); ! Assertion.AssertEquals("hello", s.VirtualMethod()); ! Assertion.AssertEquals(123, s.GetHashCode()); ! Assertion.AssertEquals("fish", s.AbstractMethod()); ! Assertion.AssertEquals("white", s.ProtectedInternalMethod()); mock.Verify(); } ! ! [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)] ); } ! [Test] public void CanExtendConcreteClass() { ! ConcreteThing concrete = (ConcreteThing)(new ClassGenerator(typeof(ConcreteThing), mock)).Generate(); mock.Expect("NoArgs"); --- 427,461 ---- mock.ExpectAndReturn("ProtectedInternalMethod", "white"); ! Assert.AreEqual("hello", s.VirtualMethod()); ! Assert.AreEqual(123, s.GetHashCode()); ! Assert.AreEqual("fish", s.AbstractMethod()); ! Assert.AreEqual("white", s.ProtectedInternalMethod()); mock.Verify(); } ! ! [Test] ! public void CheckBoxingOpCodes() { BoxingOpCodes opCodes = new BoxingOpCodes(); ! Assert.AreEqual(OpCodes.Ldind_I1, opCodes[typeof (sbyte)]); ! Assert.AreEqual(OpCodes.Ldind_I2, opCodes[typeof (short)]); ! Assert.AreEqual(OpCodes.Ldind_I4, opCodes[typeof (int)]); ! Assert.AreEqual(OpCodes.Ldind_I8, opCodes[typeof (long)]); ! Assert.AreEqual(OpCodes.Ldind_U1, opCodes[typeof (byte)]); ! Assert.AreEqual(OpCodes.Ldind_U2, opCodes[typeof (ushort)]); ! Assert.AreEqual(OpCodes.Ldind_U4, opCodes[typeof (uint)]); ! Assert.AreEqual(OpCodes.Ldind_I8, opCodes[typeof (ulong)]); ! Assert.AreEqual(OpCodes.Ldind_R4, opCodes[typeof (float)]); ! Assert.AreEqual(OpCodes.Ldind_R8, opCodes[typeof (double)]); ! Assert.AreEqual(OpCodes.Ldind_U2, opCodes[typeof (char)]); ! Assert.AreEqual(OpCodes.Ldind_I1, opCodes[typeof (bool)]); } ! ! [Test] ! public void CanExtendConcreteClass() { ! ConcreteThing concrete = (ConcreteThing) (new ClassGenerator(typeof (ConcreteThing), mock)).Generate(); mock.Expect("NoArgs"); *************** *** 375,417 **** // Limitations ! [Test] public void CannotOverrideNonVirtualFeatures() { ! cg = new ClassGenerator(typeof(AbstractThingy), mock); ! AbstractThingy s = (AbstractThingy)cg.Generate(); mock.SetupResult("NonVirtualMethod", "non virtual method"); mock.SetupResult("NonVirtualProperty", "non virtual property"); ! Assertion.AssertEquals("xx", s.NonVirtualMethod()); ! Assertion.AssertEquals("xx", s.NonVirtualProperty); mock.Verify(); } ! [Test] public void DoesNotOverrideToString() { ! cg = new ClassGenerator(typeof(AbstractThingy), mock); ! AbstractThingy s = (AbstractThingy)cg.Generate(); mock.SetupResult("ToString", "to string"); ! Assertion.AssertEquals("xx", s.ToString()); mock.Verify(); } ! [Test] public void IgnoresInternalMethodsBecauseOfAssemblyVisibility() { ArrayList methodsToIgnore = new ArrayList(); ! new ClassGenerator(typeof(ClassWithInternalMethod), mock, methodsToIgnore).Generate(); ! Assertion.Assert("Should include InternalMethod", methodsToIgnore.Contains("InternalMethod")); } ! ! [Test] public void OnlyOneAssemblyIsCreated() { ! cg = new ClassGenerator(typeof(IThingy), mock); cg.Generate(); int originalAssemblyCount = AppDomain.CurrentDomain.GetAssemblies().Length; ! cg = new ClassGenerator(typeof(ConcreteThing), mock); cg.Generate(); --- 465,511 ---- // Limitations ! [Test] ! public void CannotOverrideNonVirtualFeatures() { ! cg = new ClassGenerator(typeof (AbstractThingy), mock); ! AbstractThingy s = (AbstractThingy) cg.Generate(); mock.SetupResult("NonVirtualMethod", "non virtual method"); mock.SetupResult("NonVirtualProperty", "non virtual property"); ! Assert.AreEqual("xx", s.NonVirtualMethod()); ! Assert.AreEqual("xx", s.NonVirtualProperty); mock.Verify(); } ! [Test] ! public void DoesNotOverrideToString() { ! cg = new ClassGenerator(typeof (AbstractThingy), mock); ! AbstractThingy s = (AbstractThingy) cg.Generate(); mock.SetupResult("ToString", "to string"); ! Assert.AreEqual("xx", s.ToString()); mock.Verify(); } ! [Test] ! public void IgnoresInternalMethodsBecauseOfAssemblyVisibility() { ArrayList methodsToIgnore = new ArrayList(); ! new ClassGenerator(typeof (ClassWithInternalMethod), mock, methodsToIgnore).Generate(); ! Assert.IsTrue(methodsToIgnore.Contains("InternalMethod"), "Should include InternalMethod"); } ! ! [Test] ! public void OnlyOneAssemblyIsCreated() { ! cg = new ClassGenerator(typeof (IThingy), mock); cg.Generate(); int originalAssemblyCount = AppDomain.CurrentDomain.GetAssemblies().Length; ! cg = new ClassGenerator(typeof (ConcreteThing), mock); cg.Generate(); *************** *** 419,432 **** } ! [Test] public void MockTypesAreReused() { ! cg = new ClassGenerator(typeof(Exception), mock); cg.Generate(); Assembly mockAssembly = null; ! foreach(Assembly ass in AppDomain.CurrentDomain.GetAssemblies()) { ! if(ass.GetName().Name == "DynamicProxyAssembly") { mockAssembly = ass; --- 513,527 ---- } ! [Test] ! public void MockTypesAreReused() { ! cg = new ClassGenerator(typeof (Exception), mock); cg.Generate(); Assembly mockAssembly = null; ! foreach (Assembly ass in AppDomain.CurrentDomain.GetAssemblies()) { ! if (ass.GetName().Name == "DynamicProxyAssembly") { mockAssembly = ass; *************** *** 438,442 **** int originalTypeCount = mockAssembly.GetTypes().Length; ! cg = new ClassGenerator(typeof(Exception), mock); cg.Generate(); --- 533,537 ---- int originalTypeCount = mockAssembly.GetTypes().Length; ! cg = new ClassGenerator(typeof (Exception), mock); cg.Generate(); *************** *** 444,446 **** } } ! } --- 539,541 ---- } } ! } \ No newline at end of file Index: InterfaceListerTest.cs =================================================================== RCS file: /cvsroot/nmock/nmock/test/NMock/Dynamic/InterfaceListerTest.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** InterfaceListerTest.cs 1 Jun 2003 09:48:50 -0000 1.1 --- InterfaceListerTest.cs 22 Oct 2004 11:46:27 -0000 1.2 *************** *** 174,178 **** actualString.Append(","); } ! Assertion.AssertEquals(expectedString.ToString(), actualString.ToString()); } --- 174,178 ---- actualString.Append(","); } ! Assert.AreEqual(expectedString.ToString(), actualString.ToString()); } |
From: Owen Rogers <exortech@us...> - 2004-10-22 11:47:08
|
Update of /cvsroot/nmock/nmock/test/NMock/Remoting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19470/test/NMock/Remoting Modified Files: RemotingMockTest.cs Log Message: upgraded to nunit 2.2 upgraded to new version of NAnt Index: RemotingMockTest.cs =================================================================== RCS file: /cvsroot/nmock/nmock/test/NMock/Remoting/RemotingMockTest.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RemotingMockTest.cs 13 Jul 2003 13:27:07 -0000 1.1 --- RemotingMockTest.cs 22 Oct 2004 11:46:28 -0000 1.2 *************** *** 6,10 **** { [TestFixture] ! public class RemotingMockTest : Assertion { [Test] --- 6,10 ---- { [TestFixture] ! public class RemotingMockTest { [Test] *************** *** 13,17 **** RemotingMock mock = new RemotingMock(typeof(Base)); MarshalByRefObject instance = mock.MarshalByRefInstance; ! AssertNotNull(instance); } --- 13,17 ---- RemotingMock mock = new RemotingMock(typeof(Base)); MarshalByRefObject instance = mock.MarshalByRefInstance; ! Assert.IsNotNull(instance); } |
From: Owen Rogers <exortech@us...> - 2004-10-22 11:47:07
|
Update of /cvsroot/nmock/nmock In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19470 Modified Files: nmock.build Log Message: upgraded to nunit 2.2 upgraded to new version of NAnt Index: nmock.build =================================================================== RCS file: /cvsroot/nmock/nmock/nmock.build,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** nmock.build 14 Jun 2004 17:54:45 -0000 1.9 --- nmock.build 22 Oct 2004 11:46:26 -0000 1.10 *************** *** 16,20 **** <csc target="library" output="build/nmock.dll" debug="true"> <sources> ! <includes name="src/**.cs"/> </sources> </csc> --- 16,20 ---- <csc target="library" output="build/nmock.dll" debug="true"> <sources> ! <include name="src/**.cs"/> </sources> </csc> *************** *** 24,33 **** <csc target="library" output="build/nmock.test.dll" debug="true"> <sources> ! <includes name="test/**.cs"/> ! <includes name="sample/**.cs"/> </sources> <references> ! <includes name="build/nmock.dll"/> ! <includes name="lib/*.dll"/> </references> <arg value="/nowarn:0679,1591"/> --- 24,33 ---- <csc target="library" output="build/nmock.test.dll" debug="true"> <sources> ! <include name="test/**.cs"/> ! <include name="sample/**.cs"/> </sources> <references> ! <include name="build/nmock.dll"/> ! <include name="lib/*.dll"/> </references> <arg value="/nowarn:0679,1591"/> *************** *** 56,60 **** <csc target="library" output="dist/nmock.dll" debug="false"> <sources> ! <includes name="src/**.cs"/> </sources> </csc> --- 56,60 ---- <csc target="library" output="dist/nmock.dll" debug="false"> <sources> ! <include name="src/**.cs"/> </sources> </csc> |
From: Owen Rogers <exortech@us...> - 2004-10-22 11:47:07
|
Update of /cvsroot/nmock/nmock/sample/random In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19470/sample/random Modified Files: WeatherTest.cs Log Message: upgraded to nunit 2.2 upgraded to new version of NAnt Index: WeatherTest.cs =================================================================== RCS file: /cvsroot/nmock/nmock/sample/random/WeatherTest.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WeatherTest.cs 15 Nov 2002 22:31:10 -0000 1.2 --- WeatherTest.cs 22 Oct 2004 11:46:26 -0000 1.3 *************** *** 1,58 **** - using NUnit.Framework; using NMock; ! namespace NMockSample.Random { - [TestFixture] public class WeatherTest { - private IMock random; private Weather weather; ! [SetUp] ! public void SetUp() { ! random = new DynamicMock(typeof(WeatherRandom)); ! weather = new Weather((WeatherRandom)random.MockInstance); } ! ! [Test] ! public void RandomRaining() { random.SetupResult("NextTemperature", 1.0); random.SetupResult("NextIsRaining", true); weather.Randomize(); ! Assertion.Assert("is raining", weather.IsRaining); } ! ! [Test] ! public void RandomNotRaining() { random.SetupResult("NextTemperature", 1.0); random.SetupResult("NextIsRaining", false); weather.Randomize(); ! Assertion.Assert("is not raining", !weather.IsRaining); } ! [Test] ! public void RandomTemperatureSunny() ! { double TEMPERATURE = 20.0; random.SetupResult("NextTemperature", TEMPERATURE); random.SetupResult("NextIsRaining", false); weather.Randomize(); ! Assertion.AssertEquals("temperature", TEMPERATURE, weather.Temperature); } [Test] ! public void RandomTemperatureRaining() ! { double TEMPERATURE = 20.0; random.SetupResult("NextTemperature", TEMPERATURE); random.SetupResult("NextIsRaining", true); weather.Randomize(); ! Assertion.AssertEquals("temperature", TEMPERATURE / 2.0, weather.Temperature); } --- 1,56 ---- using NMock; + using NUnit.Framework; ! namespace NMockSample.Random { [TestFixture] public class WeatherTest { private IMock random; private Weather weather; ! [SetUp] ! public void SetUp() { ! random = new DynamicMock(typeof (WeatherRandom)); ! weather = new Weather((WeatherRandom) random.MockInstance); } ! ! [Test] ! public void RandomRaining() { random.SetupResult("NextTemperature", 1.0); random.SetupResult("NextIsRaining", true); weather.Randomize(); ! Assert.IsTrue(weather.IsRaining, "is raining"); } ! ! [Test] ! public void RandomNotRaining() { random.SetupResult("NextTemperature", 1.0); random.SetupResult("NextIsRaining", false); weather.Randomize(); ! Assert.IsTrue(!weather.IsRaining, "is not raining"); } ! [Test] ! public void RandomTemperatureSunny() ! { double TEMPERATURE = 20.0; random.SetupResult("NextTemperature", TEMPERATURE); random.SetupResult("NextIsRaining", false); weather.Randomize(); ! Assert.AreEqual(TEMPERATURE, weather.Temperature, "temperature"); } [Test] ! public void RandomTemperatureRaining() ! { double TEMPERATURE = 20.0; random.SetupResult("NextTemperature", TEMPERATURE); random.SetupResult("NextIsRaining", true); weather.Randomize(); ! Assert.AreEqual(TEMPERATURE/2.0, weather.Temperature, "temperature"); } *************** *** 62,107 **** public class DefaultWeatherRandomTest { - [Test] public void NextIsRaining() { ! IMock random = new DynamicMock(typeof(System.Random)); ! WeatherRandom weather = new DefaultWeatherRandom((System.Random)random.MockInstance); ! random.SetupResult("NextDouble", 0.0); ! Assertion.Assert("is raining", weather.NextIsRaining()); ! random.SetupResult("NextDouble", DefaultWeatherRandom.CHANCE_OF_RAIN); ! Assertion.Assert("is not raining", !weather.NextIsRaining()); ! random.SetupResult("NextDouble", 1.0); ! Assertion.Assert("is not raining", !weather.NextIsRaining()); } ! [Test] public void NextTemperature() { ! IMock random = new DynamicMock(typeof(System.Random)); ! WeatherRandom weather = new DefaultWeatherRandom((System.Random)random.MockInstance); ! random.SetupResult("NextDouble", 0.0); ! Assertion.AssertEquals("should be min temperature", DefaultWeatherRandom.MIN_TEMPERATURE, ! weather.NextTemperature() ! ); ! random.SetupResult("NextDouble", 0.5); ! Assertion.AssertEquals("should be average temperature", ! 0.5 * (DefaultWeatherRandom.MIN_TEMPERATURE + DefaultWeatherRandom.MAX_TEMPERATURE), ! weather.NextTemperature() ! ); ! random.SetupResult("NextDouble", 1.0); ! Assertion.AssertEquals("should be max temperature", ! DefaultWeatherRandom.MAX_TEMPERATURE, ! weather.NextTemperature() ! ); } ! } ! } --- 60,104 ---- public class DefaultWeatherRandomTest { [Test] public void NextIsRaining() { ! IMock random = new DynamicMock(typeof (System.Random)); ! WeatherRandom weather = new DefaultWeatherRandom((System.Random) random.MockInstance); ! random.SetupResult("NextDouble", 0.0); ! Assert.IsTrue(weather.NextIsRaining(), "is raining"); ! random.SetupResult("NextDouble", DefaultWeatherRandom.CHANCE_OF_RAIN); ! Assert.IsTrue(!weather.NextIsRaining(), "is not raining"); ! random.SetupResult("NextDouble", 1.0); ! Assert.IsTrue(!weather.NextIsRaining(), "is not raining"); } ! [Test] public void NextTemperature() { ! IMock random = new DynamicMock(typeof (System.Random)); ! WeatherRandom weather = new DefaultWeatherRandom((System.Random) random.MockInstance); ! random.SetupResult("NextDouble", 0.0); ! Assert.AreEqual( DefaultWeatherRandom.MIN_TEMPERATURE, ! weather.NextTemperature(), "should be min temperature" ! ); ! random.SetupResult("NextDouble", 0.5); ! Assert.AreEqual( ! 0.5*(DefaultWeatherRandom.MIN_TEMPERATURE + DefaultWeatherRandom.MAX_TEMPERATURE), ! weather.NextTemperature(), "should be average temperature" ! ); ! random.SetupResult("NextDouble", 1.0); ! Assert.AreEqual( ! DefaultWeatherRandom.MAX_TEMPERATURE, ! weather.NextTemperature(), "should be max temperature" ! ); } ! } ! } \ No newline at end of file |
From: Owen Rogers <exortech@us...> - 2004-10-22 11:47:07
|
Update of /cvsroot/nmock/nmock/test/NMock/Constraints In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19470/test/NMock/Constraints Modified Files: ConstraintsTest.cs IsArrayEqualTest.cs Log Message: upgraded to nunit 2.2 upgraded to new version of NAnt Index: ConstraintsTest.cs =================================================================== RCS file: /cvsroot/nmock/nmock/test/NMock/Constraints/ConstraintsTest.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ConstraintsTest.cs 24 Jul 2003 23:09:05 -0000 1.6 --- ConstraintsTest.cs 22 Oct 2004 11:46:26 -0000 1.7 *************** *** 1,5 **** ! using NUnit.Framework; using System.Text.RegularExpressions; ! using System.Collections; namespace NMock.Constraints { --- 1,7 ---- ! using System; ! using System.IO; using System.Text.RegularExpressions; ! using NUnit.Framework; ! namespace NMock.Constraints { *************** *** 15,23 **** { c = new IsNull(); ! Assertion.Assert(c.Eval(null)); ! Assertion.Assert(!c.Eval(new object())); ! Assertion.Assert(!c.Eval(1)); ! Assertion.Assert(!c.Eval(true)); ! Assertion.Assert(!c.Eval(false)); } --- 17,25 ---- { c = new IsNull(); ! Assert.IsTrue(c.Eval(null)); ! Assert.IsTrue(!c.Eval(new object())); ! Assert.IsTrue(!c.Eval(1)); ! Assert.IsTrue(!c.Eval(true)); ! Assert.IsTrue(!c.Eval(false)); } *************** *** 26,31 **** { c = new NotNull(); ! Assertion.Assert(!c.Eval(null)); ! Assertion.Assert(c.Eval(new object())); } --- 28,33 ---- { c = new NotNull(); ! Assert.IsTrue(!c.Eval(null)); ! Assert.IsTrue(c.Eval(new object())); } *************** *** 36,50 **** object o2 = new object(); c = new IsEqual(o1); ! Assertion.Assert(c.Eval(o1)); ! Assertion.Assert(!c.Eval(o2)); ! Assertion.Assert(!c.Eval(null)); int i1 = 1; int i2 = 2; c = new IsEqual(i1); ! Assertion.Assert(c.Eval(i1)); ! Assertion.Assert(c.Eval(1)); ! Assertion.Assert(!c.Eval(i2)); ! Assertion.Assert(!c.Eval(2)); } --- 38,52 ---- object o2 = new object(); c = new IsEqual(o1); ! Assert.IsTrue(c.Eval(o1)); ! Assert.IsTrue(!c.Eval(o2)); ! Assert.IsTrue(!c.Eval(null)); int i1 = 1; int i2 = 2; c = new IsEqual(i1); ! Assert.IsTrue(c.Eval(i1)); ! Assert.IsTrue(c.Eval(1)); ! Assert.IsTrue(!c.Eval(i2)); ! Assert.IsTrue(!c.Eval(2)); } *************** *** 56,62 **** c = new IsEqual(new object[] { 1, 2, 3 }); ! Assertion.Assert("should be equal", c.Eval(o1)); ! Assertion.Assert("shouldn't be equal", !c.Eval(o2)); ! Assertion.Assert("it ain't null", !c.Eval(null)); } --- 58,64 ---- c = new IsEqual(new object[] { 1, 2, 3 }); ! Assert.IsTrue(c.Eval(o1), "should be equal"); ! Assert.IsTrue(!c.Eval(o2), "shouldn't be equal"); ! Assert.IsTrue(!c.Eval(null), "it ain't null" ); } *************** *** 67,81 **** object o2 = new object(); c = new NotEqual(o1); ! Assertion.Assert(!c.Eval(o1)); ! Assertion.Assert(c.Eval(o2)); ! Assertion.Assert(c.Eval(null)); int i1 = 1; int i2 = 2; c = new NotEqual(i1); ! Assertion.Assert(!c.Eval(i1)); ! Assertion.Assert(!c.Eval(1)); ! Assertion.Assert(c.Eval(i2)); ! Assertion.Assert(c.Eval(2)); } --- 69,83 ---- object o2 = new object(); c = new NotEqual(o1); ! Assert.IsTrue(!c.Eval(o1)); ! Assert.IsTrue(c.Eval(o2)); ! Assert.IsTrue(c.Eval(null)); int i1 = 1; int i2 = 2; c = new NotEqual(i1); ! Assert.IsTrue(!c.Eval(i1)); ! Assert.IsTrue(!c.Eval(1)); ! Assert.IsTrue(c.Eval(i2)); ! Assert.IsTrue(c.Eval(2)); } *************** *** 84,96 **** { c = new IsAnything(); ! Assertion.Assert(c.Eval(null)); ! Assertion.Assert(c.Eval(0)); ! Assertion.Assert(c.Eval(99)); ! Assertion.Assert(c.Eval(-2)); ! Assertion.Assert(c.Eval(true)); ! Assertion.Assert(c.Eval(false)); ! Assertion.Assert(c.Eval("")); ! Assertion.Assert(c.Eval("hello")); ! Assertion.Assert(c.Eval(new object())); } --- 86,98 ---- { c = new IsAnything(); ! Assert.IsTrue(c.Eval(null)); ! Assert.IsTrue(c.Eval(0)); ! Assert.IsTrue(c.Eval(99)); ! Assert.IsTrue(c.Eval(-2)); ! Assert.IsTrue(c.Eval(true)); ! Assert.IsTrue(c.Eval(false)); ! Assert.IsTrue(c.Eval("")); ! Assert.IsTrue(c.Eval("hello")); ! Assert.IsTrue(c.Eval(new object())); } *************** *** 98,105 **** public void IsType() { ! c = new IsTypeOf(typeof(System.IO.TextReader)); ! Assertion.Assert(!c.Eval(null)); ! Assertion.Assert(c.Eval(new System.IO.StringReader(""))); ! Assertion.Assert(!c.Eval(new System.IO.StringWriter())); } --- 100,107 ---- public void IsType() { ! c = new IsTypeOf(typeof(TextReader)); ! Assert.IsTrue(!c.Eval(null)); ! Assert.IsTrue(c.Eval(new StringReader(""))); ! Assert.IsTrue(!c.Eval(new StringWriter())); } *************** *** 107,112 **** public void Not() { ! Assertion.Assert(new Not(new False()).Eval(null)); ! Assertion.Assert(!new Not(new True()).Eval(null)); } --- 109,114 ---- public void Not() { ! Assert.IsTrue(new Not(new False()).Eval(null)); ! Assert.IsTrue(!new Not(new True()).Eval(null)); } *************** *** 114,121 **** public void And() { ! Assertion.Assert( new And(new True() , new True() ).Eval(null)); ! Assertion.Assert(!new And(new True() , new False()).Eval(null)); ! Assertion.Assert(!new And(new False(), new True() ).Eval(null)); ! Assertion.Assert(!new And(new False(), new False()).Eval(null)); } --- 116,123 ---- public void And() { ! Assert.IsTrue( new And(new True() , new True() ).Eval(null)); ! Assert.IsTrue(!new And(new True() , new False()).Eval(null)); ! Assert.IsTrue(!new And(new False(), new True() ).Eval(null)); ! Assert.IsTrue(!new And(new False(), new False()).Eval(null)); } *************** *** 123,130 **** public void Or() { ! Assertion.Assert( new Or(new True() , new True() ).Eval(null)); ! Assertion.Assert( new Or(new True() , new False()).Eval(null)); ! Assertion.Assert( new Or(new False(), new True() ).Eval(null)); ! Assertion.Assert(!new Or(new False(), new False()).Eval(null)); } --- 125,132 ---- public void Or() { ! Assert.IsTrue( new Or(new True() , new True() ).Eval(null)); ! Assert.IsTrue( new Or(new True() , new False()).Eval(null)); ! Assert.IsTrue( new Or(new False(), new True() ).Eval(null)); ! Assert.IsTrue(!new Or(new False(), new False()).Eval(null)); } *************** *** 133,149 **** { c = new IsIn(2, 3, 5); ! Assertion.Assert(!c.Eval(1)); ! Assertion.Assert(c.Eval(2)); ! Assertion.Assert(c.Eval(3)); ! Assertion.Assert(!c.Eval(4)); ! Assertion.Assert(c.Eval(5)); ! Assertion.Assert(!c.Eval(6)); ! Assertion.Assert(!c.Eval(null)); int[] array = {1, 2}; c = new IsIn(array); ! Assertion.Assert(c.Eval(1)); ! Assertion.Assert(c.Eval(2)); ! Assertion.Assert(!c.Eval(3)); } --- 135,151 ---- { c = new IsIn(2, 3, 5); ! Assert.IsTrue(!c.Eval(1)); ! Assert.IsTrue(c.Eval(2)); ! Assert.IsTrue(c.Eval(3)); ! Assert.IsTrue(!c.Eval(4)); ! Assert.IsTrue(c.Eval(5)); ! Assert.IsTrue(!c.Eval(6)); ! Assert.IsTrue(!c.Eval(null)); int[] array = {1, 2}; c = new IsIn(array); ! Assert.IsTrue(c.Eval(1)); ! Assert.IsTrue(c.Eval(2)); ! Assert.IsTrue(!c.Eval(3)); } *************** *** 152,164 **** { c = new NotIn(1, 2); ! Assertion.Assert(!c.Eval(1)); ! Assertion.Assert(!c.Eval(2)); ! Assertion.Assert(c.Eval(3)); int[] array = {1, 2}; c = new NotIn(array); ! Assertion.Assert(!c.Eval(1)); ! Assertion.Assert(!c.Eval(2)); ! Assertion.Assert(c.Eval(3)); } --- 154,166 ---- { c = new NotIn(1, 2); ! Assert.IsTrue(!c.Eval(1)); ! Assert.IsTrue(!c.Eval(2)); ! Assert.IsTrue(c.Eval(3)); int[] array = {1, 2}; c = new NotIn(array); ! Assert.IsTrue(!c.Eval(1)); ! Assert.IsTrue(!c.Eval(2)); ! Assert.IsTrue(c.Eval(3)); } *************** *** 167,174 **** { c = new IsEqualIgnoreCase("heLLo"); ! Assertion.Assert(c.Eval("HELLO")); ! Assertion.Assert(c.Eval("hello")); ! Assertion.Assert(c.Eval("HelLo")); ! Assertion.Assert(!c.Eval("abcde")); } --- 169,176 ---- { c = new IsEqualIgnoreCase("heLLo"); ! Assert.IsTrue(c.Eval("HELLO")); ! Assert.IsTrue(c.Eval("hello")); ! Assert.IsTrue(c.Eval("HelLo")); ! Assert.IsTrue(!c.Eval("abcde")); } *************** *** 176,182 **** public void StripSpace() { ! Assertion.AssertEquals("Hello World", IsEqualIgnoreWhiteSpace.StripSpace("Hello\n \n World")); ! Assertion.AssertEquals("Hello World", IsEqualIgnoreWhiteSpace.StripSpace(" Hello World ")); ! Assertion.AssertEquals("", IsEqualIgnoreWhiteSpace.StripSpace(" ")); } --- 178,184 ---- public void StripSpace() { ! Assert.AreEqual("Hello World", IsEqualIgnoreWhiteSpace.StripSpace("Hello\n \n World")); ! Assert.AreEqual("Hello World", IsEqualIgnoreWhiteSpace.StripSpace(" Hello World ")); ! Assert.AreEqual("", IsEqualIgnoreWhiteSpace.StripSpace(" ")); } *************** *** 185,192 **** { c = new IsEqualIgnoreWhiteSpace("Hello World how\n are we?"); ! Assertion.Assert(c.Eval("Hello World how are we?")); ! Assertion.Assert(c.Eval(" Hello World how are \n\n\twe?")); ! Assertion.Assert(!c.Eval("HelloWorld how are we?")); ! Assertion.Assert(!c.Eval("Hello World how are we")); } --- 187,194 ---- { c = new IsEqualIgnoreWhiteSpace("Hello World how\n are we?"); ! Assert.IsTrue(c.Eval("Hello World how are we?")); ! Assert.IsTrue(c.Eval(" Hello World how are \n\n\twe?")); ! Assert.IsTrue(!c.Eval("HelloWorld how are we?")); ! Assert.IsTrue(!c.Eval("Hello World how are we")); } *************** *** 195,220 **** { c = new IsMatch(new Regex(@"^th[aeiou]\w* .*$")); ! Assertion.Assert(c.Eval("the world")); ! Assertion.Assert(!c.Eval("theworld")); ! Assertion.Assert(!c.Eval("ThE world")); ! Assertion.Assert(!c.Eval(" the world")); ! Assertion.Assert(c.Eval("thats nice")); ! Assertion.Assert(!c.Eval(new object())); ! Assertion.Assert(!c.Eval(null)); c = new IsMatch(@"^th[aeiou]\w* .*$"); ! Assertion.Assert(c.Eval("the world")); ! Assertion.Assert(!c.Eval("theworld")); ! Assertion.Assert(!c.Eval("ThE world")); c = new IsMatch(@"^th[aeiou]\w* .*$", false); ! Assertion.Assert(c.Eval("the world")); ! Assertion.Assert(!c.Eval("theworld")); ! Assertion.Assert(!c.Eval("ThE world")); c = new IsMatch(@"^th[aeiou]\w* .*$", true); ! Assertion.Assert(c.Eval("the world")); ! Assertion.Assert(!c.Eval("theworld")); ! Assertion.Assert(c.Eval("ThE world")); } --- 197,222 ---- { c = new IsMatch(new Regex(@"^th[aeiou]\w* .*$")); ! Assert.IsTrue(c.Eval("the world")); ! Assert.IsTrue(!c.Eval("theworld")); ! Assert.IsTrue(!c.Eval("ThE world")); ! Assert.IsTrue(!c.Eval(" the world")); ! Assert.IsTrue(c.Eval("thats nice")); ! Assert.IsTrue(!c.Eval(new object())); ! Assert.IsTrue(!c.Eval(null)); c = new IsMatch(@"^th[aeiou]\w* .*$"); ! Assert.IsTrue(c.Eval("the world")); ! Assert.IsTrue(!c.Eval("theworld")); ! Assert.IsTrue(!c.Eval("ThE world")); c = new IsMatch(@"^th[aeiou]\w* .*$", false); ! Assert.IsTrue(c.Eval("the world")); ! Assert.IsTrue(!c.Eval("theworld")); ! Assert.IsTrue(!c.Eval("ThE world")); c = new IsMatch(@"^th[aeiou]\w* .*$", true); ! Assert.IsTrue(c.Eval("the world")); ! Assert.IsTrue(!c.Eval("theworld")); ! Assert.IsTrue(c.Eval("ThE world")); } *************** *** 225,247 **** c = new IsCloseTo(1.0, 0.5); ! Assertion.Assert(c.Eval(1.0)); ! Assertion.Assert(c.Eval(0.5)); ! Assertion.Assert(c.Eval(1.5)); ! Assertion.Assert(c.Eval(1)); ! Assertion.Assert(c.Eval(0.5f)); ! Assertion.Assert(c.Eval(new decimal(1.5))); ! Assertion.Assert(!c.Eval(0.49)); ! Assertion.Assert(!c.Eval(1.51)); ! Assertion.Assert(!c.Eval(-1.0)); ! Assertion.Assert(c.Eval("1.2")); ! Assertion.Assert(!c.Eval("0.2")); ! Assertion.Assert(!c.Eval("hello")); ! Assertion.Assert(!c.Eval(null)); ! Assertion.Assert(!c.Eval(0)); ! Assertion.Assert(!c.Eval(0.0)); } --- 227,249 ---- c = new IsCloseTo(1.0, 0.5); ! Assert.IsTrue(c.Eval(1.0)); ! Assert.IsTrue(c.Eval(0.5)); ! Assert.IsTrue(c.Eval(1.5)); ! Assert.IsTrue(c.Eval(1)); ! Assert.IsTrue(c.Eval(0.5f)); ! Assert.IsTrue(c.Eval(new decimal(1.5))); ! Assert.IsTrue(!c.Eval(0.49)); ! Assert.IsTrue(!c.Eval(1.51)); ! Assert.IsTrue(!c.Eval(-1.0)); ! Assert.IsTrue(c.Eval("1.2")); ! Assert.IsTrue(!c.Eval("0.2")); ! Assert.IsTrue(!c.Eval("hello")); ! Assert.IsTrue(!c.Eval(null)); ! Assert.IsTrue(!c.Eval(0)); ! Assert.IsTrue(!c.Eval(0.0)); } *************** *** 253,264 **** // 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); --- 255,266 ---- // test property equals a value ! Assert.IsTrue(new PropertyIs("MyProp", "hello").Eval(t)); ! Assert.IsTrue(!new PropertyIs("MyProp", "bye").Eval(t)); // test property using another constraint ! Assert.IsTrue(new PropertyIs("MyProp", new IsMatch("ell")).Eval(t)); ! Assert.IsTrue(!new PropertyIs("MyProp", new IsMatch("sfsl")).Eval(t)); ! Assert.AreEqual( "Property MyProp: <x>", new PropertyIs("MyProp", new IsEqual("x")).Message); *************** *** 268,272 **** public void PropertyIsWithNullValue() { ! Assertion.Assert(!new PropertyIs("Blah", new IsAnything()).Eval(null)); } --- 270,274 ---- public void PropertyIsWithNullValue() { ! Assert.IsTrue(!new PropertyIs("Blah", new IsAnything()).Eval(null)); } *************** *** 276,281 **** ThingWithProps t = new ThingWithProps(); ! Assertion.Assert(new PropertyIs("MyProp.Length", 5).Eval(t)); ! Assertion.Assert(!new PropertyIs("MyProp.Length", 9).Eval(t)); } --- 278,283 ---- ThingWithProps t = new ThingWithProps(); ! Assert.IsTrue(new PropertyIs("MyProp.Length", 5).Eval(t)); ! Assert.IsTrue(!new PropertyIs("MyProp.Length", 9).Eval(t)); } *************** *** 293,301 **** { CollectingConstraint c = new CollectingConstraint(); ! Assertion.Assert(c.Eval("test")); ! Assertion.AssertEquals("test", c.Parameter); ! Assertion.Assert("eval should always be true", c.Eval(null)); ! Assertion.AssertNull(c.Parameter); } --- 295,303 ---- { CollectingConstraint c = new CollectingConstraint(); ! Assert.IsTrue(c.Eval("test")); ! Assert.AreEqual("test", c.Parameter); ! Assert.IsTrue(c.Eval(null), "eval should always be true"); ! Assert.IsNull(c.Parameter); } *************** *** 306,313 **** c = new Constraint(new Constraint.Method(myEval)); myFlag = false; ! Assertion.Assert(c.Eval(null)); ! Assertion.Assert(!c.Eval(null)); ! Assertion.Assert(c.Eval(null)); ! Assertion.Assert(!c.Eval(null)); } --- 308,315 ---- c = new Constraint(new Constraint.Method(myEval)); myFlag = false; ! Assert.IsTrue(c.Eval(null)); ! Assert.IsTrue(!c.Eval(null)); ! Assert.IsTrue(c.Eval(null)); ! Assert.IsTrue(!c.Eval(null)); } *************** *** 315,334 **** public void Messages() { ! Assertion.AssertEquals("null", new IsNull().Message); ! Assertion.AssertEquals("", new IsAnything().Message); ! Assertion.AssertEquals("IN <hi>, <1>, <bye>", new IsIn("hi", 1, "bye").Message); ! Assertion.AssertEquals("<hi>", new IsEqual("hi").Message); ! Assertion.AssertEquals("typeof <System.String>", new IsTypeOf(typeof(System.String)).Message); ! Assertion.AssertEquals("NOT DUMMY", new Not(new Dummy()).Message); ! Assertion.AssertEquals("DUMMY AND DUMMY", new And(new Dummy(), new Dummy()).Message); ! Assertion.AssertEquals("DUMMY OR DUMMY", new Or(new Dummy(), new Dummy()).Message); ! Assertion.AssertEquals("NOT null", new NotNull().Message); ! Assertion.AssertEquals("NOT <hi>", new NotEqual("hi").Message); ! Assertion.AssertEquals("NOT IN <hi>, <1>, <bye>", new NotIn("hi", 1, "bye").Message); ! Assertion.AssertEquals("<hi>", new IsEqualIgnoreCase("hi").Message); ! Assertion.AssertEquals("<hi>", new IsEqualIgnoreWhiteSpace("hi").Message); ! Assertion.AssertEquals("<hi>", new IsMatch("hi").Message); ! Assertion.AssertEquals("<7>", new IsCloseTo(7.0, 1.1).Message); ! Assertion.AssertEquals("Custom Constraint", new Constraint(new Constraint.Method(myEval)).Message); } private bool myFlag; --- 317,336 ---- public void Messages() { ! Assert.AreEqual("null", new IsNull().Message); ! Assert.AreEqual("", new IsAnything().Message); ! Assert.AreEqual("IN <hi>, <1>, <bye>", new IsIn("hi", 1, "bye").Message); ! Assert.AreEqual("<hi>", new IsEqual("hi").Message); ! Assert.AreEqual("typeof <System.String>", new IsTypeOf(typeof(String)).Message); ! Assert.AreEqual("NOT DUMMY", new Not(new Dummy()).Message); ! Assert.AreEqual("DUMMY AND DUMMY", new And(new Dummy(), new Dummy()).Message); ! Assert.AreEqual("DUMMY OR DUMMY", new Or(new Dummy(), new Dummy()).Message); ! Assert.AreEqual("NOT null", new NotNull().Message); ! Assert.AreEqual("NOT <hi>", new NotEqual("hi").Message); ! Assert.AreEqual("NOT IN <hi>, <1>, <bye>", new NotIn("hi", 1, "bye").Message); ! Assert.AreEqual("<hi>", new IsEqualIgnoreCase("hi").Message); ! Assert.AreEqual("<hi>", new IsEqualIgnoreWhiteSpace("hi").Message); ! Assert.AreEqual("<hi>", new IsMatch("hi").Message); ! Assert.AreEqual("<7>", new IsCloseTo(7.0, 1.1).Message); ! Assert.AreEqual("Custom Constraint", new Constraint(new Constraint.Method(myEval)).Message); } private bool myFlag; *************** *** 411,417 **** 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 --- 413,419 ---- ExtractingConstraint constraint = new ExtractingConstraint("E"); ! Assert.AreEqual("A", constraint.ExtractActualValue("ACTUAL"), "Should be modified value"); ! Assert.IsTrue(constraint.Eval("EQUALS FIRST CHAR"), "Should match"); ! Assert.IsTrue(new Not(constraint).Eval("NOT EQUAL"), "Should be different"); } #endregion Index: IsArrayEqualTest.cs =================================================================== RCS file: /cvsroot/nmock/nmock/test/NMock/Constraints/IsArrayEqualTest.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IsArrayEqualTest.cs 11 Jul 2003 08:32:38 -0000 1.1 --- IsArrayEqualTest.cs 22 Oct 2004 11:46:27 -0000 1.2 *************** *** 1,5 **** // Contributed by Luke Maxon <ltmaxon@...> - using System; using System.Collections; using NUnit.Framework; --- 1,4 ---- *************** *** 18,24 **** IsListEqual c = new IsListEqual(o1); ! Assertion.Assert(!c.Eval(o2)); ! Assertion.Assert(!c.Eval(o1)); ! Assertion.Assert(!c.Eval(null)); } --- 17,23 ---- IsListEqual c = new IsListEqual(o1); ! Assert.IsTrue(!c.Eval(o2)); ! Assert.IsTrue(!c.Eval(o1)); ! Assert.IsTrue(!c.Eval(null)); } *************** *** 30,36 **** IsListEqual c = new IsListEqual(o1); ! Assertion.Assert(c.Eval(o2)); ! Assertion.Assert(c.Eval(o1)); ! Assertion.Assert(!c.Eval(null)); } --- 29,35 ---- IsListEqual c = new IsListEqual(o1); ! Assert.IsTrue(c.Eval(o2)); ! Assert.IsTrue(c.Eval(o1)); ! Assert.IsTrue(!c.Eval(null)); } *************** *** 42,46 **** IsListEqual c = new IsListEqual(o1); ! Assertion.Assert(!c.Eval(o2)); } --- 41,45 ---- IsListEqual c = new IsListEqual(o1); ! Assert.IsTrue(!c.Eval(o2)); } *************** *** 52,56 **** IsListEqual c = new IsListEqual(o1); ! Assertion.Assert(c.Eval(o2)); } --- 51,55 ---- IsListEqual c = new IsListEqual(o1); ! Assert.IsTrue(c.Eval(o2)); } *************** *** 62,66 **** IsListEqual c = new IsListEqual(o1); ! Assertion.Assert(!c.Eval(o2)); } --- 61,65 ---- IsListEqual c = new IsListEqual(o1); ! Assert.IsTrue(!c.Eval(o2)); } *************** *** 72,76 **** IsListEqual c = new IsListEqual(o1); ! Assertion.Assert(c.Eval(o2)); } --- 71,75 ---- IsListEqual c = new IsListEqual(o1); ! Assert.IsTrue(c.Eval(o2)); } *************** *** 82,86 **** IsListEqual c = new IsListEqual(o1); ! Assertion.Assert(!c.Eval(o2)); } } --- 81,85 ---- IsListEqual c = new IsListEqual(o1); ! Assert.IsTrue(!c.Eval(o2)); } } *************** *** 96,102 **** IsListEqual c = new IsListEqual(o1); ! Assertion.Assert(!c.Eval(o2)); ! Assertion.Assert(!c.Eval(o1)); ! Assertion.Assert(!c.Eval(null)); } --- 95,101 ---- IsListEqual c = new IsListEqual(o1); ! Assert.IsTrue(!c.Eval(o2)); ! Assert.IsTrue(!c.Eval(o1)); ! Assert.IsTrue(!c.Eval(null)); } *************** *** 108,114 **** IsListEqual c = new IsListEqual(o1); ! Assertion.Assert(c.Eval(o2)); ! Assertion.Assert(c.Eval(o1)); ! Assertion.Assert(!c.Eval(null)); } --- 107,113 ---- IsListEqual c = new IsListEqual(o1); ! Assert.IsTrue(c.Eval(o2)); ! Assert.IsTrue(c.Eval(o1)); ! Assert.IsTrue(!c.Eval(null)); } *************** *** 120,124 **** IsListEqual c = new IsListEqual(o1); ! Assertion.Assert(!c.Eval(o2)); } --- 119,123 ---- IsListEqual c = new IsListEqual(o1); ! Assert.IsTrue(!c.Eval(o2)); } *************** *** 130,134 **** IsListEqual c = new IsListEqual(o1); ! Assertion.Assert(c.Eval(o2)); } --- 129,133 ---- IsListEqual c = new IsListEqual(o1); ! Assert.IsTrue(c.Eval(o2)); } *************** *** 140,144 **** IsListEqual c = new IsListEqual(o1); ! Assertion.Assert(!c.Eval(o2)); } --- 139,143 ---- IsListEqual c = new IsListEqual(o1); ! Assert.IsTrue(!c.Eval(o2)); } *************** *** 150,154 **** IsListEqual c = new IsListEqual(o1); ! Assertion.Assert(c.Eval(o2)); } --- 149,153 ---- IsListEqual c = new IsListEqual(o1); ! Assert.IsTrue(c.Eval(o2)); } *************** *** 160,166 **** IsListEqual c = new IsListEqual(o1); ! Assertion.Assert(!c.Eval(o2)); } ! } ! } \ No newline at end of file --- 159,164 ---- IsListEqual c = new IsListEqual(o1); ! Assert.IsTrue(!c.Eval(o2)); } ! } } \ No newline at end of file |
From: Owen Rogers <exortech@us...> - 2004-10-22 11:47:06
|
Update of /cvsroot/nmock/nmock/src/NMock/Dynamic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19470/src/NMock/Dynamic Modified Files: ClassGenerator.cs Log Message: upgraded to nunit 2.2 upgraded to new version of NAnt Index: ClassGenerator.cs =================================================================== RCS file: /cvsroot/nmock/nmock/src/NMock/Dynamic/ClassGenerator.cs,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** ClassGenerator.cs 23 Jun 2004 04:44:53 -0000 1.22 --- ClassGenerator.cs 22 Oct 2004 11:46:26 -0000 1.23 *************** *** 88,92 **** private object CreateProxyInstance(Type proxyType) { ! object result = Activator.CreateInstance(proxyType); FieldInfo handlerField = proxyType.GetField(INVOCATION_HANDLER_FIELD_NAME); --- 88,92 ---- private object CreateProxyInstance(Type proxyType) { ! object result = Activator.CreateInstance(proxyType, true); FieldInfo handlerField = proxyType.GetField(INVOCATION_HANDLER_FIELD_NAME); |
From: Owen Rogers <exortech@us...> - 2004-10-22 11:47:06
|
Update of /cvsroot/nmock/nmock/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19470/lib Modified Files: nunit.framework.dll Log Message: upgraded to nunit 2.2 upgraded to new version of NAnt Index: nunit.framework.dll =================================================================== RCS file: /cvsroot/nmock/nmock/lib/nunit.framework.dll,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 Binary files /tmp/cvsmjgQDh and /tmp/cvsM9jvoS differ |
From: Owen Rogers <exortech@us...> - 2004-10-22 11:46:55
|
Update of /cvsroot/nmock/nmock/tools/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19470/tools/lib Added Files: NUnitCore.dll Log Message: upgraded to nunit 2.2 upgraded to new version of NAnt --- NEW FILE: NUnitCore.dll --- (This appears to be a binary file; contents omitted.) |
From: Owen Rogers <exortech@us...> - 2004-10-22 11:46:55
|
Update of /cvsroot/nmock/nmock/tools/lib/net/1.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19470/tools/lib/net/1.1 Added Files: NDoc.Core.dll NDoc.Documenter.Msdn.dll nunit.core.dll nunit.framework.dll nunit.util.dll Log Message: upgraded to nunit 2.2 upgraded to new version of NAnt --- NEW FILE: NDoc.Documenter.Msdn.dll --- (This appears to be a binary file; contents omitted.) --- NEW FILE: nunit.framework.dll --- (This appears to be a binary file; contents omitted.) --- NEW FILE: NDoc.Core.dll --- (This appears to be a binary file; contents omitted.) --- NEW FILE: nunit.util.dll --- (This appears to be a binary file; contents omitted.) --- NEW FILE: nunit.core.dll --- (This appears to be a binary file; contents omitted.) |
From: Owen Rogers <exortech@us...> - 2004-10-22 11:39:57
|
Update of /cvsroot/nmock/nmock/tools/lib/net/1.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18574/1.1 Log Message: Directory /cvsroot/nmock/nmock/tools/lib/net/1.1 added to the repository |
From: Owen Rogers <exortech@us...> - 2004-10-22 11:39:33
|
Update of /cvsroot/nmock/nmock/tools/lib/net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18489/net Log Message: Directory /cvsroot/nmock/nmock/tools/lib/net added to the repository |
From: Owen Rogers <exortech@us...> - 2004-10-22 11:38:56
|
Update of /cvsroot/nmock/nmock/tools/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18340/lib Log Message: Directory /cvsroot/nmock/nmock/tools/lib added to the repository |
From: <thibaut.barrere@gm...> - 2004-10-19 08:38:44
|
Anyone ? Or am I on the wrong list ? regards Thibaut On Thu, 14 Oct 2004 11:00:26 +0200, Thibaut Barr=E8re <thibaut.barrere@...> wrote: > Hi gentlemen, >=20 > I'm really new to mock objects, apart from very basic stuff, and would > like to have your opinion about the way I plan to use them. >=20 > I am testing interaction with remote servers, and I'm expecting to be > called in one of several callbacks (registered to the server) in my > testfixture to decide that my test has passed. Callbacks, if called, > set an AutoResetEvent. I'm currently testing the behaviour using this > : >=20 > AutoResetEvent _connected =3D new AutoResetEvent(false); >=20 > /// <summary> > /// Callback for connect test > /// </summary> > /// <param name=3D"e"></param> > private void Connected(object sender,ConnectionEventArgs e) > { > // mark the event > _connected.Set(); > } >=20 > .... >=20 > WaitHandle[] handles =3D { _accepted,_rejected,_cancelled }; > Assert.IsTrue(WaitHandle.WaitAny(handles,5000,true)!=3DWaitHandle.WaitTim= eout,"No > valid callback called."); >=20 > I'm thinking about refactoring the callbacks and waitany code inside a > mock object, with some "expectations" that would do what I need. I > would then mock the receiver, not the server. >=20 > To give more background, the remote servers (~ 10 different > implementations, native c++ code) are wrapped behind a common managed > c++ proxy interface. I couldn't manage to see the benefits of just > mocking one of the remote server, as it would not test the real thing. >=20 > What do you think of mocking the receiver ? Could I do better here ? > Am I totally wrong somewhere ? >=20 > thanks in advance >=20 > Thibaut > |
From: <thibaut.barrere@gm...> - 2004-10-14 09:01:56
|
Hi gentlemen, I'm really new to mock objects, apart from very basic stuff, and would like to have your opinion about the way I plan to use them. I am testing interaction with remote servers, and I'm expecting to be called in one of several callbacks (registered to the server) in my testfixture to decide that my test has passed. Callbacks, if called, set an AutoResetEvent. I'm currently testing the behaviour using this : AutoResetEvent _connected = new AutoResetEvent(false); /// <summary> /// Callback for connect test /// </summary> /// <param name="e"></param> private void Connected(object sender,ConnectionEventArgs e) { // mark the event _connected.Set(); } .... WaitHandle[] handles = { _accepted,_rejected,_cancelled }; Assert.IsTrue(WaitHandle.WaitAny(handles,5000,true)!=WaitHandle.WaitTimeout,"No valid callback called."); I'm thinking about refactoring the callbacks and waitany code inside a mock object, with some "expectations" that would do what I need. I would then mock the receiver, not the server. To give more background, the remote servers (~ 10 different implementations, native c++ code) are wrapped behind a common managed c++ proxy interface. I couldn't manage to see the benefits of just mocking one of the remote server, as it would not test the real thing. What do you think of mocking the receiver ? Could I do better here ? Am I totally wrong somewhere ? thanks in advance Thibaut |
From: Levi Khatskevitch <lkhatskevitch@us...> - 2004-10-13 18:04:09
|
Update of /cvsroot/nmock/nmock/test/NMock/Proxy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11257/test/NMock/Proxy Modified Files: MockRealProxyTest.cs Log Message: fixed bug with inherited/explicitly implemented interface methods Index: MockRealProxyTest.cs =================================================================== RCS file: /cvsroot/nmock/nmock/test/NMock/Proxy/MockRealProxyTest.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MockRealProxyTest.cs 13 Oct 2004 15:43:17 -0000 1.1 --- MockRealProxyTest.cs 13 Oct 2004 18:03:57 -0000 1.2 *************** *** 1,4 **** --- 1,5 ---- using System; using System.Collections; + using System.IO; using System.Reflection; using System.Reflection.Emit; *************** *** 37,54 **** string AProperty { get; set; } } public struct MyStruct ! { ! public int x; ! } ! class X ! { ! private IMock mock = null; ! string stringReturn() { return (string)mock.Invoke("stringReturn", new object[0]); } ! decimal decimalReturn() { return (decimal)mock.Invoke("decimalReturn", new object[0]); } ! MyStruct structReturn() { return (MyStruct)mock.Invoke("structReturn", new object[0]); } ! } public interface ISolidThingy --- 38,59 ---- string AProperty { get; set; } } + + public interface IDerivedThingy : IThingy + { + } public struct MyStruct ! { ! public int x; ! } ! class X ! { ! private IMock mock = null; ! string stringReturn() { return (string)mock.Invoke("stringReturn", new object[0]); } ! decimal decimalReturn() { return (decimal)mock.Invoke("decimalReturn", new object[0]); } ! MyStruct structReturn() { return (MyStruct)mock.Invoke("structReturn", new object[0]); } ! } public interface ISolidThingy *************** *** 94,97 **** --- 99,117 ---- public virtual void NoArgs() { Assertion.Fail("Should have been overriden"); } } + + public class DerivedThing : ConcreteThing + { + } + + public interface ISimpleThingy + { + void NoArgs(); + } + + public class SimpleThingy : MarshalByRefObject, ISimpleThingy + { + void ISimpleThingy.NoArgs() { Assertion.Fail("Should have been overriden"); } + } + #endregion *************** *** 196,218 **** [Test] ! public void CallMethodWithReturnDecimal() ! { ! decimal d = new decimal(3); ! mock.ExpectAndReturn("decimalReturn", d); ! decimal result = thingy.decimalReturn(); ! Assertion.AssertEquals(new decimal(3), result); ! mock.Verify(); ! } ! [Test] ! public void CallMethodWithStruct() ! { ! MyStruct str = new MyStruct(); ! str.x = 3; ! mock.ExpectAndReturn("structReturn", str); ! MyStruct result = thingy.structReturn(); ! Assertion.AssertEquals(str, result); ! mock.Verify(); ! } [Test] public void CallMethodWithReturnEnum() --- 216,238 ---- [Test] ! public void CallMethodWithReturnDecimal() ! { ! decimal d = new decimal(3); ! mock.ExpectAndReturn("decimalReturn", d); ! decimal result = thingy.decimalReturn(); ! Assertion.AssertEquals(new decimal(3), result); ! mock.Verify(); ! } ! [Test] ! public void CallMethodWithStruct() ! { ! MyStruct str = new MyStruct(); ! str.x = 3; ! mock.ExpectAndReturn("structReturn", str); ! MyStruct result = thingy.structReturn(); ! Assertion.AssertEquals(str, result); ! mock.Verify(); ! } [Test] public void CallMethodWithReturnEnum() *************** *** 224,228 **** } ! [Test] [ExpectedException(typeof(System.IO.IOException))] public void CallMethodTheThrowsException() { mock.ExpectAndThrow("boolReturn", new System.IO.IOException()); --- 244,248 ---- } ! [Test] [ExpectedException(typeof(IOException))] public void CallMethodTheThrowsException() { mock.ExpectAndThrow("boolReturn", new System.IO.IOException()); *************** *** 305,308 **** --- 325,358 ---- } + [Test] public void CallMethodOfImplementedInterface() + { + rp = new MockRealProxy(typeof(SimpleThingy), mock); + ISimpleThingy thingy = (ISimpleThingy)rp.GetTransparentProxy(); + + mock.SetupResult("NonVirtualProperty", "foo"); + thingy.NoArgs(); + mock.Verify(); + } + + [Test] public void CallMethodOfInheritedInterface() + { + rp = new MockRealProxy(typeof(IDerivedThingy), mock); + thingy = (IThingy)rp.GetTransparentProxy(); + + mock.Expect("NoArgs"); + thingy.NoArgs(); + mock.Verify(); + } + + [Test] public void CallMethodOfInheritedClass() + { + rp = new MockRealProxy(typeof(DerivedThing), mock); + DerivedThing derived = (DerivedThing)rp.GetTransparentProxy(); + + mock.Expect("NoArgs"); + derived.NoArgs(); + mock.Verify(); + } + [Test] public void CallReadOnlyProperty() { *************** *** 336,340 **** } ! [Test] public void CanExtendAbstractClass() { rp = new MockRealProxy(typeof(AbstractThingy), mock); --- 386,390 ---- } ! [Test] public void CanProxyAbstractClass() { rp = new MockRealProxy(typeof(AbstractThingy), mock); *************** *** 354,361 **** } ! [Test] public void CanExtendConcreteClass() { ! ConcreteThing concrete = (ConcreteThing) ! (new MockRealProxy(typeof(ConcreteThing), mock)).GetTransparentProxy(); mock.Expect("NoArgs"); --- 404,411 ---- } ! [Test] public void CanProxyConcreteClass() { ! rp = new MockRealProxy(typeof(ConcreteThing), mock); ! ConcreteThing concrete = (ConcreteThing)rp.GetTransparentProxy(); mock.Expect("NoArgs"); |