public void MyTestInitialize() { //Setting up the inbound handler with all the references connectionUri = new MockAdapterConnectionUri(new Uri("mock://localhost/TestEndpoint")); adapter = new MockAdapter(); adapter.Encoding = "UTF-8"; MockAdapterConnectionFactory connectionFactory = new MockAdapterConnectionFactory( connectionUri, null, adapter); MockAdapterConnection connection = new MockAdapterConnection(connectionFactory); inboundHandler = new MockAdapterInboundHandler(connection, null); inboundHandler.StartListener(null, TimeSpan.FromMinutes(1)); }
public void TestOneWayReceive_XML() { inboundHandler.StartListener(null, new TimeSpan(0, 0, 60)); string xml = "<SomeTestMessage><Element1 attribute1=\"attributeValue\"></Element1><Element2>Some element content</Element2></SomeTestMessage>"; using (NamedPipeClientStream pipeClient = new NamedPipeClientStream("localhost", connectionUri.Uri.AbsolutePath, PipeDirection.InOut, PipeOptions.Asynchronous)) { byte[] xmlBytes = Encoding.UTF8.GetBytes(xml); pipeClient.Connect(10000); pipeClient.Write(xmlBytes, 0, xmlBytes.Count()); pipeClient.WaitForPipeDrain(); pipeClient.Close(); } //Now we read the message in the inbound handler Message msg = null; IInboundReply reply; inboundHandler.TryReceive(new TimeSpan(0, 0, 10), out msg, out reply); //Sending empty message to emulate the exact behavior of BizTalk for one way communication reply.Reply(GeneralTestHelper.CreateMessageWithEmptyBody(), TimeSpan.FromSeconds(10)); Assert.IsNotNull(msg, "Message instance was not returned"); Assert.AreEqual(xml, GeneralTestHelper.GetBodyAsString(msg, Encoding.UTF8), "Message contents of received message is different"); }