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); } }
public void SendDemoMsg() { using (Init1WayMockMessagingService oneWayTarget = new Init1WayMockMessagingService { StepName = "Init 1-Way mock service", ServiceURI = "http://*****:*****@"<Resource name>", 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 } } }
public void Call1WayMock() { using (Init1WayMockMessagingService oneWayTarget = new Init1WayMockMessagingService { StepName = "Init 1-Way mock service", ServiceURI = "http://*****:*****@"BizWTF.Testing.Sample.Messages.Mock-Demo-1WayMockService.xml"; send1WayMsgStep.SourceResourceAssembly = System.Reflection.Assembly.GetExecutingAssembly().FullName; // In this case, the resource is embedded in the current assembly send1WayMsgStep.TestID = send1WayMsgStep.TestID; // NOTE : you can provide a test ID, wich will be attached as a message property. This facilitates instance tracking. /// 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 (!send1WayMsgStep.ExecuteStep()) { Assert.Fail(send1WayMsgStep.ResultDescription); } int iterationCount = 0; while (!msgReceived) { iterationCount++; System.Threading.Thread.Sleep(1000); if (iterationCount == 1000) { Assert.Fail("No message was received"); break; } } } }