public void RevisionChildless() { RevisipnStatementCorrectChildless = YangInterpreterTool.Load("TestFiles/RevisionStatement/RevisionStatementCorrectChildless.yang"); var rev = RevisipnStatementCorrectChildless.Root.Descendants("revision").Single(); Assert.AreEqual("2019-09-11", rev.Argument); Assert.AreEqual("revision 2019-09-11;", rev.ToString()); }
public void TypeStatementStringParsedCorrectly() { YangInterpreterTool InterpreterCorrect = YangInterpreterTool.Load("TestFiles/TypeStatement/TypeStatementStringTypeCorrect.yang"); var typeString = InterpreterCorrect.Root.Descendants("type").First(); Assert.AreEqual("string", typeString.Argument); Assert.AreEqual("Length", typeString.Elements().First().Name); Assert.AreEqual(1, typeString.Elements().Count()); }
public void PathIsParsedCorrectly() { InterpreterCorrect = YangInterpreterTool.Load("TestFiles/PathStatement/LeafRefTypeStatementCorrect.yang"); var typeStatement = InterpreterCorrect.Root.Descendants("type").Single(); var pathStatement = typeStatement.Elements().Single(); Assert.AreEqual("/interface/name", pathStatement.Argument); Assert.AreEqual("path \"/interface/name\";", pathStatement.ToString()); }
public void RevisionIsParsedCorrectly() { RevisipnStatementCorrect = YangInterpreterTool.Load("TestFiles/RevisionStatement/RevisionStatementCorrect.yang"); var Revision = RevisipnStatementCorrect.Root.Descendants("revision").Single(); Assert.AreEqual("2019-09-11", Revision.Argument); Assert.AreEqual("Generic Session Control parameter file.", Revision.Descendants("description").Single().Argument); Assert.AreEqual("The Reference for Revision \r\n2019-09-11", Revision.Descendants("reference").Single().Argument); }
public void EmptyTypeStatementParsedCorrectly() { YangInterpreterTool interpreted = YangInterpreterTool.Load("TestFiles/TypeStatement/TypeStatementCorrect.yang"); var leaf = interpreted.Root.Descendants("leaf").Where(statement => statement.Argument == "emptyTest").FirstOrDefault(); var typeEmpty = leaf.Elements().FirstOrDefault(); Assert.AreEqual("empty", typeEmpty.Argument); Assert.AreEqual(0, typeEmpty.Elements().Count()); Assert.AreEqual("type empty;", typeEmpty.ToString()); }
public void EnumerationTypeIsParsedCorrectly() { YangInterpreterTool EnumStatementParser = YangInterpreterTool.Load("TestFiles/EnumStatement/EnumStatementCorrect.yang"); var enumerationType = EnumStatementParser.Root.Descendants("type").Single(); var elementsOfEnumeration = enumerationType.Elements(); Assert.AreEqual(3, elementsOfEnumeration.Count()); Assert.AreEqual("zero", elementsOfEnumeration.ToList()[0].Argument); Assert.AreEqual("one", elementsOfEnumeration.ToList()[1].Argument); Assert.AreEqual("seven", elementsOfEnumeration.ToList()[2].Argument); }
static void HandleChildSearchSearch(YangInterpreterTool tool, bool IsElements) { StatementBase selectedStatement = null; var selectedName = GetName(); IEnumerable <StatementBase> elements; if (IsElements) { elements = tool.Root.Elements(selectedName); } else { elements = tool.Root.Descendants(selectedName); } if (elements?.Count() > 1) { Console.WriteLine("Több statement is létezik ami tartalmazza a megadott nevet: " + selectedName); foreach (var item in elements) { Console.WriteLine("Statement neve: " + item.Name + " | Statement argumentuma: " + item.Argument); } var selectedArg = GetArgument(); selectedStatement = elements.FirstOrDefault(statement => statement.Argument == selectedArg); } else { selectedStatement = elements?.FirstOrDefault(); } if (selectedStatement != null) { ShowSeparatedData("Kiválasztott elem neve: " + selectedStatement.Name + " Kiválasztott statement argumentuma: " + selectedStatement.Argument + Environment.NewLine + selectedStatement.ToString()); } Console.WriteLine("A továbblépéshez nyomjon entert..."); Console.ReadLine(); }
public void ParseFunctionWithWrongYangVer() { Assert.Throws <InvalidYangVersion>(() => YangInterpreterTool.Parse("module testModul {\r\n yang-version 1.1;\r\n leaf testLeaf {\r\n type int8; } }")); }
public void Setup() { InterpreterCorrect = YangInterpreterTool.Parse("module testModul {\r\n leaf testLeaf {\r\n type int8; } }"); InterpreterForce = YangInterpreterTool.Parse("module testModul {\r\n yang-version 1.1;\r\n leaf testLeaf {\r\n type int8; } }", InterpreterOption.Force); }
public void Setup() { InterpreterCorrect = YangInterpreterTool.Load("TestFiles/UnionType/UnionTypeStatementCorrect.yang"); }
public void Setup() { InterpreterCorrect = YangInterpreterTool.Load("TestFiles/MandatoryStatement/MandatoryStatementCorrect.yang"); }
public void Setup() { InterpreterCorrect = YangInterpreterTool.Load("TestFiles/OrderedByStatement/OrderedByCorrect.yang"); }
public void DifferentQuoteFinishThanBeg() { Assert.Throws <InterpreterParseFail>(() => YangInterpreterTool.Load("TestFiles/ArgumentParsing/ArgumentParseTestInvalidCase10.yang")); }
public void Setup() { InterpreterCorrect = YangInterpreterTool.Load("TestFiles/NamespaceStatement/NamespaceStatementCorrect.yang"); }
public void OrganizationMissingFirstQuotationMark() { Assert.Throws <InterpreterParseFail>(() => YangInterpreterTool.Load("TestFiles/OrganizationStatement/OrganizationMissingFirstQuotationMark.yang")); }
public void RevisionImproperValue() { Assert.Throws <ImproperValue>(() => YangInterpreterTool.Load("TestFiles/RevisionStatement/RevisionStatementImproperValue.yang")); }
public void Setup() { InterpreterCorrect = YangInterpreterTool.Load("TestFiles/ArgumentParsing/ArgumentParseTestCorrectCases.yang"); }
static void Main(string[] args) { ProgramState state = ProgramState.main; YangInterpreterTool tool = YangInterpreterTool.Load("DemoModule.yang"); var input = ""; while (input != "quit") { if (state == ProgramState.main) { PrintMainMenu(); input = Console.ReadLine(); if (input == "1") { Console.Clear(); state = ProgramState.moduleInfo; } else if (input == "2") { HandleChildSearchSearch(tool, true); } else if (input == "3") { HandleChildSearchSearch(tool, false); } else if (input == "4") { Console.WriteLine(tool.Root.ToString()); Console.WriteLine("A továbblépéshez nyomjon entert..."); Console.ReadLine(); } else if (input == "5") { Console.WriteLine(ToStringFormatted(tool.Root.StatementAsXML().FirstOrDefault())); StreamWriter w = new StreamWriter("DemoOutput.xml"); tool.Root.StatementAsXML().FirstOrDefault().Save(w, SaveOptions.DisableFormatting); Console.WriteLine("A továbblépéshez nyomjon entert..."); Console.ReadLine(); } } else if (state == ProgramState.moduleInfo) { PrintModuleOptions(); input = Console.ReadLine(); switch (input) { case "1": ShowSeparatedData("A betöltött modul neve(argumentumként): " + tool.Root.Argument); break; case "2": var yangVersionStatement = tool.Root.Descendants("yang-version").Single(); ShowSeparatedData("Yang verziója: " + yangVersionStatement.Argument); break; case "3": ShowSeparatedData("A betöltött modul névtere: " + tool.Root.Namespace); break; case "4": ShowSeparatedData("A betöltött modul prefixe: " + tool.Root.Prefix); break; case "5": Console.WriteLine("----------------------------------------------------"); foreach (var item in tool.Root.NamespaceDictionary) { Console.WriteLine("Prefix: " + item.Key + "| Teljes névtér: " + item.Value); } Console.WriteLine("----------------------------------------------------"); break; case "6": Console.Clear(); state = ProgramState.main; break; default: break; } } } }
public void Setup() { InterpreterCorrect = YangInterpreterTool.Load("TestFiles/RequireInstanceStatement/RequireInstanceStatementCorrect.yang"); }
public void Setup() { InterpreterCorrect = YangInterpreterTool.Load("TestFiles/ExtensionStatement/ExtensionStatementCorrect.yang"); }
public void Setup() { RevisipnStatementCorrect = YangInterpreterTool.Load("TestFiles/RevisionStatement/RevisionStatementCorrect.yang"); }
public void OrganizationMissingSemicolon() { Assert.Throws <InterpreterParseFail>(() => YangInterpreterTool.Load("TestFiles/OrganizationStatement/OrganizationMissingSemicolon.yang")); }
public void Setup() { InterpreterCorrect = YangInterpreterTool.Load("TestFiles/Bit/BitTypeCorrect.yang"); }
public void Setup() { InterpreterCorrect = YangInterpreterTool.Load("TestFiles/Boolean/BooleanCorrect.yang"); }
public void InvalidQuoteInNormalQuotedArgument() { Assert.Throws <InterpreterParseFail>(() => YangInterpreterTool.Load("TestFiles/ArgumentParsing/ArgumentParseTestInvalidCase2.yang")); }
public void Setup() { InterpreterCorrect = YangInterpreterTool.Load("TestFiles/AugmentStatement/AugmentStatementCorrect.yang"); }
public void Setup() { InterpreterCorrect = YangInterpreterTool.Load("TestFiles/ContainerStatement/ContainerStatementCorrect.yang"); }
public void InvalidConcatWithNonQuotedArgument() { Assert.Throws <InterpreterParseFail>(() => YangInterpreterTool.Load("TestFiles/ArgumentParsing/ArgumentParseTestInvalidCase5.yang")); }
public void Setup() { InterpreterCorrect = YangInterpreterTool.Load("TestFiles/IfFeature/IfFeatureStatementCorrect.yang"); }
public void NonFinishedSingleQuoteConcattedArgument() { Assert.Throws <StatementEndIsMissing>(() => YangInterpreterTool.Load("TestFiles/ArgumentParsing/ArgumentParseTestInvalidCase9.yang")); }