예제 #1
0
        public void TestOneWayFlow_NewSyntax()
        {
            var epMock = new EndpointsMock <BizTalkTestsMockAddresses>();

            epMock.SetupReceive(
                r => r.BTS_OneWayReceive2_FILE);
            epMock.SetupSend(
                s => s.BTS_OneWaySendFILE);

            var messanger = epMock.CreateMessagingClient();

            messanger
            .Send(
                r => r.BTS_OneWayReceive2_FILE,
                "StartMessage.xml",
                System.Text.Encoding.UTF8,
                10,
                beforeSendAction: ctx => ctx.DebugInfo("Sending messagein to OneWayReceive2_FILE")
                )
            .Receive(
                s => s.BTS_OneWaySendFILE,
                beforeReceiveAction: ctx => ctx.DebugInfo("Receiving message from BTS_OneWaySendFILE"),
                validator: v =>
            {
                Assert.IsTrue(v.Index == 0, "Message index is wrong!");
                Assert.IsTrue(v.Message.Body.Length > 0, "Received message is empty");

                return(true);
            }
                );
        }
예제 #2
0
        public void TestComplexFlow_1ParallelOperation_HappyPath()
        {
            var flowMock = new ComplexFlowMock();

            flowMock.RunComplexFlow1(
                "mock://localhost/Receive_Test_2Way", "mock://localhost/Send_Test_2Way");

            var integrationMock = new EndpointsMock <ComplexFlowMockAddresses>();

            integrationMock.
            SetupSendRequestAndReceiveResponse(
                r => r.Send_Test_2Way)
            .SetupReceiveRequestAndSendResponse(
                s => s.Receive_Test_2Way);

            var messageClient = integrationMock.CreateMessagingClient();

            messageClient.InParallel(
                (m) => m.ReceiveRequestAndSendResponse(
                    s => s.Send_Test_2Way,
                    rs => new StaticFileResponseSelector()
            {
                FilePath = "TestResponse.xml"
            },
                    expectedMessageCount: 2,
                    requestValidator: v =>
            {
                Assert.IsTrue(v.Message.Body.Length > 0, "The received request is empty!");

                var xDoc = XDocument.Load(v.Message.BodyStream);

                Assert.IsTrue(
                    xDoc.Root.Name.LocalName == "TestRequest",
                    "The contents of the request message is not the same");
                return(true);
            }
                    )
                )
            .SendRequestAndReceiveResponse(
                r => r.Receive_Test_2Way,
                "TestRequest.xml",
                // timeoutInSeconds: 15,
                responseValidator: v =>
            {
                Assert.IsTrue(v.Body.Length > 0, "The response message is empty");

                var xDoc = XDocument.Load(v.BodyStream);

                Assert.IsTrue(
                    xDoc.Root.Name.LocalName == "TestResponse",
                    "The contents of the response message is not the same");
                return(true);
            }
                )
            .VerifyParallel();

            flowMock.Clenup();
        }
예제 #3
0
        public void Simple2WayFlow_XML_HappyPath()
        {
            var integrationMock = new EndpointsMock <TestMockAddresses>();

            integrationMock.
            SetupSendRequestAndReceiveResponse(
                r => r.TwoWaySend_WebHTTP)
            .SetupReceiveRequestAndSendResponse(
                s => s.TwoWayReceive_WebHTTP);

            var messageClient = integrationMock.CreateMessagingClient();

            messageClient.InParallel(
                (m) => m.ReceiveRequestAndSendResponse(
                    s => s.TwoWaySend_WebHTTP,
                    rs => new StaticFileResponseSelector()
            {
                FilePath = "TestResponse.xml"
            },
                    requestValidator: v =>
            {
                Assert.IsTrue(v.Message.Body.Length > 0, "The received request is empty!");

                var xDoc = XDocument.Load(v.Message.BodyStream);

                Assert.IsTrue(
                    xDoc.Root.Name.LocalName == "TestRequest",
                    "The contents of the request message is not the same");
                return(true);
            }
                    )
                )
            .SendRequestAndReceiveResponse(
                r => r.TwoWayReceive_WebHTTP,
                "TestRequest.xml",
                responseValidator: v =>
            {
                Assert.IsTrue(v.Body.Length > 0, "The response message is empty");

                var xDoc = XDocument.Load(v.BodyStream);

                Assert.IsTrue(
                    xDoc.Root.Name.LocalName == "TestResponse",
                    "The contents of the response message is not the same");
                return(true);
            }
                )
            .VerifyParallel();
        }
예제 #4
0
        public void TestServiceBusAdapterProperties_HappyPath()
        {
            var serviceMock = new EndpointsMock <BizTalkTestsMockAddresses>();

            serviceMock.SetupReceive(r => r.BTS_OneWayReceive3_SBus)
            .SetupSend(s => s.BTS_OneWayTestSend_SBus);

            var messagingClient = serviceMock.CreateMessagingClient();

            messagingClient.Send(r => r.BTS_OneWayReceive3_SBus,
                                 "StartMessage.xml",
                                 messagePropertiesSetter: msp => msp.Add(
                                     SBMessaging.CorrelationId, "SomeCorrelationID")
                                 )
            .Receive(s => s.BTS_OneWayTestSend_SBus,
                     validator: v => ValidateCorrelationId(v, "SomeCorrelationID"));
        }
예제 #5
0
        public void Simple2WayFlow_HappyPath()
        {
            var integrationMock = new EndpointsMock <TestMockAddresses>();

            integrationMock.
            SetupSendRequestAndReceiveResponse(
                r => r.TwoWaySend_WebHTTP)
            .SetupReceiveRequestAndSendResponse(
                s => s.TwoWayReceive_WebHTTP);

            var messageClient = integrationMock.CreateMessagingClient();

            messageClient.InParallel(
                (m) => m.ReceiveRequestAndSendResponse(
                    s => s.TwoWaySend_WebHTTP,
                    rs => new StaticFileResponseSelector()
            {
                FilePath = "TestFileResponse.txt"
            },
                    requestValidator: v =>
            {
                Assert.IsTrue(v.Message.Body.Length > 0, "The received request is empty!");
                Assert.IsTrue(
                    v.Message.Body.Equals("This is a test request file",
                                          StringComparison.InvariantCulture),
                    "The contents of the request message is not the same");
                return(true);
            }
                    )
                )
            .SendRequestAndReceiveResponse(
                r => r.TwoWayReceive_WebHTTP,
                "TestFileRequest.txt",
                responseValidator: v =>
            {
                Assert.IsTrue(v.Body.Length > 0, "The response message is empty");
                Assert.AreEqual(
                    "This is a test response file",
                    v.Body,
                    "The contents of the response message is not the same");
                return(true);
            }
                )
            .VerifyParallel();
        }
예제 #6
0
        public void SimpleFlow_HappyPath()
        {
            var integrationMock = new EndpointsMock <TestMockAddresses>();

            integrationMock
            .SetupReceive(a => a.ReceiveFirstMessage_FILE)
            .SetupSend(a => a.SendFirstMessage_FILE);

            var emulator = integrationMock.CreateMessagingClient();

            emulator
            .Send(r => r.ReceiveFirstMessage_FILE,
                  "TestFileIn.txt",
                  System.Text.Encoding.UTF8,
                  10,
                  beforeSendAction: ctx => ctx.DebugInfo("Fire in the hall")
                  )
            .Receive(
                s => s.SendFirstMessage_FILE,
                beforeReceiveAction: ctx => ctx.DebugInfo("Yet one more blast!"),
                validator: v => { return(v.Message.Body.Length > 0); });
        }