c# - How To Unit Test a WFC Web Socket -
i trying create unit test in order step through code access error occurs when try access data via entity framework. have not found examples searches answers. try create client in second line of code , a "client.innerchannel threw exception of type system.servicemodel.communicationobjectfaultedexception" when examine client.innerchannel in debugger. websocket works fine in client doing simple example tutorial throws error can't examine try access db via entity framework.
i working off code provided in tutorial http://www.codeproject.com/articles/619343/using-websocket-in-net-part
my interfaces defined below:
namespace priceblotterwebsocket { [servicecontract(callbackcontract = typeof(ipriceblottercallback))] public interface ipriceblotterwebsocket { [operationcontract(isoneway = true, action = "*")] task sendmessagetoserver(message msg); } [servicecontract] public interface ipriceblottercallback { [operationcontract(isoneway = true, action = "*")] task sendmessagetoclient(message msg); } } and unit test:
[testclass] public class unittest1 { internal class callbackhandler : ipriceblottercallback { public async task sendmessagetoclient(message msg) { system.diagnostics.debug.write(msg); } } [testmethod] public void testmethod1() { var context = new instancecontext(new callbackhandler()); var client = new priceblottewebsocketservice.priceblotterwebsocketclient("custombinding_ipriceblotterwebsocket"); //why can't call client.sendmessagetoserver ? } } test project client config:
<configuration> <system.servicemodel> <bindings> <custombinding> <binding name="custombinding_ipriceblotterwebsocket"> <textmessageencoding messageversion="soap12" /> <httptransport> <websocketsettings transportusage="always" subprotocol="soap" /> </httptransport> </binding> </custombinding> </bindings> <client> <endpoint address="ws://localhost:54426/service1.svc" binding="custombinding" bindingconfiguration="custombinding_ipriceblotterwebsocket" contract="priceblottewebsocketservice.ipriceblotterwebsocket" name="custombinding_ipriceblotterwebsocket" /> </client> </system.servicemodel> </configuration>
Comments
Post a Comment