public void Setup() { // parse business actions using (Stream xmlStream = File.OpenRead("../../AccipioTests/Samples/OnlineBankingBusinessActions.xml")) { IBusinessActionXmlParser businessActionXmlParser = new BusinessActionsXmlParser(xmlStream); businessActionsRepository = businessActionXmlParser.Parse(); } }
public void NotSupportedActionsElementTest() { string xml = "<actions><element></element></actions>"; byte[] bytes = Encoding.ASCII.GetBytes(xml); using (MemoryStream stream = new MemoryStream(bytes)) { IBusinessActionXmlParser parser = new BusinessActionsXmlParser(stream); parser.Parse(); } }
public void ParseBusinessActionsInvalidXmlTest() { string xml = "<actionss><action></action></actionss>"; byte[] bytes = Encoding.ASCII.GetBytes(xml); using (MemoryStream stream = new MemoryStream(bytes)) { IBusinessActionXmlParser parser = new BusinessActionsXmlParser(stream); parser.Parse(); } }
/// <summary> /// Parse business action xml document to object /// </summary> /// <param name="businessActionsXmlFileName">file name of business action</param> /// <returns>Parsed xml document as BusinessActionsRepository object</returns> private static BusinessActionsRepository ParseXmlToObject(string businessActionsXmlFileName) { BusinessActionsRepository businessActionsRepository; using (Stream xmlStream = File.OpenRead(businessActionsXmlFileName)) { IBusinessActionXmlParser businessActionXmlParser = new BusinessActionsXmlParser(xmlStream); businessActionsRepository = businessActionXmlParser.Parse(); } return(businessActionsRepository); }
public void ParseBusinessActionsTest() { using (Stream stream = File.OpenRead("../../AccipioTests/Samples/OnlineBankingBusinessActions.xml")) { IBusinessActionXmlParser parser = new BusinessActionsXmlParser(stream); BusinessActionsRepository businessActionsRepository = parser.Parse(); // test id of actions Assert.AreEqual(businessActionsRepository.EnumerateActions().Count, 8); IList <BusinessAction> actions = businessActionsRepository.EnumerateActions(); int i = 0; Assert.AreEqual(actions[i++].ActionName, "AssertOperationSuccessful"); Assert.AreEqual(actions[i++].ActionName, "ClickActionTransfer"); Assert.AreEqual(actions[i++].ActionName, "ConfirmTransfer"); Assert.AreEqual(actions[i++].ActionName, "EnterDestinationAccountNumber"); Assert.AreEqual(actions[i++].ActionName, "EnterTransferAmount"); Assert.AreEqual(actions[i++].ActionName, "GoToPortal"); Assert.AreEqual(actions[i++].ActionName, "SignIn"); Assert.AreEqual(actions[i++].ActionName, "ViewAccount"); } }
public int Execute(IEnumerable <string> args) { List <string> unhandledArguments = options.Parse(args); if (unhandledArguments.Count > 0) { throw new ArgumentException("There are some unsupported options."); } if (String.IsNullOrEmpty(businessActionsXmlFileName)) { throw new ArgumentException("Missing business actions XML file name."); } if (String.IsNullOrEmpty(testSuiteXsdFileName)) { throw new ArgumentException("Missing test suites XSD file name."); } if (String.IsNullOrEmpty(templateFileName)) { throw new ArgumentException("Missing template file name."); } if (String.IsNullOrEmpty(templateFileExtension)) { throw new ArgumentException("Missing template file extension."); } // parse business actions using (Stream xmlStream = File.OpenRead(businessActionsXmlFileName)) { IBusinessActionXmlParser businessActionXmlParser = new BusinessActionsXmlParser(xmlStream); businessActionsRepository = businessActionXmlParser.Parse(); } XmlValidationHelper xmlValidationHelper = new XmlValidationHelper(); foreach (string testSuiteFileName in testSuitesFileNames) { // validate xml with xsd schema xmlValidationHelper.ValidateXmlDocument(testSuiteFileName, testSuiteXsdFileName); using (XmlTestSuiteParser testSuiteParser = new XmlTestSuiteParser(testSuiteFileName, businessActionsRepository)) { TestSuite parsedTestSuite = testSuiteParser.Parse(); parsedTestSuite.BusinessActionsRepository = businessActionsRepository; // generate c# code string codeFileName = Path.Combine( outputDir, Path.GetFileName(Path.ChangeExtension(testSuiteFileName, templateFileExtension))); System.Console.WriteLine("Creating '{0}'", codeFileName); ITestCodeGenerator codeGenerator = new TemplatedTestCodeGenerator(templateFileName, codeFileName); codeGenerator.Generate(parsedTestSuite); } } return(0); }