Example #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);
     }
 }