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
Filter by
Sorted by
Tagged with
14 votes
3 answers
7k views

When to Expect and When to Stub?

I use NMock2, and I've drafted the following NMock classes to represent some common mock framework concepts: Expect: this specifies what a mocked method should return and says that the call must ...
Jeff Sternal's user avatar
  • 48.3k
24 votes
5 answers
14k views

Is there a way to unit test an async method?

I am using Xunit and NMock on .NET platform. I am testing a presentation model where a method is asynchronous. The method creates an async task and executes it so the method returns immediately and ...
Jiho Han's user avatar
  • 1,620
7 votes
3 answers
13k views

Test a public method which calls a private method using NUnit

I have a public method in a class that internally calls a particular private method within that class. It looks something like this : public class MyClass : IMyClassInterface { public List<int&...
Siddhant's user avatar
  • 571
3 votes
3 answers
14k views

Mocking a private field

I know a similar question has been asked but I have not found a clear solution. I'm trying to mock a private field from a large class. The private field gets instantiated in some earlier method and I'...
Samuel Heaney's user avatar
2 votes
1 answer
1k views

NMock issue testing against WPF and Dispatcher

Here's one for the threading junkies out there. I've got this method: public void RefreshMelts() { MeltsAvailable.Clear(); ThreadPool.QueueUserWorkItem(delegate { ...
Steve Smith's user avatar
2 votes
1 answer
5k views

C# Mock a Class With an Internal Property Setter

I am trying to build a unit test. The class Position is implemented in a third party library. But for my unit test I need the Size property to be set to a specific value. public class Position { ...
Konstantin's user avatar