public void Read1() { XmlInput xmlinput = new XmlInput(TestUtil.GetTestFile("xmlinput.xml")); xmlinput.CheckElement("rootsym"); try { xmlinput.CheckElement("fiddle"); Assert.Fail("expect exception"); } catch (Exception e) { Assert.IsTrue(e is XmlFileFormatException); } xmlinput.Read(); xmlinput.CheckElement("fiddle"); Assert.AreEqual(1, xmlinput.GetAttributeInt("y")); Assert.AreEqual(false, xmlinput.GetAttributeBool("z")); Assert.AreEqual("foo", xmlinput.GetAttributeString("x")); xmlinput.Skip(); xmlinput.CheckElement("faddle"); Assert.AreEqual(3.4F, xmlinput.GetAttributeFloat("x")); try { Assert.AreEqual("", xmlinput.GetAttributeString("q")); Assert.Fail("should throw"); } catch (Exception e) { Assert.IsTrue(e is XmlFileFormatException); } int i = 0; bool first = true; while (xmlinput.FindSubElement(first, "hello", "zung", "zang", "zing")) { ++i; first = false; switch (xmlinput.Name) { case "zing": Assert.AreEqual(5, xmlinput.GetAttributeInt("why", 5)); Assert.AreEqual(true, xmlinput.GetAttributeBool("why", true)); Assert.AreEqual(5.7F, xmlinput.GetAttributeFloat("why", 5.7F)); Assert.AreEqual("Whazzzle", xmlinput.GetAttributeString("why", "Whazzzle")); Assert.AreEqual("This is the zing", xmlinput.GetContentString()); break; case "zang": Assert.AreEqual(true, xmlinput.GetAttributeBool("r")); try { Assert.AreEqual(true, xmlinput.GetAttributeBool("z")); Assert.Fail("should throw"); } catch (Exception) { } xmlinput.Skip(); break; case "zung": xmlinput.Read(); xmlinput.CheckElement("diddle"); xmlinput.Skip(); xmlinput.Skip(); break; default: Assert.Fail("shouldn't get here"); break; } } Assert.AreEqual(4, i); }