Example #1
0
 public BObjectTransform()
 {
     integerTransform = new IntegerTransform();
     byteStringTransform = new ByteStringTransform();
     listTransform = new ListTransform(this);
     dictionaryTransform = new DictionaryTransform(this);
 }
        private void EncodeIntegerTest(BInteger input)
        {
            string expected = string.Format("i{0}e", input.Value);

            MemoryStream outputBuffer = new MemoryStream();

            var transform = new IntegerTransform();
            transform.Encode(input, outputBuffer);

            outputBuffer.Position = 0;
            StreamReader sr = new StreamReader(outputBuffer);
            string actual = sr.ReadToEnd();

            Assert.AreEqual<string>(expected, actual);
        }
        private void DecodeIntegerTest(long originalNumber, string inputAsStr)
        {
            MemoryStream inputBuffer = new MemoryStream(Encoding.ASCII.GetBytes(inputAsStr));
            inputBuffer.Position = 0;

            var transform = new IntegerTransform();
            var integer = transform.Decode(inputBuffer);

            Assert.IsTrue(integer.Value.GetType() == typeof(long), "value type should be long");
            Assert.AreEqual<long>(originalNumber, integer.Value);
            Assert.AreEqual<BObjectType>(BObjectType.Integer, integer.BType);
        }