开发者

How to design multiple WCF calls?

开发者 https://www.devze.com 2023-03-14 04:32 出处:网络
I have 2 WCF services implemented in C# that test a client-server interaction of a 3-rd party application. Let\'s say I have a server-side tester interface for WCF test service (I skipped the attribut

I have 2 WCF services implemented in C# that test a client-server interaction of a 3-rd party application. Let's say I have a server-side tester interface for WCF test service (I skipped the attributes ans simplified the interfaces)

interface IServerTester
{
    bool Start();
}

And a client side one:

interface IClientTester
{
    bool Start();
}
开发者_运维技巧

The purpose of those methods is merely to start the server and to start the client of the 3-rd party application. I am using NUnit to test it. On the upper level it looks like a C# transaction script, where I first start a server, then a client and lastly verify that they are communicating.

Later, I want to easily add more clients (start more than one), thus I need to add more WCF calls to IClientTester in my transaction script.

I can do something like this, with each client has its own endpoint

//Start server

//start client 1
//start client 2
//...
//start client N

I will need to reuse the code in many other tests.But it seems to be a rather long solution. Is there any better idea, or perhaps a pattern that I can adopt? Many thanks!


I'm not sure I completely followed your question, but it sounds to me like a need for Pub/Sub. It sounds like when the server starts, you want 1:M clients to be notified and also start, correct? If so, then the server could publish a message or event that the "clients" all subscribe to. You would not need to modify anything to add new clients, simply subscribe to the message or event in the new client implementation.

0

精彩评论

暂无评论...
验证码 换一张
取 消