public void TestFakeTrapTransform() { var typeMap = new SnmpTrapTypeMap(); var transform = typeMap.GetTransform(typeof(TrapTypeMapTests.FakeTrap)); Assert.IsNotNull(transform); var env = new Envelope(DateTimeOffset.MinValue, DateTimeOffset.MinValue, "", "", "", null, this.snmpDatagram); var key = typeMap.GetInputKey(env); var transformedOutput = transform(env) as TrapTypeMapTests.FakeTrap; Assert.IsNotNull(transformedOutput); Assert.AreEqual(506009u, transformedOutput.SysUpTime); Assert.AreEqual(5L, transformedOutput.Integer); Assert.IsNotNull(transformedOutput.Objects); Assert.AreEqual(4, transformedOutput.Objects.Count); Assert.AreEqual(IPAddress.Parse("1.1.1.1"), transformedOutput.SourceAddress); Assert.AreEqual(this.snmpDatagram.ReceivedTime, transformedOutput.ReceivedTime); var varbinds = transformedOutput.Objects; var extraneous = varbinds.FirstOrDefault(vb => vb.Oid.Equals(new ObjectIdentifier("1.3.6.1.6.3.1.1.42.42.42.0"))); Assert.IsNotNull(extraneous); Assert.AreNotEqual(default(VarBind), extraneous); Assert.AreEqual(8938ul, extraneous.Value); }
public void TestFakeTrapInputKey() { var typeMap = new SnmpTrapTypeMap(); var env = new Envelope(DateTimeOffset.MinValue, DateTimeOffset.MinValue, "", "", "", null, this.snmpDatagram); var inputKey = typeMap.GetInputKey(env); Assert.AreEqual(new ObjectIdentifier("1.3.6.1.4.1.500.12"), inputKey); var typeKey = typeMap.GetTypeKey(typeof(TrapTypeMapTests.FakeTrap)); Assert.AreEqual(inputKey, typeKey); }
public void TestFakeTrapStringIpTransform() { var typeMap = new SnmpTrapTypeMap(); var transform = typeMap.GetTransform(typeof(TrapTypeMapTests.FakeTrapStringIp)); Assert.IsNotNull(transform); var env = new Envelope(DateTimeOffset.MinValue, DateTimeOffset.MinValue, "", "", "", null, this.snmpDatagram); var key = typeMap.GetInputKey(env); var transformedOutput = transform(env) as TrapTypeMapTests.FakeTrapStringIp; Assert.IsNotNull(transformedOutput); Assert.AreEqual("1.1.1.1", transformedOutput.SourceAddress); }