コード例 #1
0
        public void SetOutputValuesFromHandlerSetsValuesOnBoundInputs()
        {
            List<HttpOperationHandler> requestHandlers = new List<HttpOperationHandler>();
            List<HttpOperationHandler> responseHandlers = new List<HttpOperationHandler>();

            SHttpOperationHandler requestHandler1 = new SHttpOperationHandler();
            requestHandlers.Add(requestHandler1);
            requestHandler1.OnGetInputParameters01 = () => new HttpParameter[] { HttpParameter.RequestMessage };
            requestHandler1.OnGetOutputParameters01 = () => new HttpParameter[] { new HttpParameter("anotherMessage", typeof(HttpRequestMessage)), HttpParameter.RequestHeaders };

            SHttpOperationDescription operation = new SHttpOperationDescription();
            operation.Name = "operationName";
            operation.ReturnValue = HttpParameter.ResponseMessage;
            operation.InputParameters.Add(HttpParameter.RequestHeaders);
            operation.InputParameters.Add(new HttpParameter("aThirdMessage", typeof(HttpRequestMessage)));
            operation.OutputParameters.Add(new HttpParameter("unknown", typeof(DateTime)));

            SHttpOperationHandler responseHandler1 = new SHttpOperationHandler();
            responseHandlers.Add(responseHandler1);
            responseHandler1.OnGetInputParameters01 = () => new HttpParameter[] { new HttpParameter("aDateTime", typeof(DateTime)) };
            responseHandler1.OnGetOutputParameters01 = () => null;

            OperationHandlerPipelineInfo pipelineInfo = new OperationHandlerPipelineInfo(requestHandlers, responseHandlers, operation);
            object[] array = pipelineInfo.GetEmptyPipelineValuesArray();

            object obj1 = new object();
            object obj2 = new object();
            object[] requestHandlerOutputs = new object[] { obj1, obj2 };

            object obj3 = new HttpResponseMessage();
            object obj4 = DateTime.Now;
            object[] serviceOperationOutputs = new object[] { obj3, obj4 };

            pipelineInfo.SetOutputValuesFromHandler(1, requestHandlerOutputs, array);

            Assert.AreSame(obj1, array[2], "SetOutputValuesFromHandler didn't set the correct output values for the request handler.");
            Assert.AreSame(obj2, array[1], "SetOutputValuesFromHandler didn't set the correct output values for the request handler.");

            pipelineInfo.SetOutputValuesFromHandler(2, serviceOperationOutputs, array);

            Assert.AreSame(obj3, array[4], "SetOutputValuesFromHandler didn't set the correct output values for the service operation.");
            Assert.AreSame(obj4, array[3], "SetOutputValuesFromHandler didn't set the correct output values for the service operation.");
        }
コード例 #2
0
        public void SetHttpRequestMessageAddsHttpRequestMessageToTheArray()
        {
            List<HttpOperationHandler> requestHandlers = new List<HttpOperationHandler>();
            List<HttpOperationHandler> responseHandlers = new List<HttpOperationHandler>();

            SHttpOperationHandler requestHandler1 = new SHttpOperationHandler();
            requestHandlers.Add(requestHandler1);
            requestHandler1.OnGetInputParameters01 = () => new HttpParameter[] { HttpParameter.RequestMessage };
            requestHandler1.OnGetOutputParameters01 = () => new HttpParameter[] { new HttpParameter("anotherMessage", typeof(HttpRequestMessage)), HttpParameter.RequestHeaders };

            SHttpOperationDescription operation = new SHttpOperationDescription();
            operation.Name = "operationName";
            operation.ReturnValue = HttpParameter.ResponseMessage;
            operation.InputParameters.Add(HttpParameter.RequestHeaders);
            operation.InputParameters.Add(new HttpParameter("aThirdMessage", typeof(HttpRequestMessage)));
            operation.OutputParameters.Add(new HttpParameter("unknown", typeof(DateTime)));

            SHttpOperationHandler responseHandler1 = new SHttpOperationHandler();
            responseHandlers.Add(responseHandler1);
            responseHandler1.OnGetInputParameters01 = () => new HttpParameter[] { new HttpParameter("aDateTime", typeof(DateTime)) };
            responseHandler1.OnGetOutputParameters01 = () => null;

            OperationHandlerPipelineInfo pipelineInfo = new OperationHandlerPipelineInfo(requestHandlers, responseHandlers, operation);
            object[] array = pipelineInfo.GetEmptyPipelineValuesArray();

            HttpRequestMessage request = new HttpRequestMessage();
            pipelineInfo.SetHttpRequestMessage(request, array);

            Assert.AreSame(request, array[0], "The HttpRequestMessage was not added to the first array indice although the input parameter is bound to the HttpRequestMessage.");
            Assert.IsNull(array[1], "The HttpRequestMessage was added to the second array indice although the input parameter is not bound to the HttpRequestMessage.");
            Assert.AreSame(request, array[2], "The HttpRequestMessage was not added to the third array indice although the input parameter is bound to the HttpRequestMessage.");
            Assert.IsNull(array[3], "The HttpRequestMessage was added to the fourth array indice although the input parameter is not bound to the HttpRequestMessage.");
            Assert.IsNull(array[4], "The HttpRequestMessage was added to the fifth array indice although the input parameter is not bound to the HttpRequestMessage.");
        }
コード例 #3
0
        public void GetHttpResponseMessageReturnsNullIfNoHttpResponseMessage()
        {
            List<HttpOperationHandler> requestHandlers = new List<HttpOperationHandler>();
            List<HttpOperationHandler> responseHandlers = new List<HttpOperationHandler>();

            SHttpOperationHandler requestHandler1 = new SHttpOperationHandler();
            requestHandlers.Add(requestHandler1);
            requestHandler1.OnGetInputParameters01 = () => new HttpParameter[] { HttpParameter.RequestMessage };
            requestHandler1.OnGetOutputParameters01 = () => new HttpParameter[] { new HttpParameter("anInt", typeof(string)) };

            SHttpOperationDescription operation = new SHttpOperationDescription();
            operation.Name = "operationName";
            operation.ReturnValue = HttpParameter.ResponseMessage;
            operation.InputParameters.Add(new HttpParameter("anInt", typeof(int)));
            operation.OutputParameters.Add(new HttpParameter("unknown", typeof(DateTime)));

            SHttpOperationHandler responseHandler1 = new SHttpOperationHandler();
            responseHandlers.Add(responseHandler1);
            responseHandler1.OnGetInputParameters01 = () => new HttpParameter[] { new HttpParameter("aDateTime", typeof(DateTime)) };
            responseHandler1.OnGetOutputParameters01 = () => null;

            OperationHandlerPipelineInfo pipelineInfo = new OperationHandlerPipelineInfo(requestHandlers, responseHandlers, operation);
            object[] array = pipelineInfo.GetEmptyPipelineValuesArray();

            array[array.Length - 1] = null;
            HttpResponseMessage responseFromArray = pipelineInfo.GetHttpResponseMessage(array);

            Assert.IsNull(responseFromArray, "GetHttpResponseMessage() did not return the null value from the last indice of the array.");
        }
コード例 #4
0
        public void GetInputValuesForHandlerReturnsInputsForAGivenHandler()
        {
            List<HttpOperationHandler> requestHandlers = new List<HttpOperationHandler>();
            List<HttpOperationHandler> responseHandlers = new List<HttpOperationHandler>();

            SHttpOperationHandler requestHandler1 = new SHttpOperationHandler();
            requestHandlers.Add(requestHandler1);
            requestHandler1.OnGetInputParameters01 = () => new HttpParameter[] { HttpParameter.RequestMessage };
            requestHandler1.OnGetOutputParameters01 = () => new HttpParameter[] { new HttpParameter("anotherMessage", typeof(HttpRequestMessage)), HttpParameter.RequestHeaders };

            SHttpOperationDescription operation = new SHttpOperationDescription();
            operation.Name = "operationName";
            operation.ReturnValue = HttpParameter.ResponseMessage;
            operation.InputParameters.Add(HttpParameter.RequestHeaders);
            operation.InputParameters.Add(new HttpParameter("aThirdMessage", typeof(HttpRequestMessage)));
            operation.OutputParameters.Add(new HttpParameter("unknown", typeof(DateTime)));

            SHttpOperationHandler responseHandler1 = new SHttpOperationHandler();
            responseHandlers.Add(responseHandler1);
            responseHandler1.OnGetInputParameters01 = () => new HttpParameter[] { new HttpParameter("aDateTime", typeof(DateTime)) };
            responseHandler1.OnGetOutputParameters01 = () => null;

            OperationHandlerPipelineInfo pipelineInfo = new OperationHandlerPipelineInfo(requestHandlers, responseHandlers, operation);
            object[] array = pipelineInfo.GetEmptyPipelineValuesArray();

            object obj1 = new object();
            array[0] = obj1;

            object obj2 = new HttpRequestMessage().Headers;
            array[1] = obj2;

            object obj3 = new HttpRequestMessage();
            array[2] = obj3;

            object obj4 = new object();
            array[3] = obj4;

            object[] requestSourceInputs = pipelineInfo.GetInputValuesForHandler(0, array);
            object[] requestHandlerInputs = pipelineInfo.GetInputValuesForHandler(1, array);
            object[] serviceOperationInputs = pipelineInfo.GetInputValuesForHandler(2, array);
            object[] responseHandlerInputs = pipelineInfo.GetInputValuesForHandler(3, array);
            object[] responseSinkInputs = pipelineInfo.GetInputValuesForHandler(4, array);

            Assert.AreEqual(0, requestSourceInputs.Length, "GetInputValuesForHandler returned the wrong number of input values for the request source handler.");

            Assert.AreEqual(1, requestHandlerInputs.Length, "GetInputValuesForHandler returned the wrong number of input values for the request handler.");
            Assert.AreSame(obj1, requestHandlerInputs[0], "GetInputValuesForHandler returned the wrong input value for the request handler.");

            Assert.AreEqual(2, serviceOperationInputs.Length, "GetInputValuesForHandler returned the wrong number of input values for the service operation.");
            Assert.AreSame(obj2, serviceOperationInputs[0], "GetInputValuesForHandler returned the wrong input value for the service operation.");
            Assert.AreSame(obj3, serviceOperationInputs[1], "GetInputValuesForHandler returned the wrong input value for the service operation.");

            Assert.AreEqual(1, responseHandlerInputs.Length, "GetInputValuesForHandler returned the wrong number of input values for the response handler.");
            Assert.AreSame(obj4, responseHandlerInputs[0], "GetInputValuesForHandler returned the wrong input value for the response handler.");

            Assert.AreEqual(1, responseSinkInputs.Length, "GetInputValuesForHandler returned the wrong number of input values for the response sink handler.");
        }
コード例 #5
0
        public void GetEmptyPipelineValueArrayReturnsAnArrayInstance()
        {
            List<HttpOperationHandler> requestHandlers = new List<HttpOperationHandler>();
            List<HttpOperationHandler> responseHandlers = new List<HttpOperationHandler>();

            SHttpOperationHandler requestHandler1 = new SHttpOperationHandler();
            requestHandlers.Add(requestHandler1);
            requestHandler1.OnGetInputParameters01 = () => new HttpParameter[] { HttpParameter.RequestMessage };
            requestHandler1.OnGetOutputParameters01 = () => new HttpParameter[] { new HttpParameter("anInt", typeof(string)) };

            SHttpOperationDescription operation = new SHttpOperationDescription();
            operation.Name = "operationName";
            operation.ReturnValue = HttpParameter.ResponseMessage;
            operation.InputParameters.Add(new HttpParameter("anInt", typeof(int)));
            operation.OutputParameters.Add(new HttpParameter("unknown", typeof(DateTime)));

            SHttpOperationHandler responseHandler1 = new SHttpOperationHandler();
            responseHandlers.Add(responseHandler1);
            responseHandler1.OnGetInputParameters01 = () => new HttpParameter[] { new HttpParameter("aDateTime", typeof(DateTime)) };
            responseHandler1.OnGetOutputParameters01 = () => null;

            OperationHandlerPipelineInfo pipelineInfo = new OperationHandlerPipelineInfo(requestHandlers, responseHandlers, operation);
            object[] array = pipelineInfo.GetEmptyPipelineValuesArray();
            Assert.AreEqual(4, array.Length, "The returned array length was not the count of input parameters plus one for the HttpResponseMessage.");
        }