public void TestParse3() { const string test = "::=BEGIN"; Lexer lexer = new Lexer(); StringReader reader = new StringReader(test); lexer.Parse(reader); Assert.AreEqual("::=", lexer.NextSymbol.ToString()); Assert.AreEqual("BEGIN", lexer.NextSymbol.ToString()); }
public void TestMethod() { Lexer lexer = new Lexer(); lexer.Parse(new StringReader("{ iso org(3) dod(6) 1 }")); string parent; uint value; lexer.ParseOidValue(out parent, out value); Assert.AreEqual("iso.org(3).dod(6)", parent); Assert.AreEqual(1, value); }
public void TestParse() { Lexer lexer = new Lexer(); MemoryStream m = new MemoryStream(Resources.SNMPv2_SMI); using (StreamReader reader = new StreamReader(m)) { lexer.Parse(reader); reader.Close(); } Assert.AreEqual(909, lexer.SymbolCount); }
public void TestMethod1() { Lexer lexer = new Lexer(); lexer.Parse(new StringReader("{ iso(1) std(0) iso8802(8802) ieee802dot1(1)" + Environment.NewLine + " ieee802dot1mibs(1) 1 }")); string parent; uint value; lexer.ParseOidValue(out parent, out value); Assert.AreEqual("iso(1).std(0).iso8802(8802).ieee802dot1(1).ieee802dot1mibs(1)", parent); Assert.AreEqual(1, value); }
public void TestException() { Lexer lexer = new Lexer(); MemoryStream m = new MemoryStream(Resources.fivevarbinds); using (StreamReader reader = new StreamReader(m)) { lexer.Parse("temp.txt", reader); reader.Close(); } new MibDocument(lexer); }
public void TestOverlappingRanges3() { const string test = "SomeEnum ::= INTEGER (8 | 8 | 31 .. 60 )"; Lexer lexer = new Lexer(); StringReader reader = new StringReader(test); lexer.Parse(reader); string name = lexer.GetNextSymbol().ToString(); lexer.GetNextSymbol().Expect(Symbol.Assign); lexer.GetNextSymbol().Expect(Symbol.Integer); Assert.Throws<MibException>(() => new IntegerType("module", "name", lexer)); }
public void Test() { const string test = "SomeIp ::= IpAddress"; Lexer lexer = new Lexer(); StringReader reader = new StringReader(test); lexer.Parse(reader); string name = lexer.GetNextSymbol().ToString(); lexer.GetNextSymbol().Expect(Symbol.Assign); lexer.GetNextSymbol().Expect(Symbol.IpAddress); IpAddressType i = new IpAddressType("module", "name", lexer); }
public void TestEnumerable() { const string test = "SomeEnum ::= Counter64"; Lexer lexer = new Lexer(); StringReader reader = new StringReader(test); lexer.Parse(reader); string name = lexer.GetNextSymbol().ToString(); lexer.GetNextSymbol().Expect(Symbol.Assign); lexer.GetNextSymbol().Expect(Symbol.Counter64); Counter64Type i = new Counter64Type("module", "name", lexer); }
public void TestNegative() { const string test = "SomeEnum ::= OCTET STRING ( SIZE (8 | -5 .. 20 | 31 .. 60 ))"; Lexer lexer = new Lexer(); StringReader reader = new StringReader(test); lexer.Parse(reader); string name = lexer.GetNextSymbol().ToString(); lexer.GetNextSymbol().Expect(Symbol.Assign); lexer.GetNextSymbol().Expect(Symbol.Octet); lexer.GetNextSymbol().Expect(Symbol.String); Assert.Throws<MibException>(delegate { new OctetStringType("module", "name", lexer); }); }
public void Test() { const string test = "SomeEnum ::= BITS {first(1), second(2)}"; Lexer lexer = new Lexer(); StringReader reader = new StringReader(test); lexer.Parse(reader); string name = lexer.GetNextSymbol().ToString(); lexer.GetNextSymbol().Expect(Symbol.Assign); lexer.GetNextSymbol().Expect(Symbol.Bits); BitsType i = new BitsType("module", "name", lexer); Assert.AreEqual("first(1)", i[1]); }
public void TestEnumerable() { const string test = "SomeEnum ::= INTEGER {first(1), second(2)}"; Lexer lexer = new Lexer(); StringReader reader = new StringReader(test); lexer.Parse(reader); string name = lexer.GetNextSymbol().ToString(); lexer.GetNextSymbol().Expect(Symbol.Assign); lexer.GetNextSymbol().Expect(Symbol.Integer); IntegerType i = new IntegerType("module", "name", lexer); Assert.IsTrue(i.IsEnumeration); Assert.AreEqual("first(1)", i[1]); }
private static IList <IModule> CompileToModules(string file, TextReader stream) { var watch = new System.Diagnostics.Stopwatch(); watch.Start(); Lexer lexer = new Lexer(); lexer.Parse(file, stream); MibDocument doc = new MibDocument(lexer); Logger.Info(watch.ElapsedMilliseconds.ToString(CultureInfo.InvariantCulture) + "-ms used to parse " + file); watch.Stop(); return(doc.Modules); }
public void TestEmpty() { // issue 4978 Lexer lexer = new Lexer(); MemoryStream m = new MemoryStream(Resources.empty); using (StreamReader reader = new StreamReader(m)) { lexer.Parse(reader); reader.Close(); } MibDocument file = new MibDocument(lexer); Assert.AreEqual("SNMPV2-CONF", file.Modules[0].Name); Assert.AreEqual(0, file.Modules[0].Dependents.Count); Assert.AreEqual(0, file.Modules[0].Entities.Count); }
public void TestHttpMib() { // issue 4978 Lexer lexer = new Lexer(); MemoryStream m = new MemoryStream(Resources.httpmib); using (StreamReader reader = new StreamReader(m)) { lexer.Parse(reader); reader.Close(); } MibDocument file = new MibDocument(lexer); Assert.AreEqual("HTTPSERVER-MIB", file.Modules[0].Name); Assert.AreEqual(0, file.Modules[0].Dependents.Count); Assert.AreEqual(0, file.Modules[0].Entities.Count); }
// TODO: [Test] public void TestSNMPv2_PDU() { Lexer lexer = new Lexer(); MemoryStream m = new MemoryStream(Resources.SNMPV2_PDU); using (StreamReader reader = new StreamReader(m)) { lexer.Parse(reader); reader.Close(); } MibDocument file = new MibDocument(lexer); Assert.AreEqual("SNMPv2-PDU", file.Modules[0].Name); Assert.AreEqual(5, file.Modules[0].Dependents.Count); Assert.AreEqual(55, file.Modules[0].Entities.Count); IEntity node = file.Modules[0].Entities[54]; Assert.AreEqual("casConfigGroup", node.Name); Assert.AreEqual(2, node.Value); Assert.AreEqual("casMIBGroups", node.Parent); }
public void TestRanges() { const string test = "SomeEnum ::= INTEGER (8 |10 ..20| 31..60 )"; Lexer lexer = new Lexer(); StringReader reader = new StringReader(test); lexer.Parse(reader); string name = lexer.GetNextSymbol().ToString(); lexer.GetNextSymbol().Expect(Symbol.Assign); lexer.GetNextSymbol().Expect(Symbol.Integer); IntegerType i = new IntegerType("module", "name", lexer); Assert.IsFalse(i.IsEnumeration); Assert.IsTrue(i.Contains(8)); Assert.IsTrue(i.Contains(10)); Assert.IsTrue(i.Contains(15)); Assert.IsTrue(i.Contains(20)); Assert.IsTrue(i.Contains(35)); Assert.IsFalse(i.Contains(4)); Assert.IsFalse(i.Contains(-9)); Assert.IsFalse(i.Contains(25)); Assert.IsFalse(i.Contains(61)); }
public void TestRanges() { const string test = "SomeEnum ::= OCTET STRING ( SIZE (5 | 8 .. 20 | 31 .. 60 ))"; Lexer lexer = new Lexer(); StringReader reader = new StringReader(test); lexer.Parse(reader); string name = lexer.GetNextSymbol().ToString(); lexer.GetNextSymbol().Expect(Symbol.Assign); lexer.GetNextSymbol().Expect(Symbol.Octet); lexer.GetNextSymbol().Expect(Symbol.String); OctetStringType i = new OctetStringType("module", "name", lexer); Assert.IsTrue(i.Contains(8)); Assert.IsTrue(i.Contains(5)); Assert.IsTrue(i.Contains(15)); Assert.IsTrue(i.Contains(20)); Assert.IsTrue(i.Contains(35)); Assert.IsFalse(i.Contains(4)); Assert.IsFalse(i.Contains(-9)); Assert.IsFalse(i.Contains(25)); Assert.IsFalse(i.Contains(61)); }
public void TestNet_Snmp_System_MIB() { Lexer lexer = new Lexer(); MemoryStream m = new MemoryStream(Resources.NET_SNMP_SYSTEM_MIB); using (StreamReader reader = new StreamReader(m)) { lexer.Parse(reader); reader.Close(); } MibDocument file = new MibDocument(lexer); Assert.AreEqual(1, file.Modules.Count); Assert.AreEqual("NET-SNMP-SYSTEM-MIB", file.Modules[0].Name); Assert.AreEqual(6, file.Modules[0].Entities.Count); IEntity node = file.Modules[0].Entities[5]; Assert.AreEqual("nsDiskIO", node.Name); Assert.AreEqual(35, node.Value); Assert.AreEqual("netSnmpObjects", node.Parent); }
public void TestIPv6_Flow_Label_MIB() { Lexer lexer = new Lexer(); MemoryStream m = new MemoryStream(Resources.IPV6_FLOW_LABEL_MIB); using (StreamReader reader = new StreamReader(m)) { lexer.Parse(reader); reader.Close(); } MibDocument file = new MibDocument(lexer); Assert.AreEqual(1, file.Modules.Count); Assert.AreEqual("IPV6-FLOW-LABEL-MIB", file.Modules[0].Name); Assert.AreEqual(1, file.Modules[0].Entities.Count); IEntity node = file.Modules[0].Entities[0]; Assert.AreEqual("ipv6FlowLabelMIB", node.Name); Assert.AreEqual(103, node.Value); Assert.AreEqual("mib-2", node.Parent); }
public void TestUDP_MIB() { Lexer lexer = new Lexer(); MemoryStream m = new MemoryStream(Resources.UDP_MIB); using (StreamReader reader = new StreamReader(m)) { lexer.Parse(reader); reader.Close(); } MibDocument file = new MibDocument(lexer); Assert.AreEqual(1, file.Modules.Count); Assert.AreEqual("UDP-MIB", file.Modules[0].Name); Assert.AreEqual(31, file.Modules[0].Entities.Count); IEntity node = file.Modules[0].Entities[30]; Assert.AreEqual("udpEndpointGroup", node.Name); Assert.AreEqual(4, node.Value); Assert.AreEqual("udpMIBGroups", node.Parent); }
public void TestNetwork_Service_MIB() { Lexer lexer = new Lexer(); MemoryStream m = new MemoryStream(Resources.NETWORK_SERVICES_MIB); using (StreamReader reader = new StreamReader(m)) { lexer.Parse(reader); reader.Close(); } MibDocument file = new MibDocument(lexer); Assert.AreEqual(1, file.Modules.Count); Assert.AreEqual("NETWORK-SERVICES-MIB", file.Modules[0].Name); Assert.AreEqual(44, file.Modules[0].Entities.Count); IEntity node = file.Modules[0].Entities[43]; Assert.AreEqual("applUDPProtoID", node.Name); Assert.AreEqual(5, node.Value); Assert.AreEqual("application", node.Parent); }
public void TestNotification_Log_MIB() { Lexer lexer = new Lexer(); MemoryStream m = new MemoryStream(Resources.NOTIFICATION_LOG_MIB); using (StreamReader reader = new StreamReader(m)) { lexer.Parse(reader); reader.Close(); } MibDocument file = new MibDocument(lexer); Assert.AreEqual(1, file.Modules.Count); Assert.AreEqual("NOTIFICATION-LOG-MIB", file.Modules[0].Name); Assert.AreEqual(55, file.Modules[0].Entities.Count); IEntity node = file.Modules[0].Entities[54]; Assert.AreEqual("notificationLogDateGroup", node.Name); Assert.AreEqual(4, node.Value); Assert.AreEqual("notificationLogMIBGroups", node.Parent); }
public void TestNet_Snmp_TC() { Lexer lexer = new Lexer(); MemoryStream m = new MemoryStream(Resources.NET_SNMP_TC); using (StreamReader reader = new StreamReader(m)) { lexer.Parse(reader); reader.Close(); } MibDocument file = new MibDocument(lexer); Assert.AreEqual(1, file.Modules.Count); Assert.AreEqual("NET-SNMP-TC", file.Modules[0].Name); Assert.AreEqual(24, file.Modules[0].Entities.Count); IEntity node = file.Modules[0].Entities[23]; Assert.AreEqual("netSnmpCallbackDomain", node.Name); Assert.AreEqual(6, node.Value); Assert.AreEqual("netSnmpDomains", node.Parent); }
public void TestNet_Snmp_VACM_MIB() { Lexer lexer = new Lexer(); MemoryStream m = new MemoryStream(Resources.NET_SNMP_VACM_MIB); using (StreamReader reader = new StreamReader(m)) { lexer.Parse(reader); reader.Close(); } MibDocument file = new MibDocument(lexer); Assert.AreEqual(1, file.Modules.Count); Assert.AreEqual("NET-SNMP-VACM-MIB", file.Modules[0].Name); Assert.AreEqual(8, file.Modules[0].Entities.Count); IEntity node = file.Modules[0].Entities[7]; Assert.AreEqual("nsVacmStatus", node.Name); Assert.AreEqual(5, node.Value); Assert.AreEqual("nsVacmAccessEntry", node.Parent); }
public void TestMTA_MIB() { Lexer lexer = new Lexer(); MemoryStream m = new MemoryStream(Resources.MTA_MIB); using (StreamReader reader = new StreamReader(m)) { lexer.Parse(reader); reader.Close(); } MibDocument file = new MibDocument(lexer); Assert.AreEqual(1, file.Modules.Count); Assert.AreEqual("MTA-MIB", file.Modules[0].Name); Assert.AreEqual(81, file.Modules[0].Entities.Count); IEntity node = file.Modules[0].Entities[80]; Assert.AreEqual("mtaRFC2789ErrorGroup", node.Name); Assert.AreEqual(9, node.Value); Assert.AreEqual("mtaGroups", node.Parent); }
public void TestNet_Snmp_Examples_MIB() { Lexer lexer = new Lexer(); MemoryStream m = new MemoryStream(Resources.NET_SNMP_EXAMPLES_MIB); using (StreamReader reader = new StreamReader(m)) { lexer.Parse(reader); reader.Close(); } MibDocument file = new MibDocument(lexer); Assert.AreEqual(1, file.Modules.Count); Assert.AreEqual("NET-SNMP-EXAMPLES-MIB", file.Modules[0].Name); Assert.AreEqual(25, file.Modules[0].Entities.Count); IEntity node = file.Modules[0].Entities[24]; Assert.AreEqual("netSnmpExampleNotification", node.Name); Assert.AreEqual(1, node.Value); Assert.AreEqual("netSnmpExampleNotifications", node.Parent); }
public void TestNet_Snmp_Monitor_MIB() { Lexer lexer = new Lexer(); MemoryStream m = new MemoryStream(Resources.NET_SNMP_MONITOR_MIB); using (StreamReader reader = new StreamReader(m)) { lexer.Parse(reader); reader.Close(); } MibDocument file = new MibDocument(lexer); Assert.AreEqual(1, file.Modules.Count); Assert.AreEqual("NET-SNMP-MONITOR-MIB", file.Modules[0].Name); Assert.AreEqual(5, file.Modules[0].Entities.Count); IEntity node = file.Modules[0].Entities[4]; Assert.AreEqual("nsLog", node.Name); Assert.AreEqual(24, node.Value); Assert.AreEqual("netSnmpObjects", node.Parent); }
public void TestNet_Snmp_MIB() { Lexer lexer = new Lexer(); MemoryStream m = new MemoryStream(Resources.NET_SNMP_MIB); using (StreamReader reader = new StreamReader(m)) { lexer.Parse(reader); reader.Close(); } MibDocument file = new MibDocument(lexer); Assert.AreEqual(1, file.Modules.Count); Assert.AreEqual("NET-SNMP-MIB", file.Modules[0].Name); Assert.AreEqual(14, file.Modules[0].Entities.Count); IEntity node = file.Modules[0].Entities[13]; Assert.AreEqual("netSnmpGroups", node.Name); Assert.AreEqual(2, node.Value); Assert.AreEqual("netSnmpConformance", node.Parent); }
public void TestNet_Snmp_Extend_MIB() { Lexer lexer = new Lexer(); MemoryStream m = new MemoryStream(Resources.NET_SNMP_EXTEND_MIB); using (StreamReader reader = new StreamReader(m)) { lexer.Parse(reader); reader.Close(); } MibDocument file = new MibDocument(lexer); Assert.AreEqual(1, file.Modules.Count); Assert.AreEqual("NET-SNMP-EXTEND-MIB", file.Modules[0].Name); Assert.AreEqual(27, file.Modules[0].Entities.Count); IEntity node = file.Modules[0].Entities[26]; Assert.AreEqual("nsExtendOutputGroup", node.Name); Assert.AreEqual(2, node.Value); Assert.AreEqual("nsExtendGroups", node.Parent); }
public void TestNet_Snmp_Agent_MIB() { Lexer lexer = new Lexer(); MemoryStream m = new MemoryStream(Resources.NET_SNMP_AGENT_MIB); using (StreamReader reader = new StreamReader(m)) { lexer.Parse(reader); reader.Close(); } MibDocument file = new MibDocument(lexer); Assert.AreEqual(1, file.Modules.Count); Assert.AreEqual("NET-SNMP-AGENT-MIB", file.Modules[0].Name); Assert.AreEqual(54, file.Modules[0].Entities.Count); IEntity node = file.Modules[0].Entities[53]; Assert.AreEqual("nsAgentNotifyGroup", node.Name); Assert.AreEqual(9, node.Value); Assert.AreEqual("netSnmpGroups", node.Parent); }
public void TestRFC1157_SNMP_MIB() { Lexer lexer = new Lexer(); MemoryStream m = new MemoryStream(Resources.RFC1157_SNMP); using (StreamReader reader = new StreamReader(m)) { lexer.Parse(reader); reader.Close(); } MibDocument file = new MibDocument(lexer); Assert.AreEqual("RFC1157-SNMP", file.Modules[0].Name); Assert.AreEqual(1, file.Modules[0].Dependents.Count); Assert.AreEqual(0, file.Modules[0].Entities.Count); }