c# - Unit Testing WCF Service is launching -
i'm new wcf. i've created basic service , engineer tested debugger , wcftestclient. i've never written own wcf client. need build unit tests service.
my classes:
ixservice cxservice cservicelauncher (yes, know c prefix not meet current standards, required client's standards.)
my service functionality can tested directly against xservice, need test cservicelauncher well. want connect uri , discover if there service running there , methods offers.
other questions read:
- addressaccessdeniedexception "your process not have access rights namespace" when unit testing wcf service - starts service host in unit test
- wcf unit test - recommends hosting service in unit test, makes vague reference connecting service via http
- wcf msmq unit testing - references msmq, more detailed need
- unit test wcf method - never knew auto generate tests, system isn't smart enough know assert.
test outline:
public void startuitest() { uri baseaddress = new uri("http://localhost:8080/myservice"); string soapaddress = "soap"; iuserinterface target = new cservicelauncher(baseaddress, soapaddress); try { assert.areequal(true, target.startui()); /// @todo assert.istrue(serviceisrunning); /// @todo assert.istrue(service.exposedmethods.count() > 4); assert.inconclusive("this tells nothing service"); } { target.stopui(); } }
i needed build simple client.
reference: http://webbeyond.blogspot.com/2012/11/wcf-simple-wcf-client-example.html
- add service reference test project
add test file:
using system.servicemodel;using mytests.servicereferencenamespace;
code inside try now:
assert.areequal(true, target.startui()); xserviceclient client = new xserviceclient(); client.getsessionid(); assert.areequal(communicationstate.opened, client.state, "wrong communication state after first call");
Comments
Post a Comment