Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        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();
        }