예제 #1
0
        public void ListEncode_PopulatedList_Positive()
        {
            BList inputList = new BList()
            {
                Value = new IBObject[]
                {
                    new BInteger(9L), new BByteString() { Value = "spam".GetASCIIBytes() }
                }
            };

            var expectedBytes = "li9e4:spame".GetASCIIBytes();
            var outputStream = new MemoryStream();

            var transform = new ListTransform(new BObjectTransform());

            transform.Encode(inputList, outputStream);

            outputStream.Position = 0;
            var actualBytes = outputStream.ToArray();

            Assert.IsTrue(expectedBytes.IsEqualWith(actualBytes), "Bytes returned does not match expected bytes");
        }
예제 #2
0
        public void ListEncode_NullListParam_Exception()
        {
            var outputStream = new MemoryStream();
            var transform = new ListTransform(new BObjectTransform());

            transform.Encode(null, outputStream);
        }
예제 #3
0
        public void ListEncode_NullOutputStream_Exception()
        {
            BList inputList = new BList() { Value = new IBObject[] { } };
            var transform = new ListTransform(new BObjectTransform());

            transform.Encode(inputList, null);
        }
예제 #4
0
        public void ListEncode_NestedList_Positive()
        {
            // A list with an empty list as it's only item:
            BList inputList = new BList()
            {
                Value = new IBObject[]
                {
                    new BList()
                    {
                        Value = new IBObject[] { }
                    }
                }
            };

            var expectedBytes = "llee".GetASCIIBytes();
            var outputStream = new MemoryStream();

            var transform = new ListTransform(new BObjectTransform());

            transform.Encode(inputList, outputStream);

            outputStream.Position = 0;
            var actualBytes = outputStream.ToArray();

            Assert.IsTrue(expectedBytes.IsEqualWith(actualBytes), "Bytes returned does not match expected bytes");
        }