コード例 #1
0
        public void TestContructor()
        {
            var counter64 = new Counter64(new byte[] {0x00, 0xC9, 0xAC, 0xC1, 0x87, 0x4B, 0xB1, 0xE1, 0xC9});
            Assert.AreEqual(14532202884452442569, counter64.ToUInt64());
            Assert.AreEqual(14532202884452442569.GetHashCode(), counter64.GetHashCode());
            Assert.AreEqual("14532202884452442569", counter64.ToString());

            Assert.Throws<ArgumentNullException>(() => new Counter64(new Tuple<int, byte[]>(0, new byte[] { 0 }), null));
            Assert.Throws<ArgumentException>(() => new Counter64(new Tuple<int, byte[]>(-1, new[] { (byte)255 }), new MemoryStream()));
            Assert.Throws<ArgumentException>(() => new Counter64(new Tuple<int, byte[]>(10, new byte[]{10}), new MemoryStream()));
            Assert.Throws<ArgumentException>(
                () => new Counter64(new byte[] {0x05, 0xC9, 0xAC, 0xC1, 0x87, 0x4B, 0xB1, 0xE1, 0xC9}));

            var small = new Counter64(new byte[] { 0x00, 0xC9, 0xAC, 0xC1, 0x87 });
            Assert.AreEqual(3383542151, small.ToUInt64());

            Assert.Throws<ArgumentNullException>(() => new Counter64(0).AppendBytesTo(null));
        }
コード例 #2
0
        public void TestContructor()
        {
            var counter64 = new Counter64(new byte[] { 0x00, 0xC9, 0xAC, 0xC1, 0x87, 0x4B, 0xB1, 0xE1, 0xC9 });

            Assert.AreEqual(14532202884452442569, counter64.ToUInt64());
            Assert.AreEqual(14532202884452442569.GetHashCode(), counter64.GetHashCode());
            Assert.AreEqual("14532202884452442569", counter64.ToString());

            Assert.Throws <ArgumentNullException>(() => new Counter64(0, null));
            Assert.Throws <ArgumentException>(() => new Counter64(-1, new MemoryStream()));
            Assert.Throws <ArgumentException>(() => new Counter64(10, new MemoryStream()));
            Assert.Throws <ArgumentException>(
                () => new Counter64(new byte[] { 0x05, 0xC9, 0xAC, 0xC1, 0x87, 0x4B, 0xB1, 0xE1, 0xC9 }));

            var small = new Counter64(new byte[] { 0x00, 0xC9, 0xAC, 0xC1, 0x87 });

            Assert.AreEqual(3383542151, small.ToUInt64());

            Assert.Throws <ArgumentNullException>(() => new Counter64(0).AppendBytesTo(null));
        }
コード例 #3
0
        public void ConvertToString()
        {
            var i1 = new Counter64(10);

            Assert.Equal("10", i1.ToString());
        }