public void IntegrationTest_With_Valid_Message_In() { TestCase testCase = new TestCase { Name = MethodBase.GetCurrentMethod().Name }; MsmqPurgeStep msmqPurgeStep1 = new MsmqPurgeStep { FailOnError = true, Name = "Purge 'MessageIn'.", QueuePath = ".\\private$\\AcmeCorp.BizTalkBuildSample.MessageIn" }; testCase.ExecutionSteps.Add(msmqPurgeStep1); MsmqPurgeStep msmqPurgeStep2 = new MsmqPurgeStep { FailOnError = true, Name = "Purge 'MessageOut'.", QueuePath = ".\\private$\\AcmeCorp.BizTalkBuildSample.MessageOut" }; testCase.ExecutionSteps.Add(msmqPurgeStep2); XmlDocument messageBody = new XmlDocument(); messageBody.LoadXml(@"<ns0:Root xmlns:ns0='http://schemas.AcmeCorp.com/BizTalkBuildSample/MessageIn'><ValueIn>ValueIn_0</ValueIn></ns0:Root>"); MsmqWriteStep msmqWriteStep = new MsmqWriteStep { FailOnError = true, Name = "Write 'MessageIn' message to MSMQ.", QueuePath = ".\\private$\\AcmeCorp.BizTalkBuildSample.MessageIn", MessageBodyContent = messageBody }; testCase.ExecutionSteps.Add(msmqWriteStep); XPathDefinition xpathDefinition = new XPathDefinition { Value = "ValueIn_0", XPath = "/*[local-name()='Root']/*[local-name()='ValueOut']" }; XPathValidationStep xpathValidationStep = new XPathValidationStep(); xpathValidationStep.XPathValidations.Add(xpathDefinition); MsmqReadStep msmqReadStep = new MsmqReadStep { FailOnError = true, Name = "Read 'MessageOut' message from MSMQ.", QueuePath = ".\\private$\\AcmeCorp.BizTalkBuildSample.MessageOut", TimeoutInMilliseconds = ThirtySecondsInMilliseconds }; msmqReadStep.SubSteps = new Collection<SubStepBase>(); msmqReadStep.SubSteps.Add(xpathValidationStep); testCase.ExecutionSteps.Add(msmqReadStep); BizUnit.BizUnit bizUnit = new BizUnit.BizUnit(testCase); bizUnit.RunTest(); }
public void MsmqInvoke() { TestCase btc = new TestCase(); btc.Name = "Create, Send, Peek, Read and Delete operations on a MSMQ queue"; btc.Description = "Check/Validate the MSMQ related steps"; btc.BizUnitVersion = "4.0.0.1"; var queuePaths = new Collection <QueuePathDefinition>(); queuePaths.Add(new QueuePathDefinition { QueuePath = ".\\Private$\\MyTestQueue" , Transactional = true , ShouldExist = false }); // The queue should not exist yet var wsExists = new MsmqQueueExistsStep(); wsExists.QueuePaths = queuePaths; wsExists.ThrowError = false; wsExists.DeleteWhenExists = true; // Add step btc.ExecutionSteps.Add(wsExists); // Create a queue var ws = new MsmqCreateQueueStep(); ws.QueuePaths = queuePaths; // Add step btc.ExecutionSteps.Add(ws); // Put a message onto the queue var dataLoader = new FileDataLoader(); dataLoader.FilePath = @"..\..\..\BizUnit.TestSteps.i8c.Tests\TestData\BizTalk2006.ToBeProcessed.A820.Request.xml"; var wsPut = new MsmqWriteStep(); wsPut.QueuePath = queuePaths[0].QueuePath; wsPut.MessageBody = dataLoader; wsPut.MessageLabel = "Some Test"; wsPut.UseTransactions = true; // Add step btc.ExecutionSteps.Add(wsPut); // Peek into the queue and count the number of messages var wsPeek = new MsmqPeekStep(); wsPeek.QueuePath = queuePaths[0].QueuePath; wsPeek.ExpectedNumberOfMessages = 1; wsPeek.TimeOut = 100; // Add step btc.ExecutionSteps.Add(wsPeek); // Read and validate the message var wsRead = new MsmqReadStep(); wsRead.QueuePath = queuePaths[0].QueuePath; wsRead.TimeOut = 100; wsRead.SubSteps.Add(new BinaryValidationStep { ComparisonDataPath = @"..\..\..\BizUnit.TestSteps.i8c.Tests\TestData\BizTalk2006.ToBeProcessed.A820.Request.xml" }); // Add step btc.ExecutionSteps.Add(wsRead); // Delete the queue var wsDelete = new MsmqDeleteQueueStep(); wsDelete.QueuePaths = queuePaths; // Add step btc.ExecutionSteps.Add(wsDelete); // Save and Execute test BizUnit bu = new BizUnit(btc); TestCase.SaveToFile(btc, "MsmqInvoke.xaml"); bu.RunTest(); }
public void MsmqDmfaFromSQLInvoke() { TestCase btc = new TestCase(); btc.Name = "Create, Send, Peek, Read and Delete operations on a MSMQ queue"; btc.Description = "Check/Validate the MSMQ related steps (test data is retrieved out of a SQL database)"; btc.BizUnitVersion = "4.0.0.1"; var queuePaths = new Collection <QueuePathDefinition>(); queuePaths.Add(new QueuePathDefinition { QueuePath = ".\\Private$\\MyTestQueue", Transactional = true, ShouldExist = false }); // The queue should not exist yet var wsExists = new MsmqQueueExistsStep(); wsExists.QueuePaths = queuePaths; wsExists.ThrowError = false; wsExists.DeleteWhenExists = true; // Add step btc.ExecutionSteps.Add(wsExists); // Create a queue var ws = new MsmqCreateQueueStep(); ws.QueuePaths = queuePaths; // Add step btc.ExecutionSteps.Add(ws); // Put a message onto the queue var dataLoader = new SqlDataLoader(); dataLoader.ConnectionString = "Data Source=.\\btsloc;Initial Catalog=BizTalkFluxDb_ForTesting;Integrated Security=True"; dataLoader.Command = "SELECT [FluxData] FROM [BizTalkFluxDb_ForTesting].[dbo].[FluxData] WHERE [ID] = '970458E6-7F20-4F46-B69D-AA3D952ACA13'"; var wsPut = new MsmqWriteStep(); wsPut.QueuePath = queuePaths[0].QueuePath; wsPut.MessageBody = dataLoader; wsPut.MessageLabel = "Some DMFA Test"; wsPut.UseTransactions = true; wsPut.BodyType = VarEnum.VT_LPWSTR; // Add step btc.ExecutionSteps.Add(wsPut); // Peek into the queue and count the number of messages var wsPeek = new MsmqPeekStep(); wsPeek.QueuePath = queuePaths[0].QueuePath; wsPeek.ExpectedNumberOfMessages = 1; wsPeek.TimeOut = 100; // Add step btc.ExecutionSteps.Add(wsPeek); // Read and validate the message var wsRead = new MsmqReadStep(); wsRead.QueuePath = queuePaths[0].QueuePath; wsRead.TimeOut = 100; wsRead.BodyType = VarEnum.VT_LPWSTR; wsRead.SubSteps.Add(new ValidationSteps.Sql.BinaryValidationStep { ConnectionString = "Data Source=.\\btsloc;Initial Catalog=BizTalkFluxDb_ForTesting;Integrated Security=True", Command = "SELECT [FluxData] FROM [BizTalkFluxDb_ForTesting].[dbo].[FluxData] WHERE [ID] = '970458E6-7F20-4F46-B69D-AA3D952ACA13'", ReadAsUnicode = true }); // Add step btc.ExecutionSteps.Add(wsRead); // Delete the queue var wsDelete = new MsmqDeleteQueueStep(); wsDelete.QueuePaths = queuePaths; // Add step btc.ExecutionSteps.Add(wsDelete); // Save and Execute test BizUnit bu = new BizUnit(btc); TestCase.SaveToFile(btc, "MsmqDmfaSqlInvoke.xaml"); bu.RunTest(); }