Example #1
0
        public static void SlamStackDeserializeError()
        {
            var head       = BuildStackSlammer(XmlReadBuffer.s_maxDepth);
            var serialized = XmlWriteBuffer.SerializeStatic(head);

            Assert.Throws <Exception>(() => XmlReadBuffer.ReadStatic <StackSlam>(serialized));
        }
Example #2
0
        private static void AssertEqualWithAttrs(string serialiezd, WithAttributes truth)
        {
            var deserialized = XmlReadBuffer.ReadStatic <WithAttributes>(serialiezd);

            Assert.Equal(truth.m_int, deserialized.m_int);
            Assert.Equal(truth.m_uint, deserialized.m_uint);
            Assert.Equal(truth.m_double, deserialized.m_double);
            Assert.Equal(truth.m_string, deserialized.m_string);
        }
Example #3
0
        public static void HandleUnknownBodies()
        {
            const string input = "<dave><tim></tim></dave>";

            Assert.Throws <InvalidDataException>(() => XmlReadBuffer.ReadStatic <EmptyClass>(input));
            Assert.Throws <InvalidDataException>(() => XmlReadBuffer.ReadStatic <VeryLongName>(input));
            Assert.Throws <InvalidDataException>(() => XmlReadBuffer.ReadStatic <StackSlam>(input));
            Assert.Throws <InvalidDataException>(() => XmlReadBuffer.ReadStatic <WithAttributes>(input));
            Assert.Throws <InvalidDataException>(() => XmlReadBuffer.ReadStatic <StringBodies>(input));
        }
Example #4
0
        public static void SerializeStringBody(CDataMode cdataMode)
        {
            var truth = new StringBody()
            {
                m_fullBody = "asdjhasjkdhakjsdhjkahsdjhkasdhasd<>&&"
            };
            var result = XmlWriteBuffer.SerializeStatic(truth, cdataMode);

            var deserialized = XmlReadBuffer.ReadStatic <StringBody>(result, cdataMode);

            Assert.Equal(truth.m_fullBody, deserialized.m_fullBody);
        }
Example #5
0
 public override bool ParseSubBody(ref XmlReadBuffer buffer, ulong nameHash, ReadOnlySpan <char> bodySpan, ReadOnlySpan <char> innerBodySpan,
                                   ref int end, ref int endInner)
 {
     if (nameHash == c_abortIfPresentHash)
     {
         buffer.m_abort = true;
         return(false);
     }
     else if (nameHash == c_crashIfPresentHash)
     {
         throw new TestCrashException();
     }
     return(base.ParseSubBody(ref buffer, nameHash, bodySpan, innerBodySpan, ref end, ref endInner));
 }
Example #6
0
        public static void SerializeStringBodies(CDataMode cdataMode)
        {
            var truth = new StringBodies
            {
                m_a     = "blah1<>&&",
                m_b     = "blah2",
                m_null  = null,
                m_empty = string.Empty
            };
            var result = XmlWriteBuffer.SerializeStatic(truth, cdataMode);

            var deserialized = XmlReadBuffer.ReadStatic <StringBodies>(result, cdataMode);

            Assert.Equal(truth.m_a, deserialized.m_a);
            Assert.Equal(truth.m_b, deserialized.m_b);
            //Assert.Equal(truth.m_null, deserialized.m_null); // todo: do we want to avoid writing nulls?? currently empty string
            Assert.Equal(truth.m_empty, deserialized.m_empty);
        }
Example #7
0
        public string ReadBuffer()
        {
            var parsed = XmlReadBuffer.ReadStatic <StructuredClass>(s_strToDecode);

            return(parsed.m_attribute);
        }
Example #8
0
        public static void TestAbortCrash()
        {
            var str = "<abort><crashIfPresent>yep</crashIfPresent></abort>";

            Assert.Throws <TestCrashException>(() => XmlReadBuffer.ReadStatic <AbortClass>(str)); // should crash
        }
Example #9
0
 public static void TestAbortNoCrash()
 {
     var str    = "<abort><abortIfPresent>gonna do this first</abortIfPresent><crashIfPresent>yep</crashIfPresent></abort>";
     var parsed = XmlReadBuffer.ReadStatic <AbortClass>(str); // should succeed
 }
Example #10
0
 public static void SlamStackDeserialize()
 {
     var head         = BuildStackSlammer(XmlReadBuffer.s_maxDepth - 1);
     var serialized   = XmlWriteBuffer.SerializeStatic(head);
     var deserialized = XmlReadBuffer.ReadStatic <StackSlam>(serialized);
 }
Example #11
0
        public static void HandleUnknownAttributes()
        {
            const string input = "<attrs newAttr='anything'/>";

            XmlReadBuffer.ReadStatic <WithAttributes>(input); // ...nothing happens
        }