|
From: Owen R. <exo...@us...> - 2004-09-17 03:33:57
|
Update of /cvsroot/nmock/nmock/test/NMock In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9698/test/NMock Modified Files: FastErrorHandlingTest.cs MockTest.cs TypeCheckedMockTest.cs VerifyExceptionTest.cs Log Message: - committing jim's changes to add support for mocking methods with ref arguments - refactored signature class to encapsulate methods and properties Index: TypeCheckedMockTest.cs =================================================================== RCS file: /cvsroot/nmock/nmock/test/NMock/TypeCheckedMockTest.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TypeCheckedMockTest.cs 24 Aug 2004 21:15:30 -0000 1.1 --- TypeCheckedMockTest.cs 17 Sep 2004 03:33:47 -0000 1.2 *************** *** 1,8 **** using System; using System.Collections; - using System.Reflection; - using NMock.Constraints; - using NUnit.Framework; --- 1,5 ---- *************** *** 178,181 **** --- 175,230 ---- } + public interface IFoo + { + void MethodWithRefParameter(ref int p); + void MethodWithRefParameter(ref byte p); + void MethodWithRefParameter(ref sbyte p); + void MethodWithRefParameter(ref short p); + void MethodWithRefParameter(ref long p); + void MethodWithRefParameter(ref float p); + void MethodWithRefParameter(ref double p); + void MethodWithRefParameter(ref bool p); + void MethodWithRefParameter(ref ushort p); + void MethodWithRefParameter(ref uint p); + void MethodWithRefParameter(ref ulong p); + void MethodWithRefParameter(ref string p); + void MethodWithRefParameter(ref char p); + } + + [Test] + public void CanMockMembersWithRefParameters() + { + DynamicMock mock = new DynamicMock(typeof(IFoo)); + IFoo foo = (IFoo)mock.MockInstance; + + int INT = int.MaxValue; + string STRING = String.Empty; + bool BOOL = true; + char CHAR = char.MaxValue; + byte BYTE = byte.MaxValue; + double DOUBLE = double.MaxValue; + float FLOAT = float.MaxValue; + short SHORT = short.MaxValue; + long LONG = long.MaxValue; + ushort USHORT = ushort.MaxValue; + uint UINT = uint.MaxValue; + ulong ULONG = ulong.MaxValue; + sbyte SBYTE = sbyte.MaxValue; + + foo.MethodWithRefParameter(ref STRING); + foo.MethodWithRefParameter(ref INT); + foo.MethodWithRefParameter(ref BOOL); + foo.MethodWithRefParameter(ref CHAR); + foo.MethodWithRefParameter(ref BYTE); + foo.MethodWithRefParameter(ref DOUBLE); + foo.MethodWithRefParameter(ref FLOAT); + foo.MethodWithRefParameter(ref SHORT); + foo.MethodWithRefParameter(ref LONG); + foo.MethodWithRefParameter(ref USHORT); + foo.MethodWithRefParameter(ref UINT); + foo.MethodWithRefParameter(ref ULONG); + foo.MethodWithRefParameter(ref SBYTE); + } + [Test] public void CannotYetMockMembersWithOnlyAParamsArgument() { Index: FastErrorHandlingTest.cs =================================================================== RCS file: /cvsroot/nmock/nmock/test/NMock/FastErrorHandlingTest.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FastErrorHandlingTest.cs 8 Apr 2004 03:47:41 -0000 1.5 --- FastErrorHandlingTest.cs 17 Sep 2004 03:33:47 -0000 1.6 *************** *** 4,8 **** namespace NMock { - /// <summary> /// looking at the code, I think fixing this for one case (SetupResult or Expect) --- 4,7 ---- *************** *** 93,97 **** } - [Test] [ExpectedException(typeof(MissingMethodException))] --- 92,95 ---- *************** *** 127,135 **** catch(ArgumentException e) { ! AssertEquals("method <Bar> is not virtual", e.Message); } } - } - } --- 125,131 ---- catch(ArgumentException e) { ! AssertEquals("method <MockFull.Bar(System.String)> is not virtual", e.Message); } } } } Index: VerifyExceptionTest.cs =================================================================== RCS file: /cvsroot/nmock/nmock/test/NMock/VerifyExceptionTest.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** VerifyExceptionTest.cs 24 Aug 2004 16:00:25 -0000 1.2 --- VerifyExceptionTest.cs 17 Sep 2004 03:33:47 -0000 1.3 *************** *** 9,13 **** public class VerifyExceptionTest { ! private readonly MethodSignature signature = new MethodSignature("Foo", "Bar"); [Test] --- 9,13 ---- public class VerifyExceptionTest { ! private readonly DefaultSignature signature = new DefaultSignature("Foo", "Bar"); [Test] Index: MockTest.cs =================================================================== RCS file: /cvsroot/nmock/nmock/test/NMock/MockTest.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** MockTest.cs 24 Aug 2004 16:00:24 -0000 1.14 --- MockTest.cs 17 Sep 2004 03:33:47 -0000 1.15 *************** *** 437,441 **** { MockCall call = new MockCall( ! new MethodSignature("mymock", "call", new Type[] {typeof(int), typeof(string), typeof(bool[]) }), null, null, new object[] {1, "string", new bool[] {true, false}}); --- 437,441 ---- { MockCall call = new MockCall( ! new DefaultSignature("mymock", "call", new Type[] {typeof(int), typeof(string), typeof(bool[]) }), null, null, new object[] {1, "string", new bool[] {true, false}}); |