Ejemplo n.º 1
0
        public void TestRoundtrip(object obj, Type expectType)
        {
            var encoded1  = ETFCodec.Encode(obj);
            var encoded2  = ETFCodec.Encode(obj);
            var reencoded = ETFCodec.Decode(encoded1);

            Assert.That(reencoded, Is.EqualTo(obj));

            // verify that decoding doesn't alter the encoded buffer
            Assert.That(encoded1, Is.EqualTo(encoded2));

            // verify that types remain what we expect
            if (expectType != null)
            {
                Assert.That(reencoded, Is.InstanceOf(expectType));
            }
        }
Ejemplo n.º 2
0
 public void TestEmptyList()
 {
     Assert.That(ETFCodec.Encode(new ArrayList()), Is.EqualTo(new byte[] { Constants.FORMAT_VERSION, Constants.NIL_EXT }));
 }
Ejemplo n.º 3
0
 public void TestBool()
 {
     Assert.Throws <NotSupportedException>(() => { ETFCodec.Encode(true); });
     Assert.Throws <NotSupportedException>(() => { ETFCodec.Encode(false); });
 }
Ejemplo n.º 4
0
 public void TestNull()
 {
     Assert.Throws <NotSupportedException>(() => { ETFCodec.Encode(null); });
 }
Ejemplo n.º 5
0
 object Roundtrip(object obj)
 {
     return(ETFCodec.Decode(ETFCodec.Encode(obj)));
 }