public static void SlamStackDeserializeError() { var head = BuildStackSlammer(XmlReadBuffer.s_maxDepth); var serialized = XmlWriteBuffer.SerializeStatic(head); Assert.Throws <Exception>(() => XmlReadBuffer.ReadStatic <StackSlam>(serialized)); }
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); }
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)); }
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); }
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); }
public string ReadBuffer() { var parsed = XmlReadBuffer.ReadStatic <StructuredClass>(s_strToDecode); return(parsed.m_attribute); }
public static void TestAbortCrash() { var str = "<abort><crashIfPresent>yep</crashIfPresent></abort>"; Assert.Throws <TestCrashException>(() => XmlReadBuffer.ReadStatic <AbortClass>(str)); // should crash }
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 }
public static void SlamStackDeserialize() { var head = BuildStackSlammer(XmlReadBuffer.s_maxDepth - 1); var serialized = XmlWriteBuffer.SerializeStatic(head); var deserialized = XmlReadBuffer.ReadStatic <StackSlam>(serialized); }
public static void HandleUnknownAttributes() { const string input = "<attrs newAttr='anything'/>"; XmlReadBuffer.ReadStatic <WithAttributes>(input); // ...nothing happens }