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
3 answers

Creating mock objects

I created simple GUI in WPF. I would like to show there some data got from database. But for now I have only GUI and few functions that do simple calculations on received data. I know that my goal is to create mock objects that would generate some…
0
votes
1 answer

Using NMock with ByRef parameters

I have to work with an API that uses a lot of by-reference parameters. I'm just beginning to use NMock, and I'm having trouble seeing how to make NMock actually modify one of those by-ref parameters to a specific value. Am I missing something, or…
scott8035
  • 424
  • 1
  • 6
  • 15
0
votes
1 answer

NUnit and NMock- ExpectAndReturn - How to tell NMock to expect CreateObjectSet

I have the following var objSet = new DynamicMock(typeof(IObjectSet)); objSet.ExpectAndReturn("GetAll", new List { new Nationality { //obj init here }, new Nationality { //obj init here …
glosrob
  • 6,631
  • 4
  • 43
  • 73
0
votes
1 answer

Conditional mocking using NMock

i wonder if someone is able to help me with my problem. I have to stub a method which is able to perform conditional mocking. In short, i like the stub function to return different objects of the same class depending on when it is called.…
zhengtonic
  • 720
  • 12
  • 25
0
votes
2 answers

Unable to use nMock GetProperty routine on a property of an inherited object

I am getting this error when trying to set an expectation on an object I mocked that inherits from MembershipUser: ContactRepositoryTests.UpdateTest : FailedSystem.InvalidProgramException: JIT Compiler encountered an internal limitation. Server…
Chris
0
votes
1 answer

How can I use an NMock3 Method Parameter in a "Will" Action

I'm attempting to mock a method that takes an exception as a parameter and under certain circumstances may throw that exception. Is there a way to mock this such that the mocked method does that? I'm figuring a syntax something like…
0
votes
1 answer

How do I specify that the collection parameter for a mocked method should have exactly one element

I am setting expectations for a method that takes a single IList<> parameter. How do I express in NMock3 the following statement: Method XX of the mock should be called exactly once with a list object that contains exactly one item. The solution I…
Tevya
  • 836
  • 1
  • 10
  • 23
0
votes
1 answer

Does NMock support SharePoint?

Does any version of NMock support mocking SharePoint? I am using Visual Studio 2012, SharePoint 2013. This can be any version of NMock 1, 2, or the most recent version 3. I have tried looking at the documentation and nothing jumped out at me to say…
RSM
  • 14,540
  • 34
  • 97
  • 144
0
votes
2 answers

How can I mock an internal interface using NMock2?

If I try this, I just get an exception: System.TypeLoadException : Access is denied: 'Namespace.IInternalInterface'. Making the interface public is not an acceptable solution. I don't want to change the visiblity of my API in order to test it.
Matt Brunell
  • 10,141
  • 3
  • 34
  • 46
0
votes
0 answers

How to mock/stub a Java object in C# code?

My C# code is using a class written in Java (IKVM). That Java class provides 2 methods that I am calling in my C# code: GetInstance() - It simply returns the instance of that Java class. GetSet() - returns a java.util.Set that I iterate over to do…
Andy
  • 2,393
  • 4
  • 18
  • 20
0
votes
1 answer

mocking method with an array argument which will change after call

I have an issue with mocking method call with reference argument (byte[]) that will change after the call: private Mock mSocket; byte[] buffer = new byte[1000]; mSocket.Expects.One.Method(x =>…
HBCoder
  • 3
  • 2
0
votes
1 answer

NMock Method Mixing WithArguments and WithAnyArguments

Performing unit testing I had a mistake mocking a method. I am trying to return different results depending on the Parameters to input and otherwise return a default answer. The problem is that always I am receiving the default…
Xemadk
  • 53
  • 1
  • 4
0
votes
1 answer

Failing in Code coverage Test with a simple class constructor

I have a class: public class SourceServerProvider : ISourceServerProvider { private readonly ISourceServer _sourceServer; public SourceServerProvider() :this(new SourceServer()) { } public…
Tun
  • 824
  • 3
  • 16
  • 30
0
votes
1 answer

Unit testing levels of classes with Nunit and Nmock

I have levels of classes and interfaces, namely Level1, Level2 and Level3. Class Level1 depends on class Level2 and class Level2 depends on class Level3. Here is the code for that design: public interface ILevel1 { string GetData(); } public…
Alagesan Palani
  • 1,984
  • 4
  • 28
  • 53
0
votes
1 answer

NMock Problem with Lists

I have the following test using NMock which fails. It used to work when the result from the service call was passed to the view but it now fails since the results are converted to dto's. I think this might mean I need to create a custom matcher but…
m0gb0y74
  • 5
  • 3