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());
        }
Exemplo n.º 2
0
        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());
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 5
0
        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());
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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");
 }
Exemplo n.º 11
0
 public void Setup()
 {
     InterpreterCorrect = YangInterpreterTool.Load("TestFiles/MandatoryStatement/MandatoryStatementCorrect.yang");
 }
Exemplo n.º 12
0
 public void Setup()
 {
     InterpreterCorrect = YangInterpreterTool.Load("TestFiles/OrderedByStatement/OrderedByCorrect.yang");
 }
Exemplo n.º 13
0
 public void DifferentQuoteFinishThanBeg()
 {
     Assert.Throws <InterpreterParseFail>(() => YangInterpreterTool.Load("TestFiles/ArgumentParsing/ArgumentParseTestInvalidCase10.yang"));
 }
Exemplo n.º 14
0
 public void Setup()
 {
     InterpreterCorrect = YangInterpreterTool.Load("TestFiles/NamespaceStatement/NamespaceStatementCorrect.yang");
 }
Exemplo n.º 15
0
 public void OrganizationMissingFirstQuotationMark()
 {
     Assert.Throws <InterpreterParseFail>(() => YangInterpreterTool.Load("TestFiles/OrganizationStatement/OrganizationMissingFirstQuotationMark.yang"));
 }
Exemplo n.º 16
0
 public void RevisionImproperValue()
 {
     Assert.Throws <ImproperValue>(() => YangInterpreterTool.Load("TestFiles/RevisionStatement/RevisionStatementImproperValue.yang"));
 }
Exemplo n.º 17
0
 public void Setup()
 {
     InterpreterCorrect = YangInterpreterTool.Load("TestFiles/ArgumentParsing/ArgumentParseTestCorrectCases.yang");
 }
Exemplo n.º 18
0
        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;
                    }
                }
            }
        }
Exemplo n.º 19
0
 public void Setup()
 {
     InterpreterCorrect = YangInterpreterTool.Load("TestFiles/RequireInstanceStatement/RequireInstanceStatementCorrect.yang");
 }
Exemplo n.º 20
0
 public void Setup()
 {
     InterpreterCorrect = YangInterpreterTool.Load("TestFiles/ExtensionStatement/ExtensionStatementCorrect.yang");
 }
Exemplo n.º 21
0
 public void Setup()
 {
     RevisipnStatementCorrect = YangInterpreterTool.Load("TestFiles/RevisionStatement/RevisionStatementCorrect.yang");
 }
Exemplo n.º 22
0
 public void OrganizationMissingSemicolon()
 {
     Assert.Throws <InterpreterParseFail>(() => YangInterpreterTool.Load("TestFiles/OrganizationStatement/OrganizationMissingSemicolon.yang"));
 }
Exemplo n.º 23
0
 public void Setup()
 {
     InterpreterCorrect = YangInterpreterTool.Load("TestFiles/Bit/BitTypeCorrect.yang");
 }
Exemplo n.º 24
0
 public void Setup()
 {
     InterpreterCorrect = YangInterpreterTool.Load("TestFiles/Boolean/BooleanCorrect.yang");
 }
Exemplo n.º 25
0
 public void InvalidQuoteInNormalQuotedArgument()
 {
     Assert.Throws <InterpreterParseFail>(() => YangInterpreterTool.Load("TestFiles/ArgumentParsing/ArgumentParseTestInvalidCase2.yang"));
 }
Exemplo n.º 26
0
 public void Setup()
 {
     InterpreterCorrect = YangInterpreterTool.Load("TestFiles/AugmentStatement/AugmentStatementCorrect.yang");
 }
 public void Setup()
 {
     InterpreterCorrect = YangInterpreterTool.Load("TestFiles/ContainerStatement/ContainerStatementCorrect.yang");
 }
Exemplo n.º 28
0
 public void InvalidConcatWithNonQuotedArgument()
 {
     Assert.Throws <InterpreterParseFail>(() => YangInterpreterTool.Load("TestFiles/ArgumentParsing/ArgumentParseTestInvalidCase5.yang"));
 }
 public void Setup()
 {
     InterpreterCorrect = YangInterpreterTool.Load("TestFiles/IfFeature/IfFeatureStatementCorrect.yang");
 }
Exemplo n.º 30
0
 public void NonFinishedSingleQuoteConcattedArgument()
 {
     Assert.Throws <StatementEndIsMissing>(() => YangInterpreterTool.Load("TestFiles/ArgumentParsing/ArgumentParseTestInvalidCase9.yang"));
 }