i am writing a Class wich will be initialised with a Socket. I want to write a Test using an NUnit DynamicMock.
How can i create a Mock of the Socket without much effort?
DynamicMock DynamicSocketMock = new DynamicMock(typeof (Socket));
/*No ERROR - BUT I THINK HERE IS THE PROBLEM*/
Socket SocketMock = (Socket) DynamicSocketMock.MockInstance;
/*RUNTIME ERROR*/
ToBeTested Actual = new ToBeTested(SocketMock);
/*NEVER REACHED*/
Edit #1
I looked into moq nad it looks quite nice however i still can not test. My initial Problem was to find the rigth version to use, but i think i solved this.
var Mock = new Mock<Socket>();
Socket MockSocket = (Socket)Mock.Object;
ToBeTested Actual = new ToBeTested(SocketMock);
The Problem ist that Socket does not feature a Constructor without parameters. Now i do not want to give it a parameter, i want to mock everything.
Edit #2 This seems to be a problem for a lot of people The target is to create a mock directly from the socket.