public void HowToUseLibraryExample_CreateCompleteXmlFile_FileAreEqualToStub()
        {
            XPathComposer composer = new XPathComposer();
            string xmlPath = TestContext.DeploymentDirectory + "\\temp\\" + "test.xml";

            IList<KeyValuePair<string, string>> nodeList = new List<KeyValuePair<string, string>>();

            //create parent nodes
            CD cd1 = new CD("LifeForms", "Future Sound Of London", "1995");
            CD cd2 = new CD("Insides - LP", "Orbital", "1996");

            //create xml file, adding a parent node,an attribute and a list of child nodes
            composer.CreateXmlFile(xmlPath, "root").AddParentNode("cd").AddAttribute("id", "bestprice").AddNodeList<string, string>(cd1.GetList());

            //add attribute to a child node
            composer.RootNode("root").Select("cd").Where("id").Equals("bestprice").Select("artist").AddAttribute("country", "uk");

            //creatre other parent node adding an attribute and a list of child nodes
            composer.RootNode("root").AddParentNode("cd").AddAttribute("id", "limited ed").AddNodeList<string, string>(cd2.GetList());

            //add attribute to a child node
            composer.RootNode("root").Select("cd").Where("id").Equals("limited ed").Select("artist").AddAttribute("country", "uk");

            string fileContent = Regex.Replace(string.Join("", File.ReadAllText(xmlPath)), @"[\n\t] + ", "").Trim();

            Assert.AreEqual(stubXmlFile, fileContent);
        }
        public void CreateFile_AddElementList_ElementsHaveBeenAdded()
        {
            XPathComposer composer = new XPathComposer();
            string xmlPath = TestContext.DeploymentDirectory + "\\temp\\" + "test.xml";

            IList<KeyValuePair<string, string>> nodeList = new List<KeyValuePair<string, string>>();

            KeyValuePair<string, string> node1 = new KeyValuePair<string, string>("title", "LifeForms");
            KeyValuePair<string, string> node2 = new KeyValuePair<string, string>("artist", "Future Sound Of London");
            KeyValuePair<string, string> node3 = new KeyValuePair<string, string>("tear", "1995");
            nodeList.Add(node1);
            nodeList.Add(node2);
            nodeList.Add(node3);

            composer.CreateXmlFile(xmlPath, "root").AddNodeList<string, string>(nodeList);

            File.Exists(xmlPath);

            nodeList = composer.RootNode("root").SelectAllChildNodes().GetList<string, string>();

            Assert.IsTrue(nodeList.Count != 0);

            Assert.AreEqual("LifeForms", nodeList[0].Value);
            Assert.AreEqual("Future Sound Of London", nodeList[1].Value);
            Assert.AreEqual("1995", nodeList[2].Value);
        }
        public void CreateFile_FileHasBeenCreated()
        {
            XPathComposer composer = new XPathComposer();
            string xmlPath = TestContext.DeploymentDirectory + "\\temp\\" + "test.xml";

            composer.CreateXmlFile(xmlPath, "root");

            File.Exists(xmlPath);
        }
        public void CreateFile_AddAttributeToNode_NodeHasBeenFoundByAttribute()
        {
            XPathComposer composer = new XPathComposer();
            string xmlPath = TestContext.DeploymentDirectory + "\\temp\\" + "test.xml";

            IList<KeyValuePair<string, string>> nodeList = new List<KeyValuePair<string, string>>();

            KeyValuePair<string, string> node1 = new KeyValuePair<string, string>("title", "LifeForms");
            KeyValuePair<string, string> node2 = new KeyValuePair<string, string>("artist", "Future Sound Of London");
            KeyValuePair<string, string> node3 = new KeyValuePair<string, string>("year", "1995");
            nodeList.Add(node1);
            nodeList.Add(node2);
            nodeList.Add(node3);

            composer.CreateXmlFile(xmlPath, "root").AddNodeList<string, string>(nodeList);

            composer.FileName(xmlPath).RootNode("root").AddAttribute("id", "bestprice");

            File.Exists(xmlPath);

            string title = composer.RootNode("root").Where("id").Equals("bestprice").GetValueOf<string>("title");

            Assert.AreEqual("LifeForms", title);
        }