public void Constructor() { HttpOperationHandler[] handlers = new HttpOperationHandler[0]; SHttpOperationDescription operation = new SHttpOperationDescription() { ReturnValue = HttpParameter.ResponseMessage }; OperationHandlerPipelineInfo pipelineInfo = new OperationHandlerPipelineInfo(handlers, handlers, operation); MOperationHandlerPipelineInfo molePipelineInfo = new MOperationHandlerPipelineInfo(pipelineInfo); HttpRequestMessage requestAtCall = null; object[] valuesAtCall = null; molePipelineInfo.GetEmptyPipelineValuesArray = () => new object[0]; molePipelineInfo.SetHttpRequestMessageHttpRequestMessageObjectArray = (req, values) => { requestAtCall = req; valuesAtCall = values; }; HttpRequestMessage request = new HttpRequestMessage(); OperationHandlerPipelineContext context = new OperationHandlerPipelineContext(pipelineInfo, request); Assert.IsNotNull(requestAtCall, "HttpRequestMessage was not set in pipeline info."); Assert.IsNotNull(valuesAtCall, "Values were not set in pipeline info."); HttpAssert.AreEqual(request, requestAtCall); }
public void GetHttpResponseMessageCallsPipelineInfo() { HttpRequestMessage request = new HttpRequestMessage(); HttpResponseMessage response = new HttpResponseMessage() { RequestMessage = request }; HttpOperationHandler[] handlers = new HttpOperationHandler[0]; SHttpOperationDescription operation = new SHttpOperationDescription() { ReturnValue = HttpParameter.ResponseMessage }; OperationHandlerPipelineInfo pipelineInfo = new OperationHandlerPipelineInfo(handlers, handlers, operation); MOperationHandlerPipelineInfo molePipelineInfo = new MOperationHandlerPipelineInfo(pipelineInfo); molePipelineInfo.GetEmptyPipelineValuesArray = () => new object[0]; molePipelineInfo.SetHttpRequestMessageHttpRequestMessageObjectArray = (req, values) => { }; molePipelineInfo.GetHttpResponseMessageObjectArray = (values) => response; OperationHandlerPipelineContext context = new OperationHandlerPipelineContext(pipelineInfo, request); HttpResponseMessage responseReturned = context.GetHttpResponseMessage(); Assert.IsNotNull(responseReturned, "HttpResponseMessage was not returned."); HttpAssert.AreEqual(response, responseReturned); }
internal OperationHandlerPipeline( IEnumerable <HttpOperationHandler> requestHandlers, IEnumerable <HttpOperationHandler> responseHandlers, HttpOperationDescription operation) { if (requestHandlers == null) { throw Fx.Exception.ArgumentNull("requestHttpOperationHandlers"); } if (responseHandlers == null) { throw Fx.Exception.ArgumentNull("responseHttpOperationHandlers"); } if (operation == null) { throw Fx.Exception.ArgumentNull("operation"); } this.requestHandlers = requestHandlers.ToArray(); this.responseHandlers = responseHandlers.ToArray(); this.requestHandlersCount = this.requestHandlers.Length; this.responseHandlersCount = this.responseHandlers.Length; this.pipelineContextInfo = new OperationHandlerPipelineInfo(this.requestHandlers, this.responseHandlers, operation); }
internal OperationHandlerPipeline( IEnumerable<HttpOperationHandler> requestHandlers, IEnumerable<HttpOperationHandler> responseHandlers, HttpOperationDescription operation) { if (requestHandlers == null) { throw Fx.Exception.ArgumentNull("requestHttpOperationHandlers"); } if (responseHandlers == null) { throw Fx.Exception.ArgumentNull("responseHttpOperationHandlers"); } if (operation == null) { throw Fx.Exception.ArgumentNull("operation"); } this.requestHandlers = requestHandlers.ToArray(); this.responseHandlers = responseHandlers.ToArray(); this.requestHandlersCount = this.requestHandlers.Length; this.responseHandlersCount = this.responseHandlers.Length; this.pipelineContextInfo = new OperationHandlerPipelineInfo(this.requestHandlers, this.responseHandlers, operation); }
internal OperationHandlerPipelineContext(OperationHandlerPipelineInfo pipelineInfo, HttpRequestMessage request) { Fx.Assert(pipelineInfo != null, "The 'pipelineInfo' parameter should not be null."); this.pipelineInfo = pipelineInfo; this.handlerIndex = 1; this.pipelineValues = this.pipelineInfo.GetEmptyPipelineValuesArray(); this.pipelineInfo.SetHttpRequestMessage(request, this.pipelineValues); }
internal OperationHandlerPipelineContext(OperationHandlerPipelineInfo pipelineInfo, HttpRequestMessage request) { Fx.Assert(pipelineInfo != null, "The 'pipelineInfo' parameter should not be null."); this.pipelineInfo = pipelineInfo; this.handlerIndex = 1; this.pipelineValues = this.pipelineInfo.GetEmptyPipelineValuesArray(); this.pipelineInfo.SetHttpRequestMessage(request, this.pipelineValues); }
public void ConstructorAcceptsAnEmptyResponseHandlersCollection() { List<HttpOperationHandler> requestHandlers = new List<HttpOperationHandler>(); SHttpOperationHandler handler = new SHttpOperationHandler(); handler.OnGetInputParameters01 = () => null; handler.OnGetOutputParameters01 = () => null; requestHandlers.Add(handler); List<HttpOperationHandler> responseHandlers = new List<HttpOperationHandler>(); SHttpOperationDescription operation = new SHttpOperationDescription(); operation.ReturnValue = HttpParameter.ResponseMessage; OperationHandlerPipelineInfo pipelineInfo = new OperationHandlerPipelineInfo(requestHandlers, responseHandlers, operation); }
public void GetHttpResponseMessageCallsPipelineInfo() { HttpRequestMessage request = new HttpRequestMessage(); HttpResponseMessage response = new HttpResponseMessage() { RequestMessage = request }; HttpOperationHandler[] handlers = new HttpOperationHandler[0]; SHttpOperationDescription operation = new SHttpOperationDescription() { ReturnValue = HttpParameter.ResponseMessage }; OperationHandlerPipelineInfo pipelineInfo = new OperationHandlerPipelineInfo(handlers, handlers, operation); MOperationHandlerPipelineInfo molePipelineInfo = new MOperationHandlerPipelineInfo(pipelineInfo); molePipelineInfo.GetEmptyPipelineValuesArray = () => new object[0]; molePipelineInfo.SetHttpRequestMessageHttpRequestMessageObjectArray = (req, values) => { }; molePipelineInfo.GetHttpResponseMessageObjectArray = (values) => response; OperationHandlerPipelineContext context = new OperationHandlerPipelineContext(pipelineInfo, request); HttpResponseMessage responseReturned = context.GetHttpResponseMessage(); Assert.IsNotNull(responseReturned, "HttpResponseMessage was not returned."); HttpAssert.AreEqual(response, responseReturned); }
public void SetOutputValuesAndAdvanceCallsPipelineInfo() { HttpRequestMessage request = new HttpRequestMessage(); HttpResponseMessage response = new HttpResponseMessage() { RequestMessage = request }; HttpOperationHandler[] handlers = new HttpOperationHandler[0]; SHttpOperationDescription operation = new SHttpOperationDescription() { ReturnValue = HttpParameter.ResponseMessage }; OperationHandlerPipelineInfo pipelineInfo = new OperationHandlerPipelineInfo(handlers, handlers, operation); int indexAtCall = -1; object[] valuesAtCall = null; object[] pipelineValuesAtCall = null; MOperationHandlerPipelineInfo molePipelineInfo = new MOperationHandlerPipelineInfo(pipelineInfo); molePipelineInfo.GetEmptyPipelineValuesArray = () => new object[0]; molePipelineInfo.SetHttpRequestMessageHttpRequestMessageObjectArray = (req, values) => { }; molePipelineInfo.SetOutputValuesFromHandlerInt32ObjectArrayObjectArray = (index, values, pipelineValues) => { indexAtCall = index; valuesAtCall = values; pipelineValuesAtCall = pipelineValues; }; OperationHandlerPipelineContext context = new OperationHandlerPipelineContext(pipelineInfo, request); context.SetOutputValuesAndAdvance(new object[0]); Assert.AreEqual(1, indexAtCall, "Handler index was not set."); Assert.IsNotNull(valuesAtCall, "Values were not set."); Assert.IsNotNull(pipelineValuesAtCall, "Pipeline values were not set."); }
public void Constructor() { HttpOperationHandler[] handlers = new HttpOperationHandler[0]; SHttpOperationDescription operation = new SHttpOperationDescription() { ReturnValue = HttpParameter.ResponseMessage }; OperationHandlerPipelineInfo pipelineInfo = new OperationHandlerPipelineInfo(handlers, handlers, operation); MOperationHandlerPipelineInfo molePipelineInfo = new MOperationHandlerPipelineInfo(pipelineInfo); HttpRequestMessage requestAtCall = null; object[] valuesAtCall = null; molePipelineInfo.GetEmptyPipelineValuesArray = () => new object[0]; molePipelineInfo.SetHttpRequestMessageHttpRequestMessageObjectArray = (req, values) => { requestAtCall = req; valuesAtCall = values; }; HttpRequestMessage request = new HttpRequestMessage(); OperationHandlerPipelineContext context = new OperationHandlerPipelineContext(pipelineInfo, request); Assert.IsNotNull(requestAtCall, "HttpRequestMessage was not set in pipeline info."); Assert.IsNotNull(valuesAtCall, "Values were not set in pipeline info."); HttpAssert.AreEqual(request, requestAtCall); }
public void GetInputValuesCallsPipelineInfo() { HttpOperationHandler[] handlers = new HttpOperationHandler[0]; SHttpOperationDescription operation = new SHttpOperationDescription() { ReturnValue = HttpParameter.ResponseMessage }; OperationHandlerPipelineInfo pipelineInfo = new OperationHandlerPipelineInfo(handlers, handlers, operation); MOperationHandlerPipelineInfo molePipelineInfo = new MOperationHandlerPipelineInfo(pipelineInfo); molePipelineInfo.GetEmptyPipelineValuesArray = () => new object[0]; molePipelineInfo.SetHttpRequestMessageHttpRequestMessageObjectArray = (req, values) => { }; bool calledForValues = false; int handlerIndexAtCall = -1; object[] valuesAtCall = null; molePipelineInfo.GetInputValuesForHandlerInt32ObjectArray = (index, values) => { calledForValues = true; handlerIndexAtCall = index; valuesAtCall = values; return(new object[0]); }; HttpRequestMessage request = new HttpRequestMessage(); OperationHandlerPipelineContext context = new OperationHandlerPipelineContext(pipelineInfo, request); object[] returnedValues = context.GetInputValues(); Assert.IsTrue(calledForValues, "PipelineInfo was not called for its values."); Assert.AreEqual(1, handlerIndexAtCall, "Handler index should have been 0."); Assert.IsNotNull(valuesAtCall, "Values at call should have not been null."); Assert.IsNotNull(returnedValues, "Returned values were null."); Assert.AreEqual(0, returnedValues.Length, "Returned values were incorrect length."); }
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."); }
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."); }
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."); }
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."); }
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."); }
public void ConstructorCallsOnGetInputParametersOfAllRequestHandlers() { List<HttpOperationHandler> requestHandlers = new List<HttpOperationHandler>(); List<HttpOperationHandler> responseHandlers = new List<HttpOperationHandler>(); SHttpOperationHandler requestHandler1 = new SHttpOperationHandler(); requestHandlers.Add(requestHandler1); bool onGetInputParamters1Called = false; requestHandler1.OnGetOutputParameters01 = () => null; requestHandler1.OnGetInputParameters01 = () => { onGetInputParamters1Called = true; return null; }; SHttpOperationHandler requestHandler2 = new SHttpOperationHandler(); requestHandlers.Add(requestHandler2); bool onGetInputParamters2Called = false; requestHandler2.OnGetOutputParameters01 = () => null; requestHandler2.OnGetInputParameters01 = () => { onGetInputParamters2Called = true; return null; }; SHttpOperationDescription operation = new SHttpOperationDescription(); operation.ReturnValue = HttpParameter.ResponseMessage; OperationHandlerPipelineInfo pipelineInfo = new OperationHandlerPipelineInfo(requestHandlers, responseHandlers, operation); Assert.IsTrue(onGetInputParamters1Called, "The OnGetInputParameters() method of requestHandler1 was not called."); Assert.IsTrue(onGetInputParamters2Called, "The OnGetInputParameters() method of requestHandler2 was not called."); }
public void ConstructorDoesNotThrowIfTheOperationHandlerPipelineCanBindSuccessfully() { 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); }
public void ConstructorDoesNotCallOnHandleOfAnyResponseHandlers() { List<HttpOperationHandler> requestHandlers = new List<HttpOperationHandler>(); List<HttpOperationHandler> responseHandlers = new List<HttpOperationHandler>(); SHttpOperationHandler responseHandler1 = new SHttpOperationHandler(); responseHandlers.Add(responseHandler1); responseHandler1.OnGetInputParameters01 = () => null; responseHandler1.OnGetOutputParameters01 = () => null; responseHandler1.OnHandleObjectArray = (inputs) => { Assert.Fail("OnHandle() was called."); return null; }; SHttpOperationHandler responseHandler2 = new SHttpOperationHandler(); responseHandlers.Add(responseHandler2); responseHandler2.OnGetInputParameters01 = () => null; responseHandler2.OnGetOutputParameters01 = () => null; responseHandler2.OnHandleObjectArray = (inputs) => { Assert.Fail("OnHandle() was called."); return null; }; SHttpOperationDescription operation = new SHttpOperationDescription(); operation.ReturnValue = HttpParameter.ResponseMessage; OperationHandlerPipelineInfo pipelineInfo = new OperationHandlerPipelineInfo(requestHandlers, responseHandlers, operation); }
public void SetOutputValuesAndAdvanceCallsPipelineInfo() { HttpRequestMessage request = new HttpRequestMessage(); HttpResponseMessage response = new HttpResponseMessage() { RequestMessage = request }; HttpOperationHandler[] handlers = new HttpOperationHandler[0]; SHttpOperationDescription operation = new SHttpOperationDescription() { ReturnValue = HttpParameter.ResponseMessage }; OperationHandlerPipelineInfo pipelineInfo = new OperationHandlerPipelineInfo(handlers, handlers, operation); int indexAtCall = -1; object[] valuesAtCall = null; object[] pipelineValuesAtCall = null; MOperationHandlerPipelineInfo molePipelineInfo = new MOperationHandlerPipelineInfo(pipelineInfo); molePipelineInfo.GetEmptyPipelineValuesArray = () => new object[0]; molePipelineInfo.SetHttpRequestMessageHttpRequestMessageObjectArray = (req, values) => { }; molePipelineInfo.SetOutputValuesFromHandlerInt32ObjectArrayObjectArray = (index, values, pipelineValues) => { indexAtCall = index; valuesAtCall = values; pipelineValuesAtCall = pipelineValues; }; OperationHandlerPipelineContext context = new OperationHandlerPipelineContext(pipelineInfo, request); context.SetOutputValuesAndAdvance(new object[0]); Assert.AreEqual(1, indexAtCall, "Handler index was not set."); Assert.IsNotNull(valuesAtCall, "Values were not set."); Assert.IsNotNull(pipelineValuesAtCall, "Pipeline values were not set."); }
public void GetInputValuesCallsPipelineInfo() { HttpOperationHandler[] handlers = new HttpOperationHandler[0]; SHttpOperationDescription operation = new SHttpOperationDescription() { ReturnValue = HttpParameter.ResponseMessage }; OperationHandlerPipelineInfo pipelineInfo = new OperationHandlerPipelineInfo(handlers, handlers, operation); MOperationHandlerPipelineInfo molePipelineInfo = new MOperationHandlerPipelineInfo(pipelineInfo); molePipelineInfo.GetEmptyPipelineValuesArray = () => new object[0]; molePipelineInfo.SetHttpRequestMessageHttpRequestMessageObjectArray = (req, values) => { }; bool calledForValues = false; int handlerIndexAtCall = -1; object[] valuesAtCall = null; molePipelineInfo.GetInputValuesForHandlerInt32ObjectArray = (index, values) => { calledForValues = true; handlerIndexAtCall = index; valuesAtCall = values; return new object[0]; }; HttpRequestMessage request = new HttpRequestMessage(); OperationHandlerPipelineContext context = new OperationHandlerPipelineContext(pipelineInfo, request); object[] returnedValues = context.GetInputValues(); Assert.IsTrue(calledForValues, "PipelineInfo was not called for its values."); Assert.AreEqual(1, handlerIndexAtCall, "Handler index should have been 0."); Assert.IsNotNull(valuesAtCall, "Values at call should have not been null."); Assert.IsNotNull(returnedValues, "Returned values were null."); Assert.AreEqual(0, returnedValues.Length, "Returned values were incorrect length."); }