Beispiel #1
0
        public void GivenTheSOAPServiceWillRespondWithASuccessfulPayload()
        {
            this.expectedResponse = SoapBuilder.CreateSoap11Envelope()
                                    .WithBody.AddEntry("<TestActionResponse>World!</TestActionResponse>")
                                    .Build().ToString();
            Logger.Log("Expected response: " + this.expectedResponse);

            this.nancySoapAdapter.RegisterSoapActionHandler(
                TestCaseRoutes.MySoap11Service,
                TestCaseSoapActions.MySoap11ServiceTestAction,
                (request, _) =>
            {
                Logger.Log($"Fake service for action '{TestCaseSoapActions.MySoap11ServiceTestAction}' is executing...");
                Logger.Log("Request message was: " + request.GetRequestBodyAsString());

                return(Soap11NancyResponseFactory.Create(this.expectedResponse, HttpStatusCode.OK));
            });
        }
        private void DefineHelloWorldSoapActionRoute(INancySoapAdapter soapAdapter)
        {
            const string mySoap11ServiceRoutePattern = "/MySampleSoap11Service";

            DefineSoapRoute(mySoap11ServiceRoutePattern, soapAdapter);

            soapAdapter.RegisterSoapActionHandler(
                mySoap11ServiceRoutePattern,
                "urn:MySampleSoap11Service#HelloWorldSoapAction",
                (_, _) =>
                Soap11NancyResponseFactory.Create(
                    SoapBuilder.CreateSoap11Envelope().WithBody.AddEntry("<root>Hello SOAP World!</root>"),
                    HttpStatusCode.OK));

            soapAdapter.RegisterSoapActionHandler(
                mySoap11ServiceRoutePattern,
                "urn:MySampleSoap11Service#AnotherSoapAction",
                (_, _) =>
                Soap11NancyResponseFactory.Create(
                    SoapBuilder.CreateSoap11Envelope().WithBody.AddEntry("<root>Hello Another SOAP World!</root>"),
                    HttpStatusCode.OK));
        }