예제 #1
0
        public void CreateFileTest()
        {
            var step = new CreateStep();
            step.CreationPath = @"..\..\TestData\FileCreateStepTest.testdelxml";
            var dl = new FileDataLoader();
            dl.FilePath = @"..\..\TestData\PurchaseOrder001.xml";
            step.DataSource = dl;
            step.Execute(new Context());

            var readStep = new FileReadMultipleStep();
            readStep.DirectoryPath = @"..\..\TestData\.";
            readStep.SearchPattern = "*.testdelxml";

            var validation = new XmlValidationStep();
            var schemaPurchaseOrder = new SchemaDefinition
            {
                XmlSchemaPath =
                    @"..\..\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());
        }
예제 #2
0
        public void XmlValidationStepTest_SchemaValidationFail()
        {
            var validation = new XmlValidationStep();
            var schemaPurchaseOrder = new SchemaDefinition
            {
                XmlSchemaPath =
                    @"..\..\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);

            var ctx = new Context();
            var data = StreamHelper.LoadFileToStream(@"..\..\TestData\PurchaseOrder003_SchemaValidationFail.xml");
            try
            {
                Assert.Throws<ValidationStepExecutionException>(() => validation.Execute(data, ctx));
            }
            catch (ValidationStepExecutionException vsee)
            {
                Assert.AreEqual("Failed to validate document instance", vsee.Message);
                Assert.AreEqual(
                    @"The 'http://SendMail.PurchaseOrder:PurchaseOrderBAD' element is not declared.", 
                    vsee.InnerException.Message);
            }
        }
예제 #3
0
        public void XmlValidationStepTest_InvalidXPath()
        {
            var validation = new XmlValidationStep();
            var schemaPurchaseOrder = new SchemaDefinition
            {
                XmlSchemaPath =
                    @"..\..\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);

            var ctx = new Context();
            var data = StreamHelper.LoadFileToStream(@"..\..\TestData\PurchaseOrder002_BadXPath.xml");
            try
            {
                Assert.Throws<ApplicationException>(() => validation.Execute(data, ctx));
            }
            catch (ApplicationException aex)
            {
                Assert.AreEqual(
                    @"XmlValidationStep failed, compare 12323 != BADBAD, xpath query used: /*[local-name()='PurchaseOrder' and namespace-uri()='http://SendMail.PurchaseOrder']/*[local-name()='PONumber' and namespace-uri()='']",
                    aex.Message);
            }
        }
예제 #4
0
        public void Upgrade_Elligable_Test()
        {
            var testCase = new TestCase();
            testCase.Name = "Upgrade_Elligable_Test";
            testCase.Purpose = "Test successful upgrade";
            testCase.Description = "Test upgrade succeeds for passenger/flight not elligable 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> {@"..\..\..\Data\Out\*.xml"};
            testCase.SetupSteps.Add(delFiles);

            // Then execute the main scenario, execute a response-response web set step which is executed concurrently.
            // i.e. whilst this step is waiting for the response the next step, FileReadMultipleStep and then CreateStep
            // will be executed.
            var wsStep = new WebServiceStep();
            wsStep.Action = "Upgrade";
            wsStep.ServiceUrl = "http://localhost/BizUnit.Sdk.FlightUpgrade/BizUnit_Sdk_FlightUpgrade_ProcessRequest_UpgradePort.svc";
            wsStep.RequestBody = new FileDataLoader { FilePath = @"..\..\..\Tests\FlightUpgrade.Tests\Data\Request.xml" };
            wsStep.RunConcurrently = true;

            // 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);

            var fileReadStep = new FileReadMultipleStep();
            fileReadStep.DirectoryPath = @"..\..\..\Data\Out";
            fileReadStep.SearchPattern = "*.xml";
            fileReadStep.ExpectedNumberOfFiles = 1;
            fileReadStep.Timeout = 5000;
            fileReadStep.DeleteFiles = true;

            var createFileStep = new CreateStep();
            createFileStep.CreationPath = @"..\..\..\Data\In\UpgradeResponse.xml";
            createFileStep.DataSource = new FileDataLoader { FilePath = @"..\..\..\Tests\FlightUpgrade.Tests\Data\Response.xml" };

            testCase.ExecutionSteps.Add(wsStep);
            testCase.ExecutionSteps.Add(fileReadStep);
            testCase.ExecutionSteps.Add(createFileStep);

            var bizUnit = new BizUnit(testCase);
            bizUnit.RunTest();
            TestCase.SaveToFile(testCase, "Upgrade_Elligable_Test.xml");
        }
예제 #5
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");
        }
예제 #6
0
        public void XmlValidationStepTest()
        {
            var validation = new XmlValidationStep();
            var schemaPurchaseOrder = new SchemaDefinition
            {
                XmlSchemaPath =
                    @"..\..\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);

            var ctx = new Context();
            var data = StreamHelper.LoadFileToStream(@"..\..\TestData\PurchaseOrder001.xml");
            validation.Execute(data, ctx);
        }
예제 #7
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)));
        }
예제 #8
0
        public void Upgrade_NotElligable_Test()
        {
            var testCase = new TestCase();
            testCase.Name = "Upgrade_NotElligable_Test";
            testCase.Purpose = "Test failed upgrade";
            testCase.Description = "Test upgrade denied for passenger/flight not elligable for upgrade";
            testCase.Category = "BizUnit SDK: BVT";
            testCase.Reference = "Use case: 10.3.5";
            testCase.ExpectedResults = "Upgrade failed";
            testCase.Preconditions = "Solution should be deployed, bound and started";

            var wsStep = new WebServiceStep();
            wsStep.Action = "Upgrade";
            wsStep.ServiceUrl = "http://localhost/BizUnit.Sdk.FlightUpgrade/BizUnit_Sdk_FlightUpgrade_ProcessRequest_UpgradePort.svc";
            wsStep.RequestBody = new FileDataLoader { FilePath = @"..\..\..\Tests\FlightUpgrade.Tests\Data\Request_NotElligible.xml" };
            wsStep.RunConcurrently = true;

            // 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 = "false";
            validation.XPathValidations.Add(responseXpath);

            wsStep.SubSteps.Add(validation);

            testCase.ExecutionSteps.Add(wsStep);

            var bizUnit = new BizUnit(testCase);
            bizUnit.RunTest();
            TestCase.SaveToFile(testCase, "Upgrade_NotElligable_Test.xml");
        }