473,382 Members | 1,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

NMock DynamicMock - Inherited Interface Members

Hi All,

Not sure if this is the correct forum for this but I cant seem to find
a more specific one for NMock...

I'm trying to use the dynamic mocking functionality of NMock and,
whilst its great, I've run into a problem. Say intefaceA derives from
interfaceB and so gets interfaceB's members:

public interfaceA : intefaceB
{
...
}

public interfaceB
{
public bool Blah { get; }
}

Ok now I want to create a dynamic mock for interfaceA:

DynamicMock dynamicMockInfo = new DynamicMock(typeof(interfaceA));
dynamicMockInfo.SetupResult("Blah", true, new Type[0]);

Thing is it fails with a NullReferenceException in nmock.dll, and will
only work if I also put the Blah property into interfaceA. Anyone got
any idea how I resolve this?

Ta,

Colin

Nov 22 '05 #1
2 2909
colinjack <co********@gmail.com> wrote:
Not sure if this is the correct forum for this but I cant seem to find
a more specific one for NMock...

I'm trying to use the dynamic mocking functionality of NMock and,
whilst its great, I've run into a problem. Say intefaceA derives from
interfaceB and so gets interfaceB's members:

public interfaceA : intefaceB
{
...
}

public interfaceB
{
public bool Blah { get; }
}

Ok now I want to create a dynamic mock for interfaceA:

DynamicMock dynamicMockInfo = new DynamicMock(typeof(interfaceA));
dynamicMockInfo.SetupResult("Blah", true, new Type[0]);

Thing is it fails with a NullReferenceException in nmock.dll, and will
only work if I also put the Blah property into interfaceA. Anyone got
any idea how I resolve this?


Personally, I'd suggest giving EasyMockNET a go instead :)
http://sourceforge.net/projects/easymocknet/

I recently evaluated (fairly briefly) NMock, EasyMockNET and one other
whose name escapes me. EasyMockNET follows the EasyMock model, which
means you call the methods directly on the mock you've created - much
nicer than specifying the method name as a string!

Unfortunately, the distribution is just a DLL at the moment which
requires an old version of NUnit. I fetched the whole thing from CVS
and added a very simple AssertionException, which is all it really uses
from NUnit. That way you also get the documentation, which bizarrely is
only in CVS!

Just to warn you, EasyMockNET doesn't seem to have had any publicity,
and seems to be almost abandoned at the moment (no code changes in 5
months). However, it seems to work well, and I'm going to try to find
out what the project status really is, and probably volunteer as a
maintainer. (I'm using it professionally now, and we'll soon have got
enough test code for it to be a pain to change to a different framework
which doesn't have the same abilities.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #2
Hi Jon,

Ahh yes I'd had a look at that too and decided against using it simply
because .NET unit testing articles seem to focus on NMock but now
you've recommended I'll give it a shot.

Thanks,

Colin Jack

Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: thechaosengine | last post by:
Hi all, Is there a way to hide a member in a subclass that has been inherited from a base class? Lets leave aside any issues regarding whether its a good idea for a moment. Here's an example...
2
by: colinjack | last post by:
Hi All, Not sure if this is the correct forum for this but I cant seem to find a more specific one for NMock... I'm trying to use the dynamic mocking functionality of NMock and, whilst its...
5
by: Earl Teigrob | last post by:
Is there a way to rename the public properties of a inherited class? I am inheriting an asp.net control (class) and am adding addtional functionality. (in this case, up to 3 borders on an...
1
by: Naveen Mukkelli | last post by:
Hi, Can we use NMock to simulate concrete classes?. In my case, I have to a class with no interfaces and virtual methods. I've got 2 classes A, B, dependent on each other. That means, one Class...
4
by: Dan | last post by:
I have a need to make a set of classes that all share the same public methods, some implementation and some data. So, I made an abstract base (BaseClass) with an interface (IBaseClass) and a...
1
by: skootr | last post by:
I have a Public Interface defined in a class module. I also have a form that implements that interface After building the solution, I added an Inherited Form (inherited from the above-mentioned...
6
by: Peter Oliphant | last post by:
I just discovered that the ImageList class can't be inherited. Why? What could go wrong? I can invision a case where someone would like to add, say, an ID field to an ImageList, possible so that...
0
by: swiftanthony | last post by:
Hi, I am currently trialing TDD (Test Driven Development) and have had good results so far. I recently heard about NMock and decided to give it a try, unfortunately I seem to be falling at the...
14
by: lovecreatesbea... | last post by:
Could you tell me how many class members the C++ language synthesizes for a class type? Which members in a class aren't derived from parent classes? I have read the book The C++ Programming...
2
by: eggie5 | last post by:
Hi, I have a class Dog which derives from Animal. Suppose my instance of Dog is bulldog. bulldog has all the members of Animal plus Dog. How can copy just the members from Dog to a new Dog...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.