Ejemplo n.º 1
0
        public void Test()
        {
            SimpleSoapRequestRouter router = new SimpleSoapRequestRouter();
            router.AddRoute(
                "display",
                "urn:mediator_platform_eInvoices_RetailGateway",
                (c, x) => new LiteralSoapEnvelope("response"));

            DetergentSoapHttpHandler handler = new DetergentSoapHttpHandler();
            handler.RequestRouter = router;

            DummyHttpContext httpContext = new DummyHttpContext();
            string requestContent = @"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:urn='urn:mediator_platform_eInvoices_RetailGateway'>
               <soapenv:Header/>
               <soapenv:Body>
              <urn:display>
             <!--Optional:-->
             <request>
            <invoiceID>?</invoiceID>
            <!--Zero or more repetitions:-->
            <properties name='?'>?</properties>
             </request>
              </urn:display>
               </soapenv:Body>
            </soapenv:Envelope>";

            httpContext.SetRequestContent(
                "text/xml",
                Encoding.UTF8,
                requestContent);
            LiteralSoapEnvelope envelope = (LiteralSoapEnvelope)handler.ProcessRequest(httpContext);
            Assert.AreEqual("response", envelope.Content);
        }
Ejemplo n.º 2
0
        public void RouteDoesNotMatch()
        {
            Route route = new Route("product/(?<productId>[^//]+)/part/(?<partId>[^//]+)$");

            DummyHttpContext context = new DummyHttpContext(
                "http://google.com/service/",
                "/service/product/10/part");
            RouteMatchData matchData = route.Match(context);

            Assert.IsNull(matchData);
        }
Ejemplo n.º 3
0
        public void TestListPackagesWithWrongMethod()
        {
            context = new DummyHttpContext(
                "http://google.com/service",
                "/packages");
            context.RequestHttpMethod = HttpMethod.POST.ToString();

            IHttpResponse response = handler.ProcessRequest(context);
            RestErrorHttpResponse errorResponse = (RestErrorHttpResponse)response;
            Assert.AreEqual((int)HttpStatusCode.BadRequest, errorResponse.HttpStatusCode);
        }
Ejemplo n.º 4
0
        public void TestGetPackage()
        {
            context = new DummyHttpContext(
                "http://google.com/service",
                "/package/20");
            context.RequestHttpMethod = "GET";

            IHttpResponse response = handler.ProcessRequest(context);
            LiteralHttpResponse literal = (LiteralHttpResponse)response;
            Assert.AreEqual("get20", literal.Content);
        }
Ejemplo n.º 5
0
        public void TestListPackages(string path, string queryString)
        {
            context = new DummyHttpContext(
                "http://google.com/service",
                path,
                queryString);
            context.RequestHttpMethod = "GET";

            IHttpResponse response = handler.ProcessRequest(context);
            LiteralHttpResponse literal = (LiteralHttpResponse)response;
            Assert.AreEqual("list", literal.Content);
        }
Ejemplo n.º 6
0
        public void RouteIsMatch(string queryString)
        {
            Route route = new Route("product/(?<productId>[^//]+)/part/(?<partId>[^//]+)$");

            DummyHttpContext context = new DummyHttpContext(
                "http://google.com/service",
                "/product/10/part/20",
                queryString);
            RouteMatchData matchData = route.Match(context);

            Assert.IsNotNull(matchData);
            Assert.AreEqual("10", matchData.GetParameter("productId"));
            Assert.AreEqual("20", matchData.GetParameter("partId"));
        }