private void SetupReceive(SendEndpoint sendEndpoint) { if (this.operationExpectations.ContainsKey(sendEndpoint.URL)) { // We have an expectation set for this endpoint // so we exit gracefully return; } var receiveOperation = new MessageOperationExpectation() { SendEndpoint = sendEndpoint, MockMessageServer = new StreamingNamedPipeServer( new Uri(sendEndpoint.URL).AbsolutePath) }; // We start the server as this is the whole point of the setup process // The mock should be ready to receive messages from the integration // Before calling Start we need to hook the event handler for ReadCompleted // This brings some challanges with the chosen model, as the mock should then // expose a public property exhibiting the queue that contains the received messages receiveOperation.MockMessageServer.ReadCompleted += MockMessageServer_ReadCompleted; receiveOperation.MockMessageServer.Start(); // TODO: There should be added a check for uniqueness of the key operationExpectations.Add(sendEndpoint.URL, receiveOperation); }
/// <summary> /// Receive response implementation /// TODO: create a higher abstraction representation of a message for easier work in the validation methods /// </summary> /// <returns></returns> private System.IO.Stream ReceiveResponse(MessageOperationExpectation endpointSetup) { // We receive the response var responseStream = endpointSetup.MockMessageClient .ReadStream(); return(responseStream); }
private void SendResponse(MessageOperationExpectation endpointSetup, ResponseStrategy responseStrategy, int connectionId) { // Fetch the message based on the configured strategy var responseMessage = responseStrategy.FetchResponseMessage(); endpointSetup.MockMessageServer .WriteStream( connectionId, responseMessage); }
private void SetupSendRequestAndReceiveResponse(TwoWayReceiveEndpoint receiveSendEndpoint) { var sendReceiveOperation = new MessageOperationExpectation() { TwoWayReceiveEndpoint = receiveSendEndpoint, MockMessageClient = new StreamingNamedPipeClient(new System.Uri(receiveSendEndpoint.URL)) }; operationExpectations.Add(receiveSendEndpoint.URL, sendReceiveOperation); }
private void SetupReceiveRequestAndSendResponse(TwoWaySendEndpoint sendReceiveEndpoint) { var receiveSendOperation = new MessageOperationExpectation() { TwoWaySendEndpoint = sendReceiveEndpoint, MockMessageServer = new StreamingNamedPipeServer( new Uri(sendReceiveEndpoint.URL).AbsolutePath) }; receiveSendOperation.MockMessageServer.ReadCompleted += MockMessageServer_ReadCompleted; receiveSendOperation.MockMessageServer.Start(); operationExpectations.Add(sendReceiveEndpoint.URL, receiveSendOperation); }
public TestCasting <TAddresses> SetupReceiveRequestAndSendResponse(Expression <Func <TAddresses, string> > sender) { var sendReceiveEndpoint = new TwoWaySendEndpoint(); // Invoke the callback for setting the send endpoint properties as well as the expectation method sendReceiveEndpoint.URL = sender.Compile()(this.mockAddresses); var sendReceiveOperation = new MessageOperationExpectation() { TwoWaySendEndpoint = sendReceiveEndpoint, MockMessageClient = new StreamingNamedPipeClient(new System.Uri(sendReceiveEndpoint.URL)) }; endpointsMap.Add(sendReceiveEndpoint.URL, sendReceiveOperation); return(this); }
private void SetupSend(ReceiveEndpoint receiveEndpoint) { if (this.operationExpectations.ContainsKey(receiveEndpoint.URL)) { // We have an expectation set for this endpoint // so we exit gracefully return; } var sendOperation = new MessageOperationExpectation() { ReceiveEndpoint = receiveEndpoint, MockMessageClient = new StreamingNamedPipeClient(new System.Uri(receiveEndpoint.URL)) }; operationExpectations.Add(receiveEndpoint.URL, sendOperation); return; }
public TestCasting <TAddresses> SetupSendRequestAndReceiveResponse(Expression <Func <TAddresses, string> > receiver) { var receiveSendEndpoint = new TwoWayReceiveEndpoint(); // Invoke the callback for setting the send endpoint properties as well as the expectation method receiveSendEndpoint.URL = receiver.Compile()(this.mockAddresses); var receiveSendOperation = new MessageOperationExpectation() { TwoWayReceiveEndpoint = receiveSendEndpoint, MockMessageServer = new StreamingNamedPipeServer( new Uri(receiveSendEndpoint.URL).AbsolutePath) }; receiveSendOperation.MockMessageServer.ReadCompleted += MockMessageServer_ReadCompleted; receiveSendOperation.MockMessageServer.Start(); endpointsMap.Add(receiveSendEndpoint.URL, receiveSendOperation); return(this); }
public TestCasting <TAddresses> SetupReceive(Expression <Func <TAddresses, string> > sender) { var sendEndpoint = new SendEndpoint(); // Invoke the callback for setting the send endpoint properties as well as the expectation method sendEndpoint.URL = sender.Compile()(this.mockAddresses); if (this.endpointsMap.ContainsKey(sendEndpoint.URL)) { // We have an expectation set for this endpoint // so we exit gracefully return(this); } var sendOperation = new MessageOperationExpectation() { SendEndpoint = sendEndpoint, MockMessageClient = new StreamingNamedPipeClient(new System.Uri(sendEndpoint.URL)) }; endpointsMap.Add(sendEndpoint.URL, sendOperation); return(this); }
/// <summary> /// The func in the expression is hardcoded to return strings, as the Mock addresses class has only /// getters of type string /// </summary> /// <param name="receiver"></param> /// <returns></returns> public TestCasting <TAddresses> SetupSend(Expression <Func <TAddresses, string> > receiver) { var receiveEndpoint = new ReceiveEndpoint(); // Compile the expression and fetch the value of the corresponding property receiveEndpoint.URL = receiver.Compile()(this.mockAddresses); if (this.endpointsMap.ContainsKey(receiveEndpoint.URL)) { // We have an expectation set for this endpoint // so we exit gracefully return(this); } var receiveOperation = new MessageOperationExpectation() { ReceiveEndpoint = receiveEndpoint, MockMessageServer = new StreamingNamedPipeServer( new Uri(receiveEndpoint.URL).AbsolutePath) }; // We start the server as this is the whole point of the setup process // The mock should be ready to receive messages from the integration // Before calling Start we need to hook the event handler for ReadCompleted // This brings some challanges with the chosen model, as the mock should then // expose a public property exhibiting the queue that contains the received messages receiveOperation.MockMessageServer.ReadCompleted += MockMessageServer_ReadCompleted; receiveOperation.MockMessageServer.Start(); // TODO: There should be added a check for uniqueness of the key endpointsMap.Add(receiveEndpoint.URL, receiveOperation); return(this); }