473,394 Members | 1,750 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,394 software developers and data experts.

NMock problem??

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 A creates many objects of Class B.

For example..

public class DependenceClass
{
private string name = null;
public DependenceClass(string str)
{
this.name = str;
}

public DependenceClass()
{
}

public void Wish()
{
Console.WriteLine("Hello " + this.name );
}
public string GetName()
{
return this.name;
}
public void SetName(string str)
{
this.name = str;
}
}

public class UnderTest
{
private DependenceClass dC = null;
public UnderTest(DependenceClass dc)
{
this.dC = dc;
}
public string GetName()
{
return this.dC.GetName();
}
public void SetName(string str)
{
this.dC.SetName(str);
}
}

my test class

[TestFixture]
public class TestClass
{

private DependenceClass dependenceClass = null;

[Test]
public void Test1()
{
IMock mock = new DynamicMock(

typeof(DependenceClass));
dependenceClass =

(DependenceClass)mock.MockInstance;

mock.ExpectAndReturn("GetName","Naveen",null);
Assert.AreEqual

("Naveen",dependenceClass.GetName());
}
The test is failing and the excpetion is : System.ArgumentException, Method
GetName is not Virtual.

How do we test class with no vitual methods and Interfaces.
And also, I could not download nmock.dll from the sourceforge.
I have downloaded the source code and compiled it in VS.NET to the dll.
I'm adding this dll to my "references". If this is incorrect, could anyone
please send me the "nmock.dll". My email is "na****@worldsmart.com.au"

Cheers,

Naveen.

Nov 16 '05 #1
1 2527
Avi
There is a new framework called TypeMock
(http://www.typemock.com ). This framework allows you to mock
concrete classes, static methods and future creations of objects.
--
POST BY: http://www.dotNET.us - Need .NET? Just ask, Please dotNET.us
Nov 16 '05 #2

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

Similar topics

0
by: Bruce Davis | last post by:
I'm having a problem on windows (both 2000 and XP) with a multi-threaded tkinter gui application. The problem appears to be a deadlock condition when a child thread pops up a Pmw dialog window in...
2
by: Jason | last post by:
Is anyone familar with these two products? Should they be used together or is there an advantage of one over the other?
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...
117
by: Peter Olcott | last post by:
www.halting-problem.com
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.