示例#1
0
        public void Call2WayMock_FunctionalError()
        {
            using (BizWTF.Core.Tests.ActionSteps.Messaging.Init2WayMockMessagingService twoWayTarget = new BizWTF.Core.Tests.ActionSteps.Messaging.Init2WayMockMessagingService
            {
                StepName = "Init 2-Way mock service",
                ServiceURI = "http://*****:*****@"BizWTF.Testing.Sample.Messages.ERROR_SystemBResponse.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
                BizWTF.Mocking.Services.MockServiceEventHub.OnMessageReceived += (string uri, BizWTF.Core.Entities.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
                BizWTF.Mocking.Services.MockServiceEventHub.OnMessageResolved += (string uri, BizWTF.Core.Entities.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

                BizWTF.Core.Tests.ActionSteps.Messaging.SubmitMockMessage2WayStep send2WayMsgStep = new BizWTF.Core.Tests.ActionSteps.Messaging.SubmitMockMessage2WayStep("Submit 2Way Message");
                send2WayMsgStep.DestURI                = "http://*****:*****@"BizWTF.Testing.Sample.Messages.ERROR_SystemARequest.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(BizWTF.Core.Entities.BTSTestContext.GetParam(send2WayMsgStep.TargetContextProperty));

                /// Add the rest of your test here
                // Do something
                BizWTF.Core.Entities.MultipartMessageDefinition response = (BizWTF.Core.Entities.MultipartMessageDefinition)BizWTF.Core.Entities.BTSTestContext.GetParam(send2WayMsgStep.TargetContextProperty);


                Assert.IsNotNull(response.Parts[0].Data.SelectSingleNode("/*[local-name()='Status']"));
                Assert.AreEqual(response.Parts[0].Data.SelectSingleNode("/*[local-name()='Status']").InnerText, "FunctionalError");

                Assert.IsNotNull(response.Parts[0].Data.SelectSingleNode("/*[local-name()='ReturnValue']"));
                Assert.AreEqual(response.Parts[0].Data.SelectSingleNode("/*[local-name()='ReturnValue']").InnerText, "ERR1");



                Assert.IsTrue(twoWayTarget.ReceivedMessages.Count > 0);



                BizWTF.Core.Tests.ActionSteps.ForceTrackedMessageCopyJobStep dtaStep = new Core.Tests.ActionSteps.ForceTrackedMessageCopyJobStep("Force tracking job");
                if (!dtaStep.ExecuteStep())
                {
                    Assert.Fail(dtaStep.ResultDescription);
                }

                BizWTF.Core.Tests.GetSteps.GetProcessDebugStep getProcess = new BizWTF.Core.Tests.GetSteps.GetProcessDebugStep("GetProcess - <Your orchestration>");
                getProcess.TargetContextProperty = "GetProcess_Result_Call2WayMock"; // Choose any relevant name
                #region GetProcessDebugStep : Orchestration selection configuration

                getProcess.ProcessName = "BizWTF.Sample.Processes.Call2WayMock";
                /// The following context properties and XPath queries are used to precisely spot which orchestration instance you want to synchronize with.
                /// This is only an example. If nothing is specified, the most recent instance will be selected.
                /// You can add as many context props and XPath queries as you like
                getProcess.ContextProps.Add(new BizWTF.Core.Entities.ProcessValidation.ControlProperty("https://BizWTF.Mocking.Schemas.ProcessingProperties",
                                                                                                       "TestID",
                                                                                                       send2WayMsgStep.TestID)); // NOTE : if a test ID was set in a previous step, use it here
                #endregion

                /// NOTE : the folowing code actually executes the step.
                /// Any corresponding SynchronizeProcessDebugStep should be executed prior to this
                if (!getProcess.ExecuteStep())
                {
                    Assert.Fail(getProcess.ResultDescription);
                }


                BizWTF.Core.Tests.TestSteps.TestProcessDebugStep testStep = new BizWTF.Core.Tests.TestSteps.TestProcessDebugStep("TestProcess - <Your orchestration>");
                testStep.SourceContextProperty = getProcess.TargetContextProperty;
                testStep.Scenario = BizWTF.Core.Entities.ProcessValidation.DebugTrace.ImportTimeLine(
                    System.Reflection.Assembly.GetExecutingAssembly().FullName,  // In this case, the resource is embedded in the current assembly
                    "BizWTF.Testing.Sample.Processes.Call2WayMock_FunctionalError_1.xml");

                if (!testStep.ExecuteStep())
                {
                    Assert.Fail(testStep.ResultDescription);
                }
            }
        }
示例#2
0
        public void Call2WayMock_TechnicalError()
        {
            using (BizWTF.Core.Tests.ActionSteps.Messaging.Init2WayMockMessagingService twoWayTarget = new BizWTF.Core.Tests.ActionSteps.Messaging.Init2WayMockMessagingService
            {
                StepName = "Init 2-Way mock service",
                ServiceURI = "http://*****:*****@"BizWTF.Testing.Sample.Messages.ERROR_SystemARequest.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(BizWTF.Core.Entities.BTSTestContext.GetParam(send2WayMsgStep.TargetContextProperty));

                /// Add the rest of your test here
                // Do something
                BizWTF.Core.Entities.MultipartMessageDefinition response = (BizWTF.Core.Entities.MultipartMessageDefinition)BizWTF.Core.Entities.BTSTestContext.GetParam(send2WayMsgStep.TargetContextProperty);


                Assert.IsNotNull(response.Parts[0].Data.SelectSingleNode("/*[local-name()='Status']"));
                Assert.AreEqual(response.Parts[0].Data.SelectSingleNode("/*[local-name()='Status']").InnerText, "TechnicalError");



                Assert.IsTrue(twoWayTarget.ReceivedMessages.Count > 0);
            }
        }