|
From: <sm...@us...> - 2003-08-08 00:05:06
|
Update of /cvsroot/nmock/nmock/test/NMock
In directory sc8-pr-cvs1:/tmp/cvs-serv5316/test/NMock
Modified Files:
DynamicMockTest.cs MockTest.cs
Log Message:
Added Invocation and MethodSignature to collect data values together.
Include type name in error reports
Tidied up MockTest.
Index: DynamicMockTest.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/test/NMock/DynamicMockTest.cs,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** DynamicMockTest.cs 3 Aug 2003 23:01:22 -0000 1.13
--- DynamicMockTest.cs 8 Aug 2003 00:05:03 -0000 1.14
***************
*** 248,253 ****
}
!
! [Test] [Ignore("SetupResult doesn't work for properties")] public void SetAndGetPropertiesDoesNotWorkWithSetupReturn()
{
DynamicMock mock = new DynamicMock(typeof(IWithProperty));
--- 248,253 ----
}
! [Ignore("SetupResult doesn't work for properties")]
! [Test] public void SetAndGetPropertiesDoesNotWorkWithSetupReturn()
{
DynamicMock mock = new DynamicMock(typeof(IWithProperty));
***************
*** 255,259 ****
mock.SetupResult("Name", "fred");
! mock.ExpectAndReturn("Name", "jim");
AssertEquals("Should be property Name", "fred", withProperty.Name);
--- 255,259 ----
mock.SetupResult("Name", "fred");
! mock.Expect("Name", "jim");
AssertEquals("Should be property Name", "fred", withProperty.Name);
Index: MockTest.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/test/NMock/MockTest.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** MockTest.cs 24 Jul 2003 23:09:05 -0000 1.8
--- MockTest.cs 8 Aug 2003 00:05:03 -0000 1.9
***************
*** 1,2 ****
--- 1,3 ----
+ using System;
using NUnit.Framework;
using NMock.Constraints;
***************
*** 5,34 ****
{
! [TestFixture]
! public class MockTest
{
private IMock mock;
! [SetUp]
! public void SetUp()
{
mock = new Mock("mymock");
}
! [Test]
! public void Name()
{
Assertion.AssertEquals("mymock", mock.Name);
}
! [Test]
! public void NewMockVerifies()
{
mock.Verify();
}
! [Test]
! public void CallToVoidMethod()
{
mock.Expect("myMethod");
--- 6,30 ----
{
! [TestFixture] public class MockTest : Assertion
{
private IMock mock;
! [SetUp] public void SetUp()
{
mock = new Mock("mymock");
}
! [Test] public void HasNameSetDuringConstruction()
{
Assertion.AssertEquals("mymock", mock.Name);
}
! [Test] public void VerifyiDoesNothingWithANewMock()
{
mock.Verify();
}
! [Test] public void ExpectAndCallAVoidMethod()
{
mock.Expect("myMethod");
***************
*** 37,43 ****
}
! [Test]
! [ExpectedException(typeof(VerifyException))]
! public void NoCallToVoidMethod()
{
mock.Expect("myMethod");
--- 33,37 ----
}
! [Test] [ExpectedException(typeof(VerifyException))] public void VerifyFailsWhenAnExpectedVoidMethodIsNotCalled()
{
mock.Expect("myMethod");
***************
*** 45,51 ****
}
! [Test]
! [ExpectedException(typeof(VerifyException))]
! public void TooManyCallsToVoidMethod()
{
mock.Expect("myMethod");
--- 39,43 ----
}
! [Test] [ExpectedException(typeof(VerifyException))] public void VerifyFailsWhenTooManyCallsToAnExpectedVoidMethod()
{
mock.Expect("myMethod");
***************
*** 54,59 ****
}
! [Test]
! public void CallWithNoExpectation()
{
mock.Call("myMethod");
--- 46,50 ----
}
! [Test] public void IgnoresUnexpectedCalls()
{
mock.Call("myMethod");
***************
*** 61,66 ****
}
! [Test]
! public void ManyCallsToVoidMethod()
{
mock.Expect("myMethod");
--- 52,56 ----
}
! [Test] public void VerifyMultipleCallsToSameExpectedVoidMethod()
{
mock.Expect("myMethod");
***************
*** 73,78 ****
}
! [Test]
! public void CallToMethodWithParams()
{
mock.Expect("myMethod", new IsEqual("hello"), new IsAnything());
--- 63,77 ----
}
! [Test] [ExpectedException(typeof(VerifyException))] public void VerifyFailsForDifferentNumberOfCallsToExpectedVoidMethod()
! {
! mock.Expect("myMethod");
! mock.Expect("myMethod");
! mock.Expect("myMethod");
! mock.Call("myMethod");
! mock.Call("myMethod");
! mock.Verify();
! }
!
! [Test] public void CallToMethodWithParameterConstraints()
{
mock.Expect("myMethod", new IsEqual("hello"), new IsAnything());
***************
*** 81,87 ****
}
! [Test]
! [ExpectedException(typeof(VerifyException))]
! public void CallToMethodWithInvalidParams()
{
mock.Expect("myMethod", new IsEqual("hello"), new IsAnything());
--- 80,84 ----
}
! [Test] [ExpectedException(typeof(VerifyException))] public void CallToMethodWithInvalidParams()
{
mock.Expect("myMethod", new IsEqual("hello"), new IsAnything());
***************
*** 89,94 ****
}
! [Test]
! public void CallToMethodWithParamsButNotCheckingValues()
{
mock.Expect("myMethod");
--- 86,90 ----
}
! [Test] public void CallToMethodWithParamsButNotCheckingValues()
{
mock.Expect("myMethod");
***************
*** 97,102 ****
}
! [Test]
! public void CallMultipleMethods()
{
mock.Expect("myMethod1");
--- 93,97 ----
}
! [Test] public void CallMultipleMethods()
{
mock.Expect("myMethod1");
***************
*** 109,114 ****
}
! [Test]
! public void CallMultipleMethodsInDifferentOrder()
{
mock.Expect("myMethod1");
--- 104,108 ----
}
! [Test] public void CallMultipleMethodsInDifferentOrder()
{
mock.Expect("myMethod1");
***************
*** 121,126 ****
}
! [Test]
! public void CallMultipleMethodsSomeWithoutExpectations()
{
mock.Expect("myMethod1");
--- 115,119 ----
}
! [Test] public void CallMultipleMethodsSomeWithoutExpectations()
{
mock.Expect("myMethod1");
***************
*** 135,140 ****
}
! [Test]
! public void CallToNonVoidMethod()
{
object something = new object();
--- 128,132 ----
}
! [Test] public void CallToNonVoidMethod()
{
object something = new object();
***************
*** 145,150 ****
}
! [Test]
! public void CallToNonVoidMethodWithParams()
{
object something = new object();
--- 137,141 ----
}
! [Test] public void CallToNonVoidMethodWithParams()
{
object something = new object();
***************
*** 155,161 ****
}
! [Test]
! [ExpectedException(typeof(VerifyException))]
! public void CallToNonVoidMethodWithWrongParams()
{
object something = new object();
--- 146,150 ----
}
! [Test] [ExpectedException(typeof(VerifyException))] public void CallToNonVoidMethodWithWrongParams()
{
object something = new object();
***************
*** 166,171 ****
}
! [Test]
! public void MultipleCallToNonVoidMethod()
{
object something = new object();
--- 155,159 ----
}
! [Test] public void MultipleCallToNonVoidMethod()
{
object something = new object();
***************
*** 181,186 ****
}
! [Test]
! public void CallToNonVoidMethodReturningNull()
{
mock.ExpectAndReturn("myMethod", null);
--- 169,173 ----
}
! [Test] public void CallToNonVoidMethodReturningNull()
{
mock.ExpectAndReturn("myMethod", null);
***************
*** 189,194 ****
}
! [Test]
! public void DefaultEqualsConstraint()
{
object o = new object();
--- 176,180 ----
}
! [Test] public void DefaultEqualsConstraint()
{
object o = new object();
***************
*** 197,203 ****
}
! [Test]
! [ExpectedException(typeof(VerifyException))]
! public void DefaultEqualsConstraintFailure()
{
mock.Expect("myMethod", new object());
--- 183,187 ----
}
! [Test] [ExpectedException(typeof(VerifyException))] public void DefaultEqualsConstraintFailure()
{
mock.Expect("myMethod", new object());
***************
*** 205,210 ****
}
! [Test]
! public void DefaultAnythingConstraint()
{
mock.Expect("myMethod", null, null);
--- 189,193 ----
}
! [Test] public void DefaultAnythingConstraint()
{
mock.Expect("myMethod", null, null);
***************
*** 216,221 ****
}
! [Test]
! public void FixedValue()
{
mock.SetupResult("myMethod", "hello");
--- 199,203 ----
}
! [Test] public void FixedValue()
{
mock.SetupResult("myMethod", "hello");
***************
*** 237,243 ****
}
! [Test]
! [ExpectedException(typeof(System.IO.IOException))]
! public void CallThrowingException()
{
mock.ExpectAndThrow("myMethod", new System.IO.IOException());
--- 219,223 ----
}
! [Test] [ExpectedException(typeof(System.IO.IOException))] public void CallThrowingException()
{
mock.ExpectAndThrow("myMethod", new System.IO.IOException());
***************
*** 245,251 ****
}
! [Test]
! [ExpectedException(typeof(VerifyException))]
! public void ExpectNoCall()
{
mock.ExpectNoCall("myMethod");
--- 225,229 ----
}
! [Test] [ExpectedException(typeof(VerifyException))] public void ExpectNoCall()
{
mock.ExpectNoCall("myMethod");
***************
*** 253,258 ****
}
! [Test] // , Ignore("NoCall does not currently work, but requires a biggish overhaul to fix. No time right now to do it")]
! public void ExpectNoCall_WithNoCall()
{
mock.ExpectNoCall("myMethod");
--- 231,236 ----
}
! // , Ignore("NoCall does not currently work, but requires a biggish overhaul to fix. No time right now to do it")]
! [Test] public void ExpectNoCall_WithNoCall()
{
mock.ExpectNoCall("myMethod");
***************
*** 260,266 ****
}
! [Test]
! [ExpectedException(typeof(VerifyException))]
! public void Strict()
{
mock.Strict = true;
--- 238,242 ----
}
! [Test] [ExpectedException(typeof(VerifyException))] public void Strict()
{
mock.Strict = true;
***************
*** 272,287 ****
}
! [Test]
! public void ExpectedNoCallsMessage()
{
try
{
mock.ExpectNoCall("x");
! mock.Call("x");
! Assertion.Fail("Expected VerifyException");
}
catch (VerifyException e)
{
! Assertion.AssertEquals("x() called", e.Reason);
Assertion.AssertEquals(0, e.Expected);
Assertion.AssertEquals(1, e.Actual);
--- 248,262 ----
}
! [Test] public void UnexpectedMethodCallVerifyExceptionMessage()
{
try
{
mock.ExpectNoCall("x");
! mock.Call("x");
! Fail("Expected VerifyException");
}
catch (VerifyException e)
{
! Assertion.AssertEquals("mymock.x() called", e.Reason);
Assertion.AssertEquals(0, e.Expected);
Assertion.AssertEquals(1, e.Actual);
***************
*** 289,294 ****
}
! [Test]
! public void ExpectedOneCallMessage()
{
try
--- 264,268 ----
}
! [Test] public void MethodNotCalledVerifyExpectionMessage()
{
try
***************
*** 300,304 ****
catch (VerifyException e)
{
! Assertion.AssertEquals("x() never called", e.Reason);
Assertion.AssertEquals(1, e.Expected);
Assertion.AssertEquals(0, e.Actual);
--- 274,278 ----
catch (VerifyException e)
{
! Assertion.AssertEquals("mymock.x() never called", e.Reason);
Assertion.AssertEquals(1, e.Expected);
Assertion.AssertEquals(0, e.Actual);
***************
*** 306,311 ****
}
! [Test]
! public void ExpectedOneCallGotTooManyMessage()
{
try
--- 280,284 ----
}
! [Test] public void ExpectedOneCallGotTooManyMessage()
{
try
***************
*** 325,330 ****
}
! [Test]
! public void ExpectedManyCallsGotNoneMessage()
{
try
--- 298,302 ----
}
! [Test] public void ExpectedManyCallsGotNoneMessage()
{
try
***************
*** 337,348 ****
catch (VerifyException e)
{
! Assertion.AssertEquals("x() never called", e.Reason);
! Assertion.AssertEquals(2, e.Expected);
! Assertion.AssertEquals(0, e.Actual);
}
}
! [Test]
! public void ExpectedManyCallsGotOneMessage()
{
try
--- 309,319 ----
catch (VerifyException e)
{
! AssertEquals("mymock.x() never called", e.Reason);
! AssertEquals(2, e.Expected);
! AssertEquals(0, e.Actual);
}
}
! [Test] public void ExpectedManyCallsGotOneMessage()
{
try
***************
*** 356,360 ****
catch (VerifyException e)
{
! Assertion.AssertEquals("x() not called enough times", e.Reason);
Assertion.AssertEquals(2, e.Expected);
Assertion.AssertEquals(1, e.Actual);
--- 327,331 ----
catch (VerifyException e)
{
! Assertion.AssertEquals("mymock.x() not called enough times", e.Reason);
Assertion.AssertEquals(2, e.Expected);
Assertion.AssertEquals(1, e.Actual);
***************
*** 362,367 ****
}
! [Test]
! public void ExpectedManyCallsGotTooManyMessage()
{
try
--- 333,337 ----
}
! [Test] public void ExpectedManyCallsGotTooManyMessage()
{
try
***************
*** 383,388 ****
}
! [Test]
! public void ExpectedManyCallsGotNotEnoughMessage()
{
try
--- 353,357 ----
}
! [Test] public void ExpectedManyCallsGotNotEnoughMessage()
{
try
***************
*** 400,409 ****
Assertion.AssertEquals(3, e.Expected);
Assertion.AssertEquals(2, e.Actual);
! Assertion.AssertEquals("x() not called enough times", e.Reason);
}
}
! [Test]
! public void IncorrectNumberOfParametersMessage()
{
try
--- 369,377 ----
Assertion.AssertEquals(3, e.Expected);
Assertion.AssertEquals(2, e.Actual);
! Assertion.AssertEquals("mymock.x() not called enough times", e.Reason);
}
}
! [Test] public void IncorrectNumberOfParametersMessage()
{
try
***************
*** 421,426 ****
}
! [Test]
! public void IncorrectParameterConstraintMessage()
{
try
--- 389,393 ----
}
! [Test] public void IncorrectParameterConstraintMessage()
{
try
***************
*** 441,455 ****
}
}
! [Test]
! public void ArgTypes()
{
! MockCall call = new MockCall(null, null, new object[] {1, "string",
! new bool[] {true, false}});
Assertion.AssertEquals("Parameter one", typeof(int), call.ArgTypes[0]);
Assertion.AssertEquals("Parameter two", typeof(string), call.ArgTypes[1]);
Assertion.AssertEquals("Parameter three", typeof(bool[]), call.ArgTypes[2]);
}
-
}
}
--- 408,426 ----
}
}
+
+ }
! [TestFixture] public class MockCallTest
! {
! [Test] public void ArgTypes()
{
! 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}});
Assertion.AssertEquals("Parameter one", typeof(int), call.ArgTypes[0]);
Assertion.AssertEquals("Parameter two", typeof(string), call.ArgTypes[1]);
Assertion.AssertEquals("Parameter three", typeof(bool[]), call.ArgTypes[2]);
}
}
}
|