示例#1
0
        public void DictionaryEncode_NoKeyValuePairs_Positive()
        {
            Dictionary<BByteString, IBObject> inputValue = new Dictionary<BByteString, IBObject>();
            BDictionary inputDict = new BDictionary() { Value = inputValue };

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

            var transform = new DictionaryTransform(new BObjectTransform());
            transform.Encode(inputDict, outputStream);

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

            Assert.IsTrue(expectedBytes.IsEqualWith(actualBytes), "Bytes returned does not match expected bytes");
        }
示例#2
0
        public void DictionaryEncode_NullOutputStream_Exception()
        {
            Dictionary<BByteString, IBObject> inputValue = new Dictionary<BByteString, IBObject>();
            BDictionary inputDict = new BDictionary() { Value = inputValue };

            var transform = new DictionaryTransform(new BObjectTransform());
            transform.Encode(inputDict, null);
        }
示例#3
0
        public void DictionaryEncode_SimpleSample_Positive()
        {
            // Prep input
            Dictionary<BByteString, IBObject> inputValue = new Dictionary<BByteString, IBObject>();
            inputValue.Add(new BByteString("spam"), new BInteger(4));
            inputValue.Add(new BByteString("ham"), new BByteString("ok"));
            BDictionary inputDict = new BDictionary() { Value = inputValue };

            var expectedBytes = "d3:ham2:ok4:spami4ee".GetASCIIBytes();
            var outputStream = new MemoryStream();

            var transform = new DictionaryTransform(new BObjectTransform());
            transform.Encode(inputDict, outputStream);

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

            Assert.IsTrue(expectedBytes.IsEqualWith(actualBytes), "Bytes returned does not match expected bytes");
        }
示例#4
0
        public void DictionaryEncode_NullInputDict_Exception()
        {
            var outputStream = new MemoryStream();

            var transform = new DictionaryTransform(new BObjectTransform());
            transform.Encode(null, outputStream);
        }