示例#1
0
        public void DeleteFileByWildCardTest()
        {
            var step = new CreateStep();

            step.CreationPath = @"..\..\TestData\DeleteTest_FileToBeDeleted1.wildCardTestxml";
            var dl = new FileDataLoader();

            dl.FilePath     = @"..\..\TestData\PurchaseOrder001.xml";
            step.DataSource = dl;
            step.Execute(new Context());

            step.CreationPath = @"..\..\TestData\DeleteTest_FileToBeDeleted2.wildCardTestxml";
            step.Execute(new Context());

            var deleteStep = new DeleteStep();

            deleteStep.FilePathsToDelete.Add(@"..\..\TestData\*.wildCardTestxml");
            deleteStep.Execute(new Context());

            try
            {
                var deletedFile = System.IO.File.Open(@"..\..\TestData\DeleteTest_FileToBeDeleted.wildCardTestxml", FileMode.Open,
                                                      FileAccess.Read);
            }
            catch (System.IO.FileNotFoundException)
            {
                ; // Expected!
            }
        }
示例#2
0
        /// <summary> Loads a list of employees from file </summary>
        public static List <Employee> LoadEmployeesFromFile(string filePath)
        {
            IFileParser <Employee> employeeFileParser = new EmployeeFileParser();
            IDataLoader <Employee> employeeFileLoader = new FileDataLoader <Employee>(filePath, employeeFileParser);

            return(employeeFileLoader.LoadData());
        }
示例#3
0
        public void DeleteFileTest()
        {
            var step = new CreateStep
            {
                CreationPath = @"..\..\..\..\Test\BizUnit.TestSteps.Tests\TestData\DeleteTest_FileToBeDeleted.xml"
            };
            var dl = new FileDataLoader
            {
                FilePath = @"..\..\..\..\Test\BizUnit.TestSteps.Tests\TestData\PurchaseOrder001.xml"
            };

            step.DataSource = dl;
            step.Execute(new Context());

            var deleteStep = new DeleteStep();

            deleteStep.FilePathsToDelete.Add(
                @"..\..\..\..\Test\BizUnit.TestSteps.Tests\TestData\DeleteTest_FileToBeDeleted.xml");
            deleteStep.Execute(new Context());

            try
            {
                var deletedFile =
                    System.IO.File.Open(
                        @"..\..\..\..\Test\BizUnit.TestSteps.Tests\TestData\DeleteTest_FileToBeDeleted.xml",
                        FileMode.Open,
                        FileAccess.Read);
            }
            catch (FileNotFoundException)
            {
                // Expected!
            }
        }
示例#4
0
        static void Main(string[] args)
        {
            string path = "test.txt";

            using (var writer = new StreamWriter(File.Create(path)))
            {
                writer.WriteLine("https://brokenpattern1");
                writer.WriteLine("https://github.com/AnzhelikaKravchuk?tab=repositories");
                writer.WriteLine("https://brokenpattern2");
                writer.WriteLine("https://github.com/AnzhelikaKravchuk/2017-2018.MMF.BSU");
                writer.WriteLine("https://habrahabr.ru/company/it-grad/blog/341486/");
                writer.WriteLine("https://brokenpattern3");
            }

            var    fileLoader = new FileDataLoader(path);
            string dataString = fileLoader.Load();

            var urlParser = new UrlParser(new DefaultUrlConverter(
                                              new DefaultUrlValidator(),
                                              ConsoleLogger.Instance));
            var urls = urlParser.Parse(dataString);

            using (var fs = File.Create("testresult.xml"))
            {
                var exporter = new DefaultXmlExporter(fs);
                exporter.Export(urls);
            }
        }
示例#5
0
        public void DeleteFileByWildCardTest()
        {
            var step = new CreateStep();
            step.CreationPath = @"..\..\TestData\DeleteTest_FileToBeDeleted1.wildCardTestxml";
            var dl = new FileDataLoader();
            dl.FilePath = @"..\..\TestData\PurchaseOrder001.xml";
            step.DataSource = dl;
            step.Execute(new Context());

            step.CreationPath = @"..\..\TestData\DeleteTest_FileToBeDeleted2.wildCardTestxml";
            step.Execute(new Context());

            var deleteStep = new DeleteStep();
            deleteStep.FilePathsToDelete.Add(@"..\..\TestData\*.wildCardTestxml");
            deleteStep.Execute(new Context());

            try
            {
                var deletedFile = System.IO.File.Open(@"..\..\TestData\DeleteTest_FileToBeDeleted.wildCardTestxml", FileMode.Open,
                                    FileAccess.Read);
            }
            catch (System.IO.FileNotFoundException)
            {
                ; // Expected!                
            }
        }
示例#6
0
        public void WebServiceInvoke()
        {
            TestCase btc = new TestCase();

            btc.Name           = "Send SOAP message to BizTalk";
            btc.Description    = "Send a SOAP message to BizTalk as would have done Horizon";
            btc.BizUnitVersion = "4.0.0.1";

            var ws = new WebServiceStep();

            ws.Action = "http://bts.online.bizilante.intranet/ACVCSC.BizTalk.WebServiceInterface/SubmitRequest";
            FileDataLoader dataLoader;

            dataLoader               = new FileDataLoader();
            dataLoader.FilePath      = @"..\..\..\BizUnit.TestSteps.i8c.Tests\TestData\SubmitRequest.xml";
            ws.RequestBody           = dataLoader;
            ws.ServiceUrl            = "http://localhost:8888/ACVCSC.BizTalk.Common.WebServiceInterface/Common.asmx";
            ws.UseDefaultCredentials = true;
            ws.HasResponse           = false;

            // Validation....

            // Add steps
            btc.ExecutionSteps.Add(ws);

            // Save and Execute test
            BizUnit bu = new BizUnit(btc);

            TestCase.SaveToFile(btc, "WebServiceInvoke.xaml");
            bu.RunTest();
        }
示例#7
0
        public void DeleteFileTest()
        {
            var step = new CreateStep();

            step.CreationPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\DeleteTest_FileToBeDeleted.xml");
            var dl = new FileDataLoader();

            dl.FilePath     = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\PurchaseOrder001.xml");
            step.DataSource = dl;
            step.Execute(new Context());

            var deleteStep = new DeleteStep();

            deleteStep.FilePathsToDelete.Add(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\DeleteTest_FileToBeDeleted.xml"));
            deleteStep.Execute(new Context());

            try
            {
                var deletedFile = System.IO.File.Open(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\DeleteTest_FileToBeDeleted.xml"),
                                                      FileMode.Open,
                                                      FileAccess.Read);
            }
            catch (System.IO.FileNotFoundException)
            {
                ; // Expected!
            }
        }
示例#8
0
        public void SampleTestCase()
        {
            var sourceDirectory = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData");
            var sourceFilePath  = Path.Combine(sourceDirectory, "PurchaseOrder001.xml");
            var targetDirectory = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestArea");
            var targetFilePath  = Path.Combine(targetDirectory, "FileCreateStepTest.xml");

            var fds = new DeleteStep();

            fds.FilePathsToDelete.Add(targetFilePath);

            var fcs = new CreateStep();

            fcs.CreationPath = targetFilePath;
            var dl = new FileDataLoader();

            dl.FilePath    = sourceFilePath;
            fcs.DataSource = dl;

            var frs = new FileReadStep();

            frs.DirectoryPath = targetDirectory;
            frs.SearchPattern = "*.xml";
            frs.Timeout       = 3000;
            frs.DeleteFile    = true;

            var tc = new TestCase();

            tc.SetupSteps.Add(fds);
            tc.ExecutionSteps.Add(fcs);
            tc.ExecutionSteps.Add(frs);
            tc.CleanupSteps.Add(fds);

            var testRunner = new TestRunner(tc);

            testRunner.Run();

            TestCase.SaveToFile(
                tc,
                Path.Combine(
                    TestContext.CurrentContext.TestDirectory,
                    @"..\..\",
                    "TestCases",
                    "SampleTest.xaml"),
                true);
        }
示例#9
0
        public void CreateFileTest()
        {
            var step = new CreateStep
            {
                CreationPath = @"..\..\..\..\Test\BizUnit.TestSteps.Tests\TestData\FileCreateStepTest.testdelxml"
            };
            var dl = new FileDataLoader
            {
                FilePath = @"..\..\..\..\Test\BizUnit.TestSteps.Tests\TestData\PurchaseOrder001.xml"
            };

            step.DataSource = dl;
            step.Execute(new Context());

            var readStep = new FileReadMultipleStep
            {
                DirectoryPath = @"..\..\..\..\Test\BizUnit.TestSteps.Tests\TestData\.",
                SearchPattern = "*.testdelxml"
            };

            var validation          = new XmlValidationStep();
            var schemaPurchaseOrder = new SchemaDefinition
            {
                XmlSchemaPath =
                    @"..\..\..\..\Test\BizUnit.TestSteps.Tests\TestData\PurchaseOrder.xsd",
                XmlSchemaNameSpace =
                    "http://SendMail.PurchaseOrder"
            };

            validation.XmlSchemas.Add(schemaPurchaseOrder);

            var xpathProductId = new XPathDefinition
            {
                Description = "PONumber",
                XPath       =
                    "/*[local-name()='PurchaseOrder' and namespace-uri()='http://SendMail.PurchaseOrder']/*[local-name()='PONumber' and namespace-uri()='']",
                Value = "12323"
            };

            validation.XPathValidations.Add(xpathProductId);

            readStep.SubSteps.Add(validation);

            readStep.Execute(new Context());
        }
示例#10
0
        private TestCase BuildFirstTestCase()
        {
            var testCase1 = new TestCase {
                Name = "Copy First File Test"
            };

            var step = new CreateStep();

            step.CreationPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "File1.xml");
            var dl = new FileDataLoader();

            dl.FilePath     = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\PurchaseOrder001.xml");
            step.DataSource = dl;
            step.Execute(new Context());

            testCase1.ExecutionSteps.Add(step);
            return(testCase1);
        }
示例#11
0
        private TestCase BuildFirstTestCase()
        {
            var testCase1 = new TestCase {
                Name = "Copy First File Test"
            };

            var step = new CreateStep();

            step.CreationPath = @"File1.xml";
            var dl = new FileDataLoader();

            dl.FilePath     = @"..\..\TestData\PurchaseOrder001.xml";
            step.DataSource = dl;
            step.Execute(new Context());

            testCase1.ExecutionSteps.Add(step);
            return(testCase1);
        }
示例#12
0
        public void MqSeriesInvoke()
        {
            TestCase btc = new TestCase();

            btc.Name           = "Send and Read operations on a MQSeries queue";
            btc.Description    = "Check/Validate the MQSeries related steps";
            btc.BizUnitVersion = "4.0.0.1";

            const string queueManager = "QM_ACV_LOC";
            const string queueName    = "QL_LOC_ACV_CTW_CONS_OUT";

            // Put a message onto the queue
            var dataLoader = new FileDataLoader();

            dataLoader.FilePath = TestContext.TestDir + @"\..\..\Test\BizUnit.TestSteps.i8c.Tests\TestData\BizTalk2006.ToBeProcessed.A820.Request.xml";
            var wsPut = new MQSeriesPutStep();

            wsPut.QueueManager = queueManager;
            wsPut.Queue        = queueName;
            wsPut.MessageBody  = dataLoader;
            // Add step
            btc.ExecutionSteps.Add(wsPut);

            // Read and validate the message
            var wsRead = new MQSeriesGetStep();

            wsRead.QueueManager = queueManager;
            wsRead.Queue        = queueName;
            wsRead.SubSteps.Add(new BinaryValidationStep
            {
                ComparisonDataPath = TestContext.TestDir + @"\..\..\Test\BizUnit.TestSteps.i8c.Tests\TestData\BizTalk2006.ToBeProcessed.A820.Request.xml",
                ReadAsString       = true
            });
            // Add step
            btc.ExecutionSteps.Add(wsRead);

            // Save and Execute test
            BizUnit bu = new BizUnit(btc);

            TestCase.SaveToFile(btc, "MQSeriesInvoke.xaml");
            bu.RunTest();
        }
示例#13
0
        public void LoadSampleTest()
        {
            DelaySampleTest();

            // Load Test Case
            var testCase = TestCase.LoadFromFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "DelaySampleTest.xaml"));

            // Create test steps...
            var dataLoader = new FileDataLoader {
                FilePath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\InputPO.xaml")
            };

            var fileCreate = new CreateStep {
                CreationPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"InputFile"), DataSource = dataLoader
            };

            testCase.ExecutionSteps.Add(fileCreate);

            // Save Test Case
            TestCase.SaveToFile(testCase, Path.Combine(TestContext.CurrentContext.TestDirectory, "ExtendedDelaySampleTest.xaml"));
        }
示例#14
0
        public void LoadSampleTest()
        {
            DelaySampleTest();

            // Load Test Case
            var testCase = TestCase.LoadFromFile("DelaySampleTest.xml");

            // Create test steps...
            var dataLoader = new FileDataLoader {
                FilePath = @"TestData\InputPO.xml"
            };

            var fileCreate = new CreateStep {
                CreationPath = @"C\InputFile", DataSource = dataLoader
            };

            testCase.ExecutionSteps.Add(fileCreate);

            // Save Test Case
            TestCase.SaveToFile(testCase, "DelaySampleTest.xml");
        }
示例#15
0
        public void CreateFileTest()
        {
            var step = new CreateStep();

            step.CreationPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\FileCreateStepTest.testdelxml");
            var dl = new FileDataLoader();

            dl.FilePath     = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\PurchaseOrder001.xml");
            step.DataSource = dl;
            step.Execute(new Context());

            var readStep = new FileReadMultipleStep();

            readStep.DirectoryPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\.");
            readStep.SearchPattern = "*.testdelxml";

            var validation          = new XmlValidationStep();
            var schemaPurchaseOrder = new SchemaDefinition
            {
                XmlSchemaPath =
                    Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\TestData\PurchaseOrder.xsd"),
                XmlSchemaNameSpace = "http://SendMail.PurchaseOrder"
            };

            validation.XmlSchemas.Add(schemaPurchaseOrder);

            var xpathProductId = new XPathDefinition();

            xpathProductId.Description = "PONumber";
            xpathProductId.XPath       = "/*[local-name()='PurchaseOrder' and namespace-uri()='http://SendMail.PurchaseOrder']/*[local-name()='PONumber' and namespace-uri()='']";
            xpathProductId.Value       = "12323";
            validation.XPathValidations.Add(xpathProductId);

            readStep.SubSteps.Add(validation);

            readStep.Execute(new Context());
        }
示例#16
0
        public void Upgrade_Eligible_Test_FILE()
        {
            var testCase = new TestCase();

            testCase.Name            = "Upgrade_Eligible_Test_FILE";
            testCase.Purpose         = "Test successful upgrade";
            testCase.Description     = "Test upgrade succeeds for passenger/flight eligible for upgrade";
            testCase.Category        = "BizUnit SDK: BVT";
            testCase.Reference       = "Use case: 10.3.4";
            testCase.ExpectedResults = "Upgrade succeeds";
            testCase.Preconditions   = "Solution should be deployed, bound and started";

            // First ensure the target directory is empty...
            var delFiles = new DeleteStep();

            delFiles.FilePathsToDelete = new Collection <string> {
                @"C:\Temp\BizTalk\BizUnitSdkOut\*.xml"
            };
            testCase.SetupSteps.Add(delFiles);

            // Then execute the main scenario.
            var testStep = new CreateStep();

            // Where are we going to create the file.
            testStep.CreationPath = @"C:\Temp\BizTalk\BizUnitSdkIn\Request.xml";
            var dataLoader = new FileDataLoader();

            // Where are we getting the original file from?
            dataLoader.FilePath = @"..\..\Data\Request.xml";
            testStep.DataSource = dataLoader;

            testCase.ExecutionSteps.Add(testStep);

            // Add validation....
            var validation       = new XmlValidationStep();
            var schemaResultType = new SchemaDefinition
            {
                XmlSchemaPath      = @"..\..\..\..\Src\FlightUpgrade\ResponseMsg.xsd",
                XmlSchemaNameSpace = "http://bizUnit.sdk.flightUpgrade/upgradeResponse"
            };

            validation.XmlSchemas.Add(schemaResultType);

            var responseXpath = new XPathDefinition();

            responseXpath.Description = "GetProducts_RS/Result/result";
            responseXpath.XPath       = "/*[local-name()='UpgradeResponse' and namespace-uri()='http://bizUnit.sdk.flightUpgrade/upgradeResponse']/*[local-name()='UpgradeResult' and namespace-uri()='']/*[local-name()='Result' and namespace-uri()='']";
            responseXpath.Value       = "true";
            validation.XPathValidations.Add(responseXpath);

            // Check that an output file has been created.
            var finalFileReadStep = new FileReadMultipleStep();

            finalFileReadStep.DirectoryPath         = @"C:\Temp\BizTalk\BizUnitSdkOut";
            finalFileReadStep.SearchPattern         = "*.xml";
            finalFileReadStep.ExpectedNumberOfFiles = 1;
            finalFileReadStep.Timeout     = 5000;
            finalFileReadStep.DeleteFiles = false;

            finalFileReadStep.SubSteps.Add(validation);
            testCase.ExecutionSteps.Add(finalFileReadStep);

            var bizUnit = new BizUnit(testCase);

            bizUnit.RunTest();
            TestCase.SaveToFile(testCase, System.String.Format("Upgrade_Eligible_Test_File_{0}.xml", System.String.Format("{0:yyyy-MM-dd-hh_mm_ss}", System.DateTime.Now)));
        }
示例#17
0
        public void SummaryTest()
        {
            //var totalItemsTest = new TestCase { Name = "Total Items is 3" };


            var sourceFilePath = @"C:\Users\amigupta7\Desktop\Amit\Project\POC\Timewave.BizUnit.Sample\Testing\OrderSample.xml";
            //var targetDirectory = @"C:\Users\amigupta7\Desktop\Amit\Project\POC\Timewave.BizUnit.Sample\Testing\Order";
            var targetFilePath        = @"C:\Users\amigupta7\Desktop\Amit\Project\POC\Timewave.BizUnit.Sample\Testing\Order\OrderSample.xml";
            var DestinationDirSummary = @"C:\Users\amigupta7\Desktop\Amit\Project\POC\Timewave.BizUnit.Sample\Testing\Summary";


            //Get rid of any files that are already there
            var deleteStep = new DeleteStep();

            deleteStep.FilePathsToDelete.Add(targetFilePath);

            //Create the test step
            var createStep = new CreateStep();

            createStep.CreationPath = targetFilePath;   //Where are we going to create the file
            var dataLoader = new FileDataLoader();      //Where are we getting the file from?

            dataLoader.FilePath   = sourceFilePath;
            createStep.DataSource = dataLoader;

            //Create a validating read step //We should only have one file in the directory
            var ValidateFileStep = new FileReadMultipleStep();

            ValidateFileStep.DirectoryPath         = DestinationDirSummary;
            ValidateFileStep.SearchPattern         = "*.xml";
            ValidateFileStep.Timeout               = 3000;
            ValidateFileStep.ExpectedNumberOfFiles = 1;
            ValidateFileStep.DeleteFiles           = true;


            //Create an XML Validation step //This will check the result against the XSD for the document
            var summarySchemaValidationStep = new XmlValidationStep();
            var schemaSummary = new SchemaDefinition();

            schemaSummary.XmlSchemaPath      = @"C:\Users\amigupta7\Desktop\Amit\Project\POC\Timewave.BizUnit.Sample\Timewave.BizUnit.Sample\Timewave.BizUnit.Sample\Schemas\SummarySchema.xsd";
            schemaSummary.XmlSchemaNameSpace = "http://Timewave.BizTalkUnit.Sample.DestinationSchema";

            summarySchemaValidationStep.XmlSchemas.Add(schemaSummary);

            //Create an XPath Validation.  This will check a value in the output.
            //The Xpath for the node can be grabbed from the Instance XPath property on the XSD.
            var xpathProductId = new XPathDefinition();

            xpathProductId.Description = "ItemsOrdered";
            xpathProductId.XPath       = "/*[local-name()='CustomerSummary' and namespace-uri()='http://Timewave.BizTalkUnit.Sample.DestinationSchema']/*[local-name()='ItemsOrdered' and namespace-uri()='']";
            xpathProductId.Value       = "2";
            summarySchemaValidationStep.XPathValidations.Add(xpathProductId);

            ValidateFileStep.SubSteps.Add(summarySchemaValidationStep);

            var testCase = new TestCase();

            testCase.SetupSteps.Add(deleteStep);
            testCase.ExecutionSteps.Add(createStep);
            testCase.ExecutionSteps.Add(ValidateFileStep);
            testCase.CleanupSteps.Add(deleteStep);

            var testRunner = new TestRunner(testCase);

            try
            {
                testRunner.Run();
            }
            catch (Exception ex)
            {
                string filePath = @"C:\Users\amigupta7\Desktop\Amit\Project\POC\Timewave.BizUnit.Sample\TestResult\Error.txt";

                using (StreamWriter writer = new StreamWriter(filePath, true))
                {
                    writer.WriteLine("-----------------------------------------------------------------------------");
                    writer.WriteLine("Date : " + DateTime.Now.ToString());
                    writer.WriteLine();

                    while (ex != null)
                    {
                        writer.WriteLine(ex.GetType().FullName);
                        writer.WriteLine("Message : " + ex.Message);
                        writer.WriteLine("StackTrace : " + ex.StackTrace);

                        ex = ex.InnerException;
                    }
                }
            }
            finally
            {
                TestCase.SaveToFile(
                    testCase,
                    @"C:\Users\amigupta7\Desktop\Amit\Project\POC\Timewave.BizUnit.Sample\TestResult\SampleTest.xaml",
                    true);
            }
        }
示例#18
0
        public void ImportSingleTestCaseTest()
        {
            TestHelper.DeleteFile("ImportSingleTestCaseTest.xml");

            // Create the first test case i a helper method...
            var testCase1 = BuildFirstTestCase();

            // Create the second test case and import the first test case into it...
            var testCase2 = new TestCase {
                Name = "Copy First File Test"
            };

            var createFileStep = new CreateStep {
                CreationPath = @"File2.xml"
            };
            var dl = new FileDataLoader
            {
                FilePath = @"..\..\TestData\PurchaseOrder001.xml"
            };

            createFileStep.DataSource = dl;

            testCase2.ExecutionSteps.Add(createFileStep);

            var import = new ImportTestCaseStep {
                TestCase = testCase1
            };

            testCase2.ExecutionSteps.Add(import);

            // Create a validating read step...
            var validatingFileReadStep = new FileReadMultipleStep
            {
                DirectoryPath         = @".",
                SearchPattern         = "File*.xml",
                ExpectedNumberOfFiles = 2
            };

            var validation          = new XmlValidationStep();
            var schemaPurchaseOrder = new SchemaDefinition
            {
                XmlSchemaPath =
                    @"..\..\TestData\PurchaseOrder.xsd",
                XmlSchemaNameSpace =
                    "http://SendMail.PurchaseOrder"
            };

            validation.XmlSchemas.Add(schemaPurchaseOrder);

            var xpathProductId = new XPathDefinition
            {
                Description = "PONumber",
                XPath       =
                    "/*[local-name()='PurchaseOrder' and namespace-uri()='http://SendMail.PurchaseOrder']/*[local-name()='PONumber' and namespace-uri()='']",
                Value = "12323"
            };

            validation.XPathValidations.Add(xpathProductId);
            validatingFileReadStep.SubSteps.Add(validation);
            testCase2.ExecutionSteps.Add(validatingFileReadStep);

            // Run the second test case...
            var bizUnit = new BizUnit(testCase2);

            bizUnit.RunTest();

            TestCase.SaveToFile(testCase2, "ImportSingleTestCaseTest.xml");
        }
示例#19
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();
        }
        public void Integration_Test()
        {
            #region Variable Intialization
            var sourceFilePath        = @"C:\Users\amigupta7\Desktop\Amit\Project\POC\Timewave.BizUnit.Sample\Testing\OrderSample.xml";
            var targetFilePath        = @"C:\Users\amigupta7\Desktop\Amit\Project\POC\Timewave.BizUnit.Sample\Testing\Order\OrderSample.xml";
            var DestinationDirSummary = @"C:\Users\amigupta7\Desktop\Amit\Project\POC\Timewave.BizUnit.Sample\Testing\Summary";
            #endregion

            #region Initial CleanUp Step
            //Get rid of any files that are already there
            var deleteStep = new DeleteStep();
            deleteStep.FilePathsToDelete.Add(targetFilePath);
            #endregion

            #region Create step
            //Create the test step
            var createStep = new CreateStep();
            createStep.CreationPath = targetFilePath;   //Where are we going to create the file
            var dataLoader = new FileDataLoader();      //Where are we getting the file from?
            dataLoader.FilePath   = sourceFilePath;
            createStep.DataSource = dataLoader;
            #endregion

            #region Execution steps

            #region File Validation Step
            //Create a validating read step //We should only have one file in the directory
            var ValidateFileStep = new FileReadMultipleStep();
            ValidateFileStep.DirectoryPath         = DestinationDirSummary;
            ValidateFileStep.SearchPattern         = "*.xml";
            ValidateFileStep.Timeout               = 60000;
            ValidateFileStep.ExpectedNumberOfFiles = 1;
            ValidateFileStep.DeleteFiles           = true;
            #endregion

            #region  #SubSteps - Schema and node value Validation Step
            //Create an XML Validation step //This will check the result against the XSD for the document
            var summarySchemaValidationStep = new XmlValidationStep();
            var schemaSummary = new SchemaDefinition();
            schemaSummary.XmlSchemaPath      = @"C:\Users\amigupta7\Desktop\Amit\Project\POC\Timewave.BizUnit.Sample\Timewave.BizUnit.Sample\Timewave.BizUnit.Sample\Schemas\SummarySchema.xsd";
            schemaSummary.XmlSchemaNameSpace = "http://Timewave.BizTalkUnit.Sample.DestinationSchema";

            summarySchemaValidationStep.XmlSchemas.Add(schemaSummary);

            //Create an XPath Validation.  This will check a value in the output.
            //The Xpath for the node can be grabbed from the Instance XPath property on the XSD.
            var xpathProductId = new XPathDefinition();
            xpathProductId.Description = "ItemsOrdered";
            xpathProductId.XPath       = "/*[local-name()='CustomerSummary' and namespace-uri()='http://Timewave.BizTalkUnit.Sample.DestinationSchema']/*[local-name()='ItemsOrdered' and namespace-uri()='']";
            xpathProductId.Value       = "1";
            summarySchemaValidationStep.XPathValidations.Add(xpathProductId);

            ValidateFileStep.SubSteps.Add(summarySchemaValidationStep);

            #endregion

            #endregion

            #region Test Case Execution
            var testCase = new TestCase();
            testCase.SetupSteps.Add(deleteStep);
            testCase.ExecutionSteps.Add(createStep);
            testCase.ExecutionSteps.Add(ValidateFileStep);
            testCase.CleanupSteps.Add(deleteStep);

            var testRunner = new TestRunner(testCase);
            testRunner.Run();


            #endregion
        }
示例#21
0
        public void WebServiceInvoke()
        {
            TestCase btc = new TestCase();

            btc.Name           = "Serialization Test";
            btc.Description    = "Test to blah blah blah, yeah really!";
            btc.BizUnitVersion = "4.0.0.1";

            var ws = new WebServiceStep();

            ws.Action = "http://schemas.virgin-atlantic.com/AncillarySales/Book/Services/2009/IAncillarySalesBook/GetProductTermsAndConditions";
            FileDataLoader dataLoader;

            dataLoader          = new FileDataLoader();
            dataLoader.FilePath = @"..\..\..\Test\BizUnit.TestSteps.Tests\TestData\GetProductTermsAndConditions_RQ.xml";
            ws.RequestBody      = dataLoader;
            ws.ServiceUrl       = "http://localhost/AncillarySalesBook/AncillarySalesBook.svc";
            ws.Username         = @"newkydog001\kevinsmi";
            var header = new SoapHeader();

            header.HeaderName      = "ServiceCallingContext";
            header.HeaderNameSpace = "http://schemas.virgin-atlantic.com/Services/ServiceCallingContext/2009";

            var ctx = new ServiceCallingContext();

            ctx.ApplicationName         = "BVT Tests";
            ctx.GUid                    = "{1705141E-F530-4657-BA2F-23F0F4A8BCB0}";
            ctx.RequestId               = "{59ACDBB4-3FAF-4056-9459-49D43C4128F9}";
            ctx.UserId                  = "kevin";
            ctx.UTCTransactionStartDate = DateTime.UtcNow;
            ctx.UTCTransactionStartTime = DateTime.UtcNow.ToString("HH:mm:ss.fff");
            header.HeaderInstance       = ctx;
            ws.SoapHeaders.Add(header);

            // Validation....
            var validation       = new XmlValidationStep();
            var schemaResultType = new SchemaDefinition
            {
                XmlSchemaPath =
                    @"C:\Affinus\Depot\ASS\Main\Dev\Src\VAA.ASS.Schemas\VAACommon\Result_Type.xsd",
                XmlSchemaNameSpace =
                    "http://schemas.virgin-atlantic.com/Common/2009"
            };

            validation.XmlSchemas.Add(schemaResultType);
            var schema = new SchemaDefinition
            {
                XmlSchemaPath =
                    @"C:\Affinus\Depot\ASS\Main\Dev\Src\VAA.ASS.Schemas\Book\GetProductTermsAndConditions_RS.xsd",
                XmlSchemaNameSpace =
                    "http://schemas.virgin-atlantic.com/AncillarySales/Book/Services/GetProductTermsAndConditions/2009"
            };

            validation.XmlSchemas.Add(schema);

            var xpathProductId = new XPathDefinition();

            xpathProductId.XPath = "/*[local-name()='GetProductTermsAndConditions_RS' and namespace-uri()='http://schemas.virgin-atlantic.com/AncillarySales/Book/Services/GetProductTermsAndConditions/2009']/*[local-name()='Message' and namespace-uri()='']/*[local-name()='TermsAndConditions' and namespace-uri()='']/@*[local-name()='productId' and namespace-uri()='']";
            xpathProductId.Value = "1";
            validation.XPathValidations.Add(xpathProductId);

            var xpathContent = new XPathDefinition();

            xpathContent.XPath = "/*[local-name()='GetProductTermsAndConditions_RS' and namespace-uri()='http://schemas.virgin-atlantic.com/AncillarySales/Book/Services/GetProductTermsAndConditions/2009']/*[local-name()='Message' and namespace-uri()='']/*[local-name()='TermsAndConditions' and namespace-uri()='']/*[local-name()='Content' and namespace-uri()='']";
            xpathContent.Value = "Terms and Conditions: this product is non-refundable....";
            validation.XPathValidations.Add(xpathContent);

            ws.SubSteps.Add(validation);
            btc.ExecutionSteps.Add(ws);

            BizUnit bu = new BizUnit(btc);

            TestCase.SaveToFile(btc, "WebServiceInvoke.xaml");
            bu.RunTest();
        }