示例#1
0
        public void Test2WayFaultedService()
        {
            using (Init2WayMockMessagingService twoWayTarget = new Init2WayMockMessagingService
            {
                StepName = "Init 2-Way mock service",
                ServiceURI = "http://*****:*****@"BizWTF.Testing.Sample.Messages.Mock-Demo-2WayMockService-Direct.xml";
                sendStep.SourceResourceAssembly = System.Reflection.Assembly.GetExecutingAssembly().FullName;
                sendStep.TargetContextProperty  = "Init2WayTest_Response";

                if (!sendStep.ExecuteStep())
                {
                    Assert.Fail(sendStep.ResultDescription);
                }

                Assert.AreEqual(twoWayTarget.ReceivedMessages.Count, 1);
                Assert.IsNotNull(BTSTestContext.GetParam(sendStep.TargetContextProperty));
            }
        }
        public void Execute2WayStepTest()
        {
            SubmitMockMessage2WayStep target = new SubmitMockMessage2WayStep("Mock submission test"); // TODO: Initialize to an appropriate value

            target.DestURI                = "http://*****:*****@"BizWTF.Testing.Sample.Messages.Mock-Demo.xml";
            target.SourceResourceAssembly = System.Reflection.Assembly.GetExecutingAssembly().FullName;
            target.TargetContextProperty  = "BizWTFResponse";

            bool expected = true;
            bool actual   = target.ExecuteStep();

            Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }
        public void TestProcess_Receive2WayDemo()
        {
            SubmitMockMessage2WayStep send2WayMsgStep = new SubmitMockMessage2WayStep("Submit 2Way Message");

            send2WayMsgStep.DestURI                = "http://*****:*****@"<your embedded resources here>";
            send2WayMsgStep.SourceResourceAssembly = System.Reflection.Assembly.GetExecutingAssembly().FullName; // In this case, the resource is embedded in the current assembly
            send2WayMsgStep.TestID = Guid.NewGuid().ToString();                                                  // NOTE : you can provide a test ID, wich will be attached as a message property. This facilitates instance tracking.
            send2WayMsgStep.TargetContextProperty = "send2WayMsgStep_Response";


            SynchronizeProcessDebugStep synchroStep = new SynchronizeProcessDebugStep("Synchronization : <Your orchestration>");

            synchroStep.ProcessName           = "BizWTF.Sample.Processes.Receive2WayDemo";
            synchroStep.TargetContextProperty = "SyncProcess_Result_Receive2WayDemo_OK"; // Choose any relevant name
            synchroStep.ContextProps.Add(new ControlProperty("https://BizWTF.Mocking.Schemas.ProcessingProperties",
                                                             "TestID",
                                                             send2WayMsgStep.TestID)); // NOTE : if a test ID was set in a previous step, use it here

            /// NOTE : Polling settings are used to determine how long BizWTF will keep waiting for a matching instance to be started.
            /// If no matching instance is found, the step fails.
            synchroStep.PollingCount    = 10;
            synchroStep.PollingInterval = 500; // Interval in ms

            /// ForceTrackedMessageCopyJobStep : used to force execution of the TrackedMessageCopy job
            ForceTrackedMessageCopyJobStep ftmc = new ForceTrackedMessageCopyJobStep("Wait until tracking job executes");

            if (!synchroStep.ExecuteStep())
            {
                Assert.Fail(synchroStep.ResultDescription);
                // NOTE : in case of short living orchestrations, the synchronization step may fail because it didn't have to time to execute before the orchestration finished
            }
            if (!ftmc.ExecuteStep())
            {
                Assert.Fail(ftmc.ResultDescription); //NOTE : this step should DEFINITELY complete
            }
            /// NOTE : the folowwing code actually sends the message.
            /// Nevertheless, it is recommended to first initialize all the steps of the test before executing any of them.
            if (!send2WayMsgStep.ExecuteStep())
            {
                Assert.Fail(send2WayMsgStep.ResultDescription);
            }

            /// Once the step has executed successfully, do whatever test you need to do.
            /// The following code : BTSTestContext.GetParam(send2WayMsgStep.TargetContextProperty)
            /// retrieves the response received.
            Assert.IsNotNull(BTSTestContext.GetParam(send2WayMsgStep.TargetContextProperty));
        }
示例#4
0
        public void Init1WayTest()
        {
            using (Init1WayMockMessagingService oneWayTarget = new Init1WayMockMessagingService
            {
                StepName = "Init 1-Way mock service",
                ServiceURI = "http://*****:*****@"BizWTF.Testing.Sample.Messages.Mock-Demo-1WayMockService.xml";
                sendStep.SourceResourceAssembly = System.Reflection.Assembly.GetExecutingAssembly().FullName;
                sendStep.TargetContextProperty  = "Init1WayTest_Response";

                bool ssResult = sendStep.ExecuteStep();
                Assert.IsTrue(ssResult);

                Assert.AreEqual(oneWayTarget.ReceivedMessages.Count, 1);
            }
        }
示例#5
0
        public void Call2WayMock()
        {
            using (Init2WayMockMessagingService twoWayTarget = new Init2WayMockMessagingService
            {
                StepName = "Init 2-Way mock service",
                ServiceURI = "http://*****:*****@"BizWTF.Testing.Sample.Messages.Mock-Demo-2WayMockService-Response.xml",
                                                                                    System.Reflection.Assembly.GetExecutingAssembly());
                twoWayTarget.ResolutionSettings.Clear();
                twoWayTarget.ResolutionSettings.Add(setting);
                // Add as many resolution setting as needed

                /// OPTIONAL : if you need to fire some custom code when a message is received
                //MockServiceEventHub.ResetMessageReceivedEventHandler(); // Optional, if you need to flush all event handlers
                MockServiceEventHub.OnMessageReceived += (string uri, MultipartMessageDefinition message) =>
                {
                    if (uri == twoWayTarget.ServiceURI)
                    {
                        // Do something
                    }
                };

                /// OPTIONAL : if you need to fire some custom code when a message is resolved
                //MockServiceEventHub.ResetMessageResolvedEventHandler(); // Optional, if you need to flush all event handlers
                MockServiceEventHub.OnMessageResolved += (string uri, MultipartMessageDefinition message) =>
                {
                    if (uri == twoWayTarget.ServiceURI)
                    {
                        // Do something
                    }
                };

                /// Following code must complete (this is were we start the mock service)
                /// In case of any error, the user that runs the test may need som additional right to reserve the URL.
                /// If so, consider using the following command : netsh http add urlacl url=... user=...
                if (!twoWayTarget.ExecuteStep())
                {
                    Assert.Fail(twoWayTarget.ResultDescription);
                }
                #endregion



                /// Add the rest of your test here
                // Do something
                SubmitMockMessage2WayStep send2WayMsgStep = new SubmitMockMessage2WayStep("Submit 2Way Message");
                send2WayMsgStep.DestURI                = "http://*****:*****@"BizWTF.Testing.Sample.Messages.Mock-Demo-1WayMockService.xml";
                send2WayMsgStep.SourceResourceAssembly = System.Reflection.Assembly.GetExecutingAssembly().FullName; // In this case, the resource is embedded in the current assembly
                send2WayMsgStep.TestID = Guid.NewGuid().ToString();                                                  // NOTE : you can provide a test ID, wich will be attached as a message property. This facilitates instance tracking.
                send2WayMsgStep.TargetContextProperty = "send2WayMsgStep_Response";

                /// NOTE : the folowwing code actually sends the message.
                /// Nevertheless, it is recommended to first initialize all the steps of the test before executing any of them.
                if (!send2WayMsgStep.ExecuteStep())
                {
                    Assert.Fail(send2WayMsgStep.ResultDescription);
                }

                /// Once the step has executed successfully, do whatever test you need to do.
                /// The following code : BTSTestContext.GetParam(send2WayMsgStep.TargetContextProperty)
                /// retrieves the response received.
                Assert.IsNotNull(BTSTestContext.GetParam(send2WayMsgStep.TargetContextProperty));
            }
        }