How to call WCF service in the FitNesse test?

216 Views Asked by At

I'm trying to call WCF service in the FitNesse test. When I'm trying to initialize a client with the following code:

    using (var client = new Status.StatusSoapClient())
    {
        client.Endpoint.Address = new EndpointAddress(url);
        response = client.GetProductionTicketStatus(dealerId, orderId, orderLineId);

    }

I get an error:

System.InvalidOperationException: Could not find default endpoint element that references contract 'Status.StatusSoap' in the ServiceModel client configuration section.

which makes sense because .NET Framework does not support configuration for DLLs.

MSDN Library says: "You have to move your configuration code into the configuration file recognized by your hosting environment". But I'm not sure if this is possible to be done for FitNesse.

So I tried to create binding myself without trying to read it from config

    var binding = new BasicHttpBinding();
    binding.SendTimeout = new TimeSpan(0, 0, 0, 0, 100000);
    binding.OpenTimeout = new TimeSpan(0, 0, 0, 0, 100000);
    binding.MaxReceivedMessageSize = 10000;
    binding.ReaderQuotas.MaxStringContentLength = 10000;
    binding.ReaderQuotas.MaxDepth = 10000;
    binding.ReaderQuotas.MaxArrayLength = 10000;
    var endpoint = new EndpointAddress(url);
    var myClient = new Status.StatusSoapClient(binding, endpoint);
    response = myClient.GetProductionTicketStatus(dealerId, orderId, orderLineId);

But when I try to run the test with this code I get the "Testing was interrupted and results are incomplete." error on FitNesse.

This answer https://stackoverflow.com/a/646177/2211481 suggests to make a copy of the app.config for the testrunner. When I copy my app.config to Runner.exe.config, put it to the Runner folder and run the initial code again I get the "Testing was interrupted and results are incomplete." error on FitNesse again.

Is there a way I could solve this?

2

There are 2 best solutions below

0
On

Got it working by defining COMMAND_PATTERN as described here: http://twenty6-jc.blogspot.nl/2010/07/wcf-and-fitnesse-how-to-load-clients.html

!define COMMAND_PATTERN {%m -a c:\projects\someapplication\acceptancetests\acceptancetests.dll.config -r fitSharp.Slim.Service.Runner,c:\tools\nslim\fitsharp.dll %p}

Making a copy of the app.config for the testrunner also worked in the end.

I was getting "Testing was interrupted and results are incomplete." error because of a mistake in my code which I solved after debugging.

0
On

See this post: FitNesse App.Config

NetRunner uses configuration file for the first dll from the list.

For exampple, for the line:

!path C:\Probjects\HelloWorld\bin\Debug\FitNesseHelloWorld1.dll, C:\Probjects\HelloWorld\bin\Debug\FitNesseHelloWorld2.dll

NetRunner will use configuration file "C:\Probjects\HelloWorld\bin\Debug\FitNesseHelloWorld1.dll.config"