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> /// Copies the provided source end point properties to the corresponding endpoind configured in this instance /// </summary> /// <param name="sourceEndpoint"></param> public void CopySendEndpointConfig(SendEndpoint sourceEndpoint) { TimeoutInSeconds = sourceEndpoint.TimeoutInSeconds; if (SendEndpoint != null) { SendEndpoint.TimeoutInSeconds = sourceEndpoint.TimeoutInSeconds; } else if (TwoWaySendEndpoint != null) { TwoWaySendEndpoint.TimeoutInSeconds = sourceEndpoint.TimeoutInSeconds; } else { throw new InvalidOperationException("CopySendEndpointConfig() does not have a send endpoint to relate to!"); } }
/// <summary> /// Sets up a mock for a send endpoint /// </summary> /// <param name="sender">An expression that returns the address of the send endpoint</param> /// <returns>The current instance of the <see cref="EndpointsMock{TAddresses}"/> class</returns> public EndpointsMock <TAddresses> SetupSend(Expression <Func <TAddresses, Addressing.OneWaySendAddress> > 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).Value; if (this.endpointsMap.ContainsKey(sendEndpoint.URL)) { // We have an expectation set for this endpoint // so we exit gracefully return(this); } endpointsMap.Add(sendEndpoint.URL, sendEndpoint); return(this); }
public TestMold <TAddresses> Receive( Expression <Func <TAddresses, string> > sendAddress, Action <SendEndpoint> configurator, Action <TestContext> contextAction, Func <int, System.IO.Stream, bool> validator) { return(ReceiveImplementation((c, a) => { string url = sendAddress.Compile()(a); var endpoindConfig = new SendEndpoint() { URL = url }; configurator(endpoindConfig); // TODO: Check whether the expected values were configured contextAction(c); return endpoindConfig; }, validator)); }
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); }