private static TestCase GetBizUnitTestCase(ImportTestCaseStep importContainer, string testCaseDirectory, bool searchRecursively) { TestCase itc = null; try { itc = TestCase.LoadFromFile(importContainer.TestCasePath); } catch (DirectoryNotFoundException ex) {; } if (null == itc) { var fileName = Path.GetFileName(importContainer.TestCasePath); var filePath = Directory.GetFiles(testCaseDirectory, fileName, searchRecursively ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly); if (null != filePath && 1 == filePath.Length) { itc = TestCase.LoadFromFile(filePath[0]); } else if (null != filePath && 1 < filePath.Length) { throw new ApplicationException(string.Format("Ambiguous file name specified as import: {0}", filePath)); } } return(itc); }
private static void ExecuteImportedTestCase(ImportTestCaseStep testStep, Context context) { var testCase = testStep.GetTestCase(); var bu = new TestRunner(testCase, context); bu.Run(); }
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"); }
private static void ExecuteImportedTestCase(ImportTestCaseStep testStep, Context context) { var testCase = testStep.GetTestCase(); var bu = new BizUnit(testCase, context); bu.RunTest(); }