Hello All,
I'm just picking this up, so this may not be the brightest of questions, but it
has me relatively stumped. I'm experimenting with mocking a socket, and have
the following (sample) code implemented:
[TestMethod]
public void AbuseArrayList_UsingCreateMockGenerics()
{
MockRepository mocks = new MockRepository();
ArrayList list = mocks.StrictMock<ArrayList>(new Object[] {15});
Socket sock = mocks.StrictMock<Socket>(new Object[] {
AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp });
Expect.Call(delegate { sock.Bind(new IPEndPoint(IPAddress.Any,
12112)); });
// Setup the expectation of a call on the mock
Expect.Call(delegate { list.GetRange(1, 1); }).Return(null);
Expect.Call(list.Capacity).Return(999);
mocks.ReplayAll();
// Evaluate the values from the mock
Assert.AreEqual(999, list.Capacity);
Assert.AreEqual(null, list.GetRange(1, 1));
mocks.VerifyAll(); ;
}
The odd part is that the call:
Expect.Call(delegate { sock.Bind(new
IPEndPoint(IPAddress.Any, 12112)); });
Throws the exception:
Test method TestSamples.UnitTest1.AbuseArrayList_UsingCreateMockGenerics threw
exception: System.InvalidOperationException: Invalid call, the last call has
been used or no call has been made (make sure that you are calling a virtual
(C#) / Overridable (VB) method)..
Unless it is moved to after the other expects:
Expect.Call(delegate { list.GetRange(1, 1); }).Return(null);
Expect.Call(list.Capacity).Return(999);
Expect.Call(delegate { sock.Bind(new IPEndPoint(IPAddress.Any,
12112)); });
At that point, it doesn't seem to have any effect at all. Any suggestions as to
what I should know, but don't, would be appreciated.
Seth Corduan
Software Engineer
Attention: This message and all attachments are private and may contain
information that is confidential and privileged. If you received this
message in error, please notify the sender by reply email and delete
the message immediately.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Rhino.Mocks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rhinomocks?hl=en
-~----------~----~----~----~------~----~------~--~---