chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
Hi All,
i do have a tricky situation here , i have calls that span across layers, I am really confused where to start with the mock , this is the example

partial class Service
{
public method getName(string strid)
{
SerialLizeresource sr=new SerialLizeresource(MyController.getNames(strid);
}
}

static MyController
{

static name getNames(string strid)
{
return name.createname(DAS.getName(id);
}

}


An then i have the data layer also to make the call.

Can somebody please help me out in finding how to start


Thanks in Advance
thomson
asked by tomexplore (1.8k points)

4 Answers

0 votes
Hi,

I think that for start you will need to decide what layer you want to test.
A common approach is to test each layer in Isolation by mocking the underlying layers.

for example:
1) Test the Service Layer getName functionality by mocking out the Control layer. in this test you will only make sure that the serialization process is done correctly.
2) Test the Controller by mocking out the DAS - here you will only make sure that the name creation mechanism is done properly.

At the end of course you will also need to write some integration tests. i.e. test that everything works together. In those test you probably wont use mocking at all.

Hope this help, if not try to flesh out the given code and we can even try to write a simple test together.
answered by lior (13.2k points)
0 votes
Hi Lior,
Thanks for the heads up, can u hep me out a bit to start writing it


Just a initial start for the above example for example can you help me out in writing the
Test the Service Layer getName functionality by mocking out the Control layer. in this test you will only make sure that the serialization process is done correctly

How to mock the Control Layer

Thanks in Advance

thomson
answered by tomexplore (1.8k points)
0 votes
Hi All,
i have just started with my first obstacle

partial class Service
{
public SerialLizeresource getName(string strid)
{
SerialLizeresource sr=new SerialLizeresource(MyController.getNames(strid);
}
}




And i need to mock my controller also , i have started like this

private List<Names> _fakeNames = new List<Names>
{
new Names(1,"thomson"),
new Names(2,"sony")

};

using (RecordExpectations expect = RecorderManager.StartRecording())
{

Controller.GetNames(1);
expect.Return(_fakeNames);


}


Any help to start this will be appreciated

thanks in Advance
thomson
answered by tomexplore (1.8k points)
0 votes
answered by bradgearon (1.5k points)
...