Пример #1
0
 public void WriteFileCompareAllOk()
 {
     FileInfo[] files = GetTestDataDir(TestDataDir.Files_Ok).GetFiles("*.sfs");
     foreach (FileInfo file in files)
     {
         List <KmlItem> roots = KmlItem.ParseFile(file.FullName);
         string         temp  = Path.GetTempFileName();
         // GetTempFileName creates the file to protect that temp file name
         // but we dont want dest file to be existing, this would cause creating
         // backup files in temp dir, we then won't clean up
         File.Delete(temp);
         KmlItem.WriteFile(temp, roots);
         string resultname = file.Name;
         if (!File.Exists(temp))
         {
             resultname += " NOT WRITTEN TO " + temp + "!";
         }
         else
         {
             // Compare source and dest files
             string read    = File.ReadAllText(file.FullName);
             string written = File.ReadAllText(temp);
             if (!read.Equals(written))
             {
                 resultname += " NOT WRITTEN IDENTICALLY!";
             }
         }
         File.Delete(temp);
         Assert.AreEqual(file.Name, resultname);
     }
 }
Пример #2
0
        public void ParseFileAttribAboveRoot()
        {
            string         path     = GetTestDataDir(TestDataDir.Files_Ok).FullName;
            string         filename = Path.Combine(path, "SimpleAttribAboveRoot.sfs");
            List <KmlItem> roots    = KmlItem.ParseFile(filename);

            Assert.AreEqual(2, roots.Count);
            Assert.IsTrue(roots[0] is KmlAttrib);
            Assert.IsTrue(roots[1] is KmlNode);
        }
Пример #3
0
        public void ParseFileUnknownLine()
        {
            string         path     = GetTestDataDir(TestDataDir.Files_Warning).FullName;
            string         filename = Path.Combine(path, "SimpleUnknownLine.sfs");
            List <KmlItem> roots    = KmlItem.ParseFile(filename);

            Assert.AreEqual(1, roots.Count);
            Assert.IsTrue(roots[0] is KmlNode);
            KmlNode root = (KmlNode)roots[0];

            Assert.AreEqual(0, root.Attribs.Count);
            Assert.AreEqual(0, root.Children.Count);
            Assert.AreEqual(1, root.Unknown.Count);
            Assert.AreEqual(1, root.AllItems.Count);
        }
Пример #4
0
 public void ParseFileAllWarning()
 {
     FileInfo[] files = GetTestDataDir(TestDataDir.Files_Warning).GetFiles("*.sfs");
     foreach (FileInfo file in files)
     {
         Syntax.Messages.Clear();
         List <KmlItem> roots      = KmlItem.ParseFile(file.FullName);
         string         resultname = file.Name;
         if (roots.Count == 0)
         {
             resultname += " EMPTY!";
         }
         if (Syntax.Messages.Count == 0)
         {
             resultname += " NO EXPECTED WARNINGS!";
         }
         Assert.AreEqual(file.Name, resultname);
     }
 }