|
From: <sm...@us...> - 2003-07-26 06:22:20
|
Update of /cvsroot/nmock/nmock/test/NMock/Dynamic
In directory sc8-pr-cvs1:/tmp/cvs-serv9204/test/NMock/Dynamic
Modified Files:
ClassGeneratorTest.cs
Log Message:
Restored broken support for Longs and Remoting
Can no longer mock classes with internal methods
Index: ClassGeneratorTest.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/test/NMock/Dynamic/ClassGeneratorTest.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** ClassGeneratorTest.cs 24 Jul 2003 23:09:05 -0000 1.8
--- ClassGeneratorTest.cs 25 Jul 2003 15:52:41 -0000 1.9
***************
*** 1,7 ****
using NUnit.Framework;
using NMock;
using NMock.Constraints;
- using System.Reflection.Emit;
- using System.Collections;
namespace NMock.Dynamic
--- 1,10 ----
+ using System;
+ using System.Collections;
+ using System.Reflection.Emit;
+
+
using NUnit.Framework;
using NMock;
using NMock.Constraints;
namespace NMock.Dynamic
***************
*** 18,21 ****
--- 21,26 ----
void WithOtherArgs(int x, bool y, object o, IList list);
void WithParams(int i, params string[] extra);
+ void WithLongParam(long l);
+ void WithIntParam(int i);
object simpleReturn();
string stringReturn();
***************
*** 35,44 ****
}
- // internal and protected internal methods must be overridable!
public abstract class SolidThingy : ISolidThingy
{
public virtual string VirtualMethod() { return "xx"; }
public abstract string AbstractMethod();
- internal virtual string InternalMethod() { return "xx"; }
protected internal virtual string ProtectedInternalMethod() { return "xx"; }
--- 40,48 ----
}
public abstract class SolidThingy : ISolidThingy
{
+ // 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"; }
***************
*** 57,61 ****
--- 61,69 ----
get { return "xx"; }
}
+ }
+ public class ClassWithInternalMethod
+ {
+ internal virtual string InternalMethod() { return "xx"; }
}
***************
*** 163,166 ****
--- 171,188 ----
}
+ [Test] public void CallMethodWithStringParameter()
+ {
+ mock.Expect("WithSimpleArg", "hello");
+ thingy.WithSimpleArg("hello");
+ mock.Verify();
+ }
+
+ [Test] public void CallMethodWithIntParameter()
+ {
+ mock.Expect("WithIntParam", 1);
+ thingy.WithIntParam(1);
+ mock.Verify();
+ }
+
[Test]
[ExpectedException(typeof(VerifyException))]
***************
*** 214,217 ****
--- 236,246 ----
}
+ [Test] public void CallMethodWithLongParam()
+ {
+ mock.Expect("WithLongParam", 5L);
+ thingy.WithLongParam(5);
+ mock.Verify();
+ }
+
[Test]
public void CallReadOnlyProperty()
***************
*** 257,261 ****
mock.ExpectAndReturn("GetHashCode", 123);
mock.ExpectAndReturn("AbstractMethod", "fish");
- mock.ExpectAndReturn("InternalMethod", "black");
mock.ExpectAndReturn("ProtectedInternalMethod", "white");
--- 286,289 ----
***************
*** 263,267 ****
Assertion.AssertEquals(123, s.GetHashCode());
Assertion.AssertEquals("fish", s.AbstractMethod());
- Assertion.AssertEquals("black", s.InternalMethod());
Assertion.AssertEquals("white", s.ProtectedInternalMethod());
--- 291,294 ----
***************
*** 272,275 ****
--- 299,308 ----
}
+ [Test] [ExpectedException(typeof(TypeLoadException))]
+ public void CannotMockClassWithInternalMethodBecauseOfAssemblyVisibility()
+ {
+ new ClassGenerator().Generate(typeof(ClassWithInternalMethod), mock);
+ }
+
[Test]
public void CheckBoxingOpCodes()
|