public void GetIntValue_3_Doc() { //Arrange XmlDocument Menu = new XmlDocument(); Menu.LoadXml("<breakfast_menu>" + "<food1>" + "<name>Belgian Waffles</name>" + "<rating>7</rating>" + "</food1>" + "<food2>" + "<name>Strawberry Belgian Waffles</name>" + "<rating>8</rating>" + "</food2>" + "<food3>" + "<name>Homestyle Breakfast</name>" + "<rating>1</rating>" + "</food3>" + "<food4>" + "<name>French Toast</name>" + "<rating>10</rating>" + "</food4>" + "</breakfast_menu>"); string xPath = ("/breakfast_menu/food2/rating"); //Act int returnModel = XMLNodeHelper.GetIntValue(Menu, xPath); //Assert returnModel.Should().Be(8); }
public void GetIntValue_1_Node() { //Arrange XmlDocument Menu = new XmlDocument(); Menu.LoadXml("<breakfast_menu>" + "<food>" + "<name1>Belgian Waffles</name1>" + "<rating>7</rating>" + "</food>" + "<food>" + "<name>Strawberry Belgian Waffles</name>" + "<rating>8</rating>" + "</food>" + "<food>" + "<name>Homestyle Breakfast</name>" + "<rating>1</rating>" + "</food>" + "<food>" + "<name>French Toast</name>" + "<rating>10</rating>" + "</food>" + "</breakfast_menu>"); XmlNode node = Menu.FirstChild; XmlNode node2 = node.FirstChild; string xPath = ("/breakfast_menu/food/rating"); //Act int returnModel = XMLNodeHelper.GetIntValue(node2, xPath); //Assert returnModel.Should().Be(7); }