Questions tagged [nmock]

NMock is a mocking framework for .NET 3.5 and 4.0. It supports lambda expressions for member matching. It has an easy to read syntax.

NMock is a dynamic mock object test library for .NET.

NMock2 is already available.

51 questions
2
votes
2 answers

Differences between NMock 2.0 and NMock2

I am a bit confused over which version of NMock2 I should use. The one I've been using for a while I got from here: http://www.nmock.org/download.html The filename is NMock2.dll with version 2.0.0.44. I ran into a problem where I couldn't mock…
Igor Zevaka
  • 74,528
  • 26
  • 112
  • 128
2
votes
2 answers

NMock - how to say expect 'any value' on these params? Or should I not do this?

I have a quick question that I could not figure out in the docs about NMock2.0. I have a function called Save() that I want to mock out. This takes a string ID as parameter and a decimal as value.. I know I can write this to make sure that Save()…
dferraro
  • 6,357
  • 11
  • 46
  • 69
1
vote
3 answers

Using Mock objects with Dictionary

I just started working with Unit Testing with NMock I one my test cases involve adding an entry in a dictionary which is then passed to the unit being tested. I define the map as: var item = new Mock().Object; var myMap = new…
frictionlesspulley
  • 11,070
  • 14
  • 66
  • 115
1
vote
2 answers

C# Noob - Triggering event in mocked interface class - How does this code work?

I'm a little confused at what's going on here. I'm looking at the Puzzle example from Atomic Object showing how to test a Model-View-Presenter pattern Puzzle.zip The View has a private event. The view also has a Subscribe(delegate) function that…
Joe Schneider
  • 9,179
  • 7
  • 42
  • 59
1
vote
3 answers

ambiguous references when mixing NUnit and NMock2 matchers

We're using NUnit (2.5.9) and NMock2 for unit testing and mocking. Both, however, have a matcher syntax that closely corresponds. When I do using NUnit.Framework; using NMock2; And later on the following NMock2…
skrebbel
  • 9,841
  • 6
  • 35
  • 34
1
vote
1 answer

How to mock a function in an unit test

How could I unittest GetData by NMock3? It would be great if prcessA.Run and the "result" inside ProcessA could be mocked. IAnotherService could not be GetData's parameter as it depends on a processed value inside GetData. Any ideas? Service1 public…
mintssoul
  • 51
  • 1
  • 10
1
vote
1 answer

Mocking adding items to a list in .NET NMock2

I'm using NMock2 (2.1.3641.27570) in my unit tests. IList values = _mock.NewMock>(); That mock I return when my tested object calls the Values get property on my mocked…
Peete
  • 125
  • 11
1
vote
1 answer

NMOCK3 - Expects.One.Method

I am new to Mocking and Unit Testing in general. Please see the code below which I found online: [Test] public void CanQueryViewUseAccountServiceToFundsTransfer() { _viewMock.Expects.One.Method(v =>…
w0051977
  • 15,099
  • 32
  • 152
  • 329
1
vote
2 answers

How to assert a private method on concrete class is called (TypeMock/NMock/etc..)?

I am trying to write a unit test for the 'IsUnique' function in the class below that looks like this: class Foo { public bool IsUnique(params...) { ValidateStuffExists(params); return CheckUniqueness(params); } private…
dferraro
  • 6,357
  • 11
  • 46
  • 69
1
vote
1 answer

using NMock3 in c#, the mock throws expection even when I am not telling it to throw

I have seen a lot posts explaining how to use NMock to expect an exception. But that is not what i want to know. In my case, i am testing the happy path. But looks like the NMock is throwing exceptions as long as the method called on the mock is…
user1469452
  • 39
  • 1
  • 4
1
vote
2 answers

Mocking help?I can't find what's the problem

I have an interface definded like this: public interface IDatabase{ void Get ();} and when I try to do: Mockery mockery = new Mockery(); IDatabase db = mockery.NewMock(); I get the following error:…
Luisa
  • 525
  • 1
  • 6
  • 16
1
vote
2 answers

Basic NMock database examples for CRUD application

I'm looking for some basic examples of using NMock2 to mock database calls for a CRUD application. Thanks, Chris
Chris Burgess
  • 5,787
  • 13
  • 54
  • 69
1
vote
1 answer

NMock and NUnit

What is the difference between NMock and NUnit? I have spent some time Googling this and have found explanations…
w0051977
  • 15,099
  • 32
  • 152
  • 329
1
vote
2 answers

Getting an NMock expectation to return a new object based on received arguments

NMock3 is my mocking framework of choice, but I'm struggling to make it do what I want. What I need is for a new object to be constructed and returned as part of an expectation, based on some of the parameters that are received when the expectation…
RSlaughter
  • 1,191
  • 3
  • 11
  • 23
0
votes
1 answer

Error creating my first Mock object

I'm new to this, so doubtlessly I'm doing something silly. I am trying to create a mock object: mockCurrencyConversion = mocks.NewMock(); and getting this error: The non-generic method 'NMock2.Mockery.NewMock(System.Type)'…
Positonic
  • 9,151
  • 14
  • 57
  • 84