Alex Rivera | Logout

Has anyone successfully mocked the Socket class in .NET?

Asked 2009-08-11T23:48:46.587
10

I'm trying to mock out the System.net.Sockets.Socket class in C# - I tried using NUnit mocks but it can't mock concrete classes. I also tried using Rhino Mocks but it seemed to use a real version of the class because it threw a SocketException when Send(byte[]) was called. Has anyone successfully created and used a Socket mock using any mocking framework?

Edit
Report

1 Answer

1

I've created an example console application using the method thinkzig suggests (an adapter class for Socket). It uses RhinoMocks and NUnit. You can download it here: How to mock System.Net.Sockets.Socket.

answered 2009-12-28T17:15:04.680

Your Answer