The Artima Developer Community
Sponsored Link •

C# Answers Forum
Problem: Nunit mock object Testing using C#

3 replies on 1 page. Most recent reply: Jul 17, 2006 2:19 AM by teh teh

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Ketan

Posts: 2
Nickname: ks1
Registered: Nov, 2004

Problem: Nunit mock object Testing using C# Posted: Nov 2, 2004 9:07 PM
Reply to this message Reply
Advertisement
Hi,

I m using mock objects in the Nunit unit tests using C#. I am facing this problem

suppose I have a object ABC which I want to test. This object has Another object XYZ as its member variable. Something like this.

class ABC{
XYX p; (XYZ can be fetched using the get method and there is no set method)
......

}

I am creating mock object of the XYZ class. I can successfully creat the XYZ mock object. When I create an instance of ABC class, an instance of XYZ is being created which I intend to overwrite wid my mock object. The problem is that the XYZ class in the ABC class just provides the Get method to the Class ABC, so I cannot overwrite the instance of XYZ with my mock object of XYZ. Is ther a hack to overcome this problem.

Thank you in advance.

K.


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Problem: Nunit mock object Testing using C# Posted: Nov 2, 2004 11:00 PM
Reply to this message Reply
ABC could have a constructor that takes an XYZ (or an interface that XYZ and the mock object implement).

Ketan

Posts: 2
Nickname: ks1
Registered: Nov, 2004

Re: Problem: Nunit mock object Testing using C# Posted: Nov 3, 2004 8:04 AM
Reply to this message Reply
thanks for ur reply. But I dont have the luxary to pass XYZ in the constructor of ABC.

-K.

teh teh

Posts: 1
Nickname: clteh9
Registered: Jul, 2006

Re: Problem: Nunit mock object Testing using C# Posted: Jul 17, 2006 2:19 AM
Reply to this message Reply
Hi Ketan,

I am doing the same testing with you. May i know whether you have find a solution for it. Hopefully can hear u soon, thanks.

Flat View: This topic has 3 replies on 1 page
Topic: woodgrovenet problem in MCMS 2002 Previous Topic   Next Topic Topic: Total Newbie. Need Help.

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use