nunit-mocks

Has anyone successfully mocked the Socket class in .NET?

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 an...

Is there a way to specify ANYTHING as an argument to NUnit Mocks Expect call?

hi, I'm using NUnit mocks and would like to specify that I expect a call but without saying what the arguments will be for example: mock.ExpectAndReturn("Equals", true, ANY_ARGUMENT); Obviously filling in the correct syntax instead of ANY_ARGUMENT. Is there a way to do this? If I specify no arguments - NUnit fails the test because ...

How to invoke WPF Dispatcher in Nunit?

I want to test an application which renders a text block with a data field value. I would like to get the actual width and actual height, once the rendering completes. Everything works fine. The problem came first, when I tried to test the application. I'm unable to invoke the dispatcher from the test project. Following is the code. ...

Where is the NUnit.Mocks documentation?

Where is the documentation for NUnit's mocking library, NUnit.Mocks? I can't find anything in their official documentation or wiki. ...

Constructing mocks in unit tests

Is there any way to have a mock constructed instead of a real instance when testing code that calls a constructor? For example: public class ClassToTest { public void MethodToTest() { MyObject foo = new MyObject(); Console.WriteLine(foo.ToString()); } } In this example, I need to create a unit test that confirms that ca...

NUnit with Rhino Mocks exception: Why is it throwing this exception?

I'm getting an exception that really makes no sense to me whatsoever. I have an Expect call for a method that takes 3 arguments into it: The types are called CallContext, IDal, and List. NUnit throws me 2 exceptions: One for not expecting a method call that happened where the types are CallContext, System.Object, and List, and one fo...

Making a DynamicMock MockInstance equal to itself

Trying to use NUnit to test a method that adds an object to a queue, and throws an exception if the object's already been queued, but it fails because Queue.Contains() can't detect that the mock object's already in the queue. The method under test is pretty simple: public void Enqueue(ISomeInterface obj) { if (myQueue.Contains(obj)...