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
0
votes
1 answer

How to Invoke the overloaded method in place of actual method

I have a Mocking.sln which has two projects: Student (Class Library) and StudentStat (Console Application) Student project has below details: private static Dictionary GetStudentData() { // Key: Student ID Value:…
user623566
0
votes
1 answer

NUnit says the test was successful

I am new to Unit Testing. The Unit Tests are succeeding in the below. I expect them to fail because Student.getCourse, unidergraduate.getCourse1 and postgraduate.getcourse1 return different values to what is being tested for e.g. "Student Course"…
w0051977
  • 15,099
  • 32
  • 152
  • 329
0
votes
2 answers

How to test if a method was called using nmock3?

I'm trying trying to set the expectation that a method will be called. But when I write the lambda expresion inside the Method method, I get an error because I'm not passing the parameters. I don't care about the instance of the parameters, I only…
Martín La Rosa
  • 790
  • 4
  • 17
0
votes
2 answers

How to expect an exception and still pass the test?

I have this: Expect.Once.On( someObj ).Method( "SomeMethod" ) .With(1) // correct value is 2, I want this to fail .Will( Throw.Exception( new Exception() ) ); An exception is thrown by nmock when it detects that I put 1 instead of 2. …
O.O
  • 11,077
  • 18
  • 94
  • 182
0
votes
1 answer

Getting System.TypeLoadException when using NMock with NUnit from command line

I'm trying to run some NUnit tests that use NMock2 for mocking. These tests are to be run from a Makefile as part of our build process. However the tests fail to load. I can get everything working from within Monodevelop - just cant seem to get it…
Michael Anderson
  • 70,661
  • 7
  • 134
  • 187
-1
votes
2 answers

How to mock GetType() method in NMock

I have some production code like private bool IsTypeEqual(object theFirstObject, object theSecondObject) { if(theFirstObject.GetType()==theSecondObject.GetType()) { return true; } else { …
Nikhil Verma
1 2 3
4