Questions tagged [nunit-mocks]

10 questions
15
votes
2 answers

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.
sourcenouveau
  • 29,356
  • 35
  • 146
  • 243
10
votes
5 answers

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…
Nosrama
  • 14,530
  • 13
  • 49
  • 58
6
votes
2 answers

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…
Prince Ashitaka
  • 8,623
  • 12
  • 48
  • 71
5
votes
4 answers

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

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…
Nosrama
  • 14,530
  • 13
  • 49
  • 58
3
votes
2 answers

Has nUnit got a mocking framework built in and should I use it?

I recall that there is a mocking framework build into nUnit, but I can find details of it on the nUnit web site. Was I dreaming? I was considering using it to save the pain of having to introduce another assembly that we will have to managed on…
Ian Ringrose
  • 51,220
  • 55
  • 213
  • 317
3
votes
1 answer

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…
Corey Adler
  • 15,897
  • 18
  • 66
  • 80
3
votes
1 answer

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(); …
Flynn1179
  • 11,925
  • 6
  • 38
  • 74
2
votes
2 answers

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…
David Moles
  • 48,006
  • 27
  • 136
  • 235
1
vote
1 answer

Can't seem to be able to figure out the first part of this nunit test

Im struggling to understand what going on in the first part of the test. [Test] public void Can_Delete_Product() { // Arrange: Given a repository containing some product... **var mockRepository = new Mock(); …
Rushino
  • 9,415
  • 16
  • 53
  • 93
0
votes
1 answer

Testing events with NUnit mock objects

I'm using NUnit to test my application, which I've included a simplified version of below. I'm looking for a way to fire an event on a mock class, and check that the class under test has received it. The application calls LogIn on the session, and,…
thomson_matt
  • 7,473
  • 3
  • 39
  • 47