Ejemplo n.º 1
0
        public void TestBytes()
        {
            byte[] bytes = { 97, 98, 99, 100, 101, 102 };               // abcdef
            var    dict  = new Dictionary <string, string> {
                { "data", "YWJjZGVm" }, { "encoding", "base64" }
            };

            var bytes2 = SerpentSerializer.ToBytes(dict);

            Assert.Equal(bytes, bytes2);

            var hashtable = new Hashtable {
                { "data", "YWJjZGVm" }, { "encoding", "base64" }
            };

            bytes2 = SerpentSerializer.ToBytes(hashtable);
            Assert.Equal(bytes, bytes2);

            try {
                SerpentSerializer.ToBytes(12345);
                Assert.True(false, "error expected");
            } catch (ArgumentException) {
                //
            }
        }
Ejemplo n.º 2
0
        public void TestBytes()
        {
            byte[] bytes = new byte[] { 97, 98, 99, 100, 101, 102 };                    // abcdef
            var    dict  = new Dictionary <string, string>();

            dict.Add("data", "YWJjZGVm");
            dict.Add("encoding", "base64");

            byte[] bytes2 = SerpentSerializer.ToBytes(dict);
            Assert.AreEqual(bytes, bytes2);

            var hashtable = new Hashtable();

            hashtable.Add("data", "YWJjZGVm");
            hashtable.Add("encoding", "base64");

            bytes2 = SerpentSerializer.ToBytes(hashtable);
            Assert.AreEqual(bytes, bytes2);

            try {
                SerpentSerializer.ToBytes(12345);
                Assert.Fail("error expected");
            } catch (ArgumentException) {
                //
            }
        }
Ejemplo n.º 3
0
        public void TestSerpentBytes()
        {
            byte[]            bytes = Encoding.ASCII.GetBytes("hello");
            SerpentSerializer ser   = new SerpentSerializer();

            byte[] data = ser.serializeData(bytes);

            string str = Encoding.ASCII.GetString(data);

            Assert.IsTrue(str.Contains("base64"));

            Razorvine.Serpent.Parser p = new Razorvine.Serpent.Parser();
            Object data2 = p.Parse(data).GetData();

            byte[] bytes2 = SerpentSerializer.ToBytes(data2);
            Assert.AreEqual(Encoding.ASCII.GetBytes("hello"), bytes2);
        }
Ejemplo n.º 4
0
        public void TestSerpentBytes()
        {
            Config.SERPENT_INDENT = false;

            var bytes             = Encoding.ASCII.GetBytes("hello");
            SerpentSerializer ser = new SerpentSerializer();
            var data = ser.serializeData(bytes);

            string str = Encoding.ASCII.GetString(data);

            Assert.Contains("base64", str);

            Parser p      = new Parser();
            object data2  = p.Parse(data).GetData();
            var    bytes2 = SerpentSerializer.ToBytes(data2);

            Assert.Equal(Encoding.ASCII.GetBytes("hello"), bytes2);
        }