public void ReturnFalse_GivenBytesWithOnlyPaddingByte()
        {
            var bytes = new byte[] { 0x00 };

            var reader           = new DhcpBinaryReader(bytes);
            var collectionReader = new DhcpTaggedValueCollectionReader(reader);

            Assert.False(collectionReader.HasNextItem());
        }
Пример #2
0
        public void ThrowsInvalidOperationException_GivenBytesWithOnlyPaddingByte()
        {
            var bytes = new byte[] { 0x00 };

            var reader           = new DhcpBinaryReader(bytes);
            var collectionReader = new DhcpTaggedValueCollectionReader(reader);

            Assert.Throws <InvalidOperationException>(
                () => collectionReader.NextItem());
        }
Пример #3
0
        public void SkipPaddingOption()
        {
            var bytes = new byte[] { 0x00, 0x01, 0x02, 0x00, 0x00 };

            var reader           = new DhcpBinaryReader(bytes);
            var collectionReader = new DhcpTaggedValueCollectionReader(reader);

            var item = collectionReader.NextItem();

            Assert.Equal(1, item.Tag);
        }
        public void ReturnTrue_WhenHasMoreItems()
        {
            var bytes = new byte[] { 0x01, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01 };

            var reader           = new DhcpBinaryReader(bytes);
            var collectionReader = new DhcpTaggedValueCollectionReader(reader);

            collectionReader.NextItem();

            Assert.True(collectionReader.HasNextItem());
        }
        public void ReturnTrue_GivenBytesWithPadOptionAndOtherOptions()
        {
            var bytes = new byte[] { 0x00, 0x01, 0x02, 0x00, 0x00 };

            var reader           = new DhcpBinaryReader(bytes);
            var collectionReader = new DhcpTaggedValueCollectionReader(reader);

            collectionReader.NextItem();

            Assert.False(collectionReader.HasNextItem());
        }
        public void ReturnFalse_WhenNextItemIsEndByte()
        {
            var bytes = new byte[] { 0x01, 0x02, 0x00, 0x00, 0xff, 0x01, 0x02, 0x00, 0x00 };

            var reader           = new DhcpBinaryReader(bytes);
            var collectionReader = new DhcpTaggedValueCollectionReader(reader);

            collectionReader.NextItem();

            Assert.False(collectionReader.HasNextItem());
        }
Пример #7
0
        public void ThrowsInvalidOperationException_WhenNextItemIsEndByte()
        {
            var bytes = new byte[] { 0x01, 0x02, 0x00, 0x00, 0xff, 0x01, 0x02, 0x00, 0x00 };

            var reader           = new DhcpBinaryReader(bytes);
            var collectionReader = new DhcpTaggedValueCollectionReader(reader);

            collectionReader.NextItem();

            Assert.Throws <InvalidOperationException>(
                () => collectionReader.NextItem());
        }
Пример #8
0
        public void ReturnNextItem_WhenHasMoreItems()
        {
            var bytes = new byte[] { 0x01, 0x02, 0x00, 0x00, 0x09, 0x02, 0x01, 0x01 };

            var reader           = new DhcpBinaryReader(bytes);
            var collectionReader = new DhcpTaggedValueCollectionReader(reader);

            collectionReader.NextItem();

            var item = collectionReader.NextItem();

            Assert.Equal(0x09, item.Tag);
        }
Пример #9
0
        public void ReturnNextItemOfGivenLength()
        {
            var bytes = new byte[] { 0x01, 0x02, 0x00, 0x00, 0x09, 0x03, 0x01, 0x01, 0x01 };

            var reader           = new DhcpBinaryReader(bytes);
            var collectionReader = new DhcpTaggedValueCollectionReader(reader);

            collectionReader.NextItem();

            var item = collectionReader.NextItem();

            Assert.Equal(3, item.Value.AsBytes().Length);
            Assert.True(item.Value.AsBytes().All(x => x == 0x01));
        }