473,407 Members | 2,326 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,407 software developers and data experts.

webservice facade

hello all,

i am wrinting unittest for my webservice facade, i could not directly pass the object that i am passing in my original webservice facade in my unit test, so i am trying to create a mock object(class which contains all the properties that are used by my original facade) and pass that into my unit test method, but i dont know how to do that, i mean how to create a mock object uin my unittest and pass that in my unittest method, could anyone please help me out pleasee...!!!
Oct 20 '08 #1
7 1639
nateraaaa
663 Expert 512MB
Create a test project that will contain your test fixtures and your mock classes/objects. Create a mock class that implements that same interface as your current class. In your test new up the mock object and set values for all of the properties you will need to complete your test.

Nathan
Oct 20 '08 #2
thank you very much for your reply !!!

yeah i did that, i have created a test project-added a new class which contains all the properties as in my original facade(mockclass.cs)-created a new method which calls my original method and in that method
1) i have created an instance for my facade
2) instance for the mock object(mockclass.cs)
3) given all the data for the properties that i have in mockclass.cs
4) Finally call the original method from the facade and pass instance of mockclass.cs

OK now in the last line of code facade.originalmethod(mockclass) -
Argument type mockclass is not assignable to parameter type original Object in my facade ..error...that is my problem,,did i make it clear for you..?? could you help me out pleasee
Oct 20 '08 #3
nateraaaa
663 Expert 512MB
If you could post your test and any information regarding the properties of your current class that would help. Have you stepped through your test using a debugger to see where the invalid cast is occurring?

Nathan
Oct 20 '08 #4
hey i couldnot build the project to step into the code,..i am getting that argument type to paramter type conversion is nmot possible error as i mentioned..

say my mock and original class contains the following properties

firstname
lastname
middlename
ssn
dob
phonenumber.
i have created a class with t he above properties and in my unittest

public void testmethod
{
facade instance;
mockobj instance;
mockobj.fname = wqerq;
mockobj.lname=asdqwed;
----------------------
----------------------

facadeinstance.originalmethod(mockobj);



So here in the above line where mockobj(passed into method), i am getting that error...argumnt type paramter tyep blah blah......

please help meee anyone !!!
Oct 20 '08 #5
nateraaaa
663 Expert 512MB
hey i couldnot build the project to step into the code,..i am getting that argument type to paramter type conversion is nmot possible error as i mentioned..

say my mock and original class contains the following properties

firstname
lastname
middlename
ssn
dob
phonenumber.
i have created a class with t he above properties and in my unittest

public void testmethod
{
facade instance;
mockobj instance;
mockobj.fname = wqerq;
mockobj.lname=asdqwed;
----------------------
----------------------

facadeinstance.originalmethod(mockobj);



So here in the above line where mockobj(passed into method), i am getting that error...argumnt type paramter tyep blah blah......

please help meee anyone !!!
What does originalmethod do? Can you just new up an instance of object (not mock object) and do assertions on what originalmethod returns with object as a parameter. I think in this instance you may be trying to use a mock object when you don't need to.

Nathan
Oct 20 '08 #6
Please Anyone Help Me Out How To Write A Unittest For A Webservice Facade...creating A Mock Object Testing !!!
Oct 20 '08 #7
hey i could not directly use the obvject in my main project
Oct 20 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: bdinmstig | last post by:
I am building various framework components for my team to use in development, and one of those components is a Facade for reading/writing user preferences. The idea is that preference settings...
11
by: FluffyCat | last post by:
In Febraury - April of 2002 I put together in Java examples of all 23 of the classic "Gang Of Four" design patterns for my website. Partly I wanted to get a better understanding of those patterns....
0
by: Dave Johnson | last post by:
I had a problem in my OO Design, the idea is that i have a DataRepository Class That i want to only inherit from it speacial methods accourding to the child class, like i want the Client Class to...
1
by: Dave Johnson | last post by:
I had a problem in my OO Design, the idea is that i have a DataRepository Class That i want to only inherit from it speacial methods accourding to the child class, like i want the Client Class to...
1
by: Dave Johnson | last post by:
I had a problem in my OO Design, the idea is that i have a DataRepository Class That i want to only inherit from it speacial methods accourding to the child class, like i want the Client Class to...
1
by: anonymous.user0 | last post by:
I'm a little confused about the Facade pattern. As I understand it, it's supposed to be a single, simplified interface into a larger amount of subsystems. The question I have is basically how...
5
by: yads12 | last post by:
We have a webservice that is a passthrough to a third party webservice. The third party webservice uses the classes that are named the same for both the submission and result message. We have...
1
by: ybi10 | last post by:
Hi, We have a product implmented with .NET (C#) as an application, it is released as .exe file plus .dll files. Now we want to make it as webservices, i.e. to make some of it's methods as...
1
by: splendid9 | last post by:
hi all, I am trying to test my webservice facade, i also need to create a mock object for that which i hav created in my original project. I need to create a mock object to test my facade in my...
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.