public void ReadDoesNotAllowElementsNotCalledValueOnAList() { var serialiser = new NameValuePairSerialiser(null, null, true); var document = new XmlDocument(); document.LoadXml("<list><good name=\"name1\">the value of 1</good><bad name=\"name2\">the value of 2</bad></list>"); Assert.Throws <NetReflectorException>(() => { serialiser.Read(document.DocumentElement, null); }); }
public void ReadDoesNotAllowAttributesOnAList() { var serialiser = new NameValuePairSerialiser(null, null, true); var document = new XmlDocument(); document.LoadXml("<list error=\"true\"><value name=\"name1\">the value of 1</value><value name=\"name2\">the value of 2</value></list>"); Assert.Throws <NetReflectorException>(() => { serialiser.Read(document.DocumentElement, null); }); }
public void ReadDoesNotAllowChildNodesForASingleNode() { var serialiser = new NameValuePairSerialiser(null, null, false); var document = new XmlDocument(); document.LoadXml("<value name=\"a name\"><child/></value>"); Assert.Throws <NetReflectorException>(() => { serialiser.Read(document.DocumentElement, null); }); }
public void ReadLoadsASingleInstance() { var serialiser = new NameValuePairSerialiser(null, null, false); var document = new XmlDocument(); document.LoadXml("<value name=\"a name\">the value</value>"); var value = serialiser.Read(document.DocumentElement, null); Assert.IsInstanceOf <NameValuePair>(value); var actualValue = value as NameValuePair; Assert.AreEqual("a name", actualValue.Name); Assert.AreEqual("the value", actualValue.Value); }
public void ReadLoadsAList() { var serialiser = new NameValuePairSerialiser(null, null, true); var document = new XmlDocument(); document.LoadXml("<list><value name=\"name1\">the value of 1</value><value name=\"name2\">the value of 2</value></list>"); var value = serialiser.Read(document.DocumentElement, null); Assert.IsInstanceOf <NameValuePair[]>(value); var actualList = value as NameValuePair[]; Assert.AreEqual(2, actualList.Length); Assert.AreEqual("name1", actualList[0].Name); Assert.AreEqual("the value of 1", actualList[0].Value); Assert.AreEqual("name2", actualList[1].Name); Assert.AreEqual("the value of 2", actualList[1].Value); }