示例#1
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();
        }
示例#2
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();
        }
示例#3
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();
        }