Example #1
0
        public void Init2WayMock()
        {
            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)
                    {
                        setting.TargetMessage.Description = message == null ? "empy message received" : message.Description;
                    }
                };

                /// 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
                WaitStep ws = new WaitStep("Wait for 10min");
                ws.Seconds = 600;
                if (!ws.ExecuteStep())
                {
                    Assert.Fail(ws.ResultDescription);
                }
            }
        }