Пример #1
0
 public void TestNegative2()
 {
     // bug 7217 http://sharpsnmplib.codeplex.com/workitem/7217
     Integer32 i = new Integer32(-250);
     var result = DataFactory.CreateSnmpData(i.ToBytes());
     Assert.AreEqual(SnmpType.Integer32, result.TypeCode);
     Assert.AreEqual(-250, ((Integer32)result).ToInt32());
 }
 public void TestNegative()
 {
     const int i = -2147418240;
     Integer32 data = new Integer32(i);
     byte[] bytes = data.ToBytes();
     Integer32 other = (Integer32)DataFactory.CreateSnmpData(bytes);
     Assert.AreEqual(i, other.ToInt32());
 }
Пример #3
0
        public void TestNegative2()
        {
            // bug 7217 https://sharpsnmplib.codeplex.com/workitem/7217
            Integer32 i      = new Integer32(-250);
            var       result = DataFactory.CreateSnmpData(i.ToBytes());

            Assert.Equal(SnmpType.Integer32, result.TypeCode);
            Assert.Equal(-250, ((Integer32)result).ToInt32());
        }
 public void TestNegative3()
 {
 	// #7240
     const int i = -237053658;
     Integer32 data = new Integer32(i);
     byte[] bytes = data.ToBytes();
     Assert.AreEqual(6, bytes.Length);
     var exception = Assert.Throws<ArgumentException>(() => DataFactory.CreateSnmpData(new byte[] { 0x02, 0x05, 0xFF, 0xF1, 0xDE, 0xD9, 0x26 }));
     Assert.AreEqual("truncation error for 32-bit integer coding\r\nParameter name: length", exception.Message);
 }
Пример #5
0
        public void TestNegative()
        {
            const int i    = -2147418240;
            Integer32 data = new Integer32(i);

            byte[]    bytes = data.ToBytes();
            Integer32 other = (Integer32)DataFactory.CreateSnmpData(bytes);

            Assert.Equal(i, other.ToInt32());
        }
Пример #6
0
 public void TestToBytes()
 {
     byte[] bytes = new byte[] {0x02, 0x02, 0x96, 0xB5};
     Integer32 test = new Integer32(-26955);
     Assert.AreEqual(bytes, test.ToBytes());
     
     Assert.AreEqual(new byte[] {0x02, 0x02, 0x00, 0xFF}, new Integer32(255).ToBytes());
     
     Assert.AreEqual(6, new Integer32(2147483647).ToBytes().Length);
 }
Пример #7
0
        public void TestToBytes()
        {
            byte[]    bytes = new byte[] { 0x02, 0x02, 0x96, 0xB5 };
            Integer32 test  = new Integer32(-26955);

            Assert.Equal(bytes, test.ToBytes());

            Assert.Equal(new byte[] { 0x02, 0x02, 0x00, 0xFF }, new Integer32(255).ToBytes());

            Assert.Equal(6, new Integer32(2147483647).ToBytes().Length);
        }
Пример #8
0
        public void TestNegative3()
        {
            // #7240
            const int i    = -237053658;
            Integer32 data = new Integer32(i);

            byte[] bytes = data.ToBytes();
            Assert.Equal(6, bytes.Length);
            var exception = Assert.Throws <SnmpException>(() => DataFactory.CreateSnmpData(new byte[] { 0x02, 0x05, 0xFF, 0xF1, 0xDE, 0xD9, 0x26 }));

            Assert.Contains("Truncation error for 32-bit integer coding.", exception.InnerException.Message);
        }
Пример #9
0
        public void TestNegative3()
        {
            // #7240
            const int i    = -237053658;
            Integer32 data = new Integer32(i);

            byte[] bytes = data.ToBytes();
            Assert.Equal(6, bytes.Length);
            var exception = Assert.Throws <SnmpException>(() => DataFactory.CreateSnmpData(new byte[] { 0x02, 0x05, 0xFF, 0xF1, 0xDE, 0xD9, 0x26 }));

            Assert.Equal(string.Format("truncation error for 32-bit integer coding{0}Parameter name: length", Environment.NewLine), exception.InnerException.Message);
        }
Пример #10
0
        public void TestNegative3()
        {
            // #7240
            const int i    = -237053658;
            Integer32 data = new Integer32(i);

            byte[] bytes = data.ToBytes();
            Assert.AreEqual(6, bytes.Length);
            var exception = Assert.Throws <ArgumentException>(() => DataFactory.CreateSnmpData(new byte[] { 0x02, 0x05, 0xFF, 0xF1, 0xDE, 0xD9, 0x26 }));

            Assert.AreEqual("truncation error for 32-bit integer coding\r\nParameter name: length", exception.Message);
        }
Пример #11
0
 public void TestToBytes2()
 {
     Integer32 i = new Integer32(-1);
     Assert.AreEqual(new byte[] {0x02, 0x01, 0xFF}, i.ToBytes());
 }
Пример #12
0
        public void TestToBytes2()
        {
            Integer32 i = new Integer32(-1);

            Assert.Equal(new byte[] { 0x02, 0x01, 0xFF }, i.ToBytes());
        }