using System;
using System.Diagnostics;
using System.IO;
using System.Xml;
namespace TestLTEngine
{
public class TestDomLoadFromFile
{
public static void TestFromFile1()
{
const string testDirectory = "c:\\testdir$";
if( Directory.Exists(testDirectory) )
{
Directory.Delete(testDirectory,true);
}
Directory.CreateDirectory(testDirectory);
try
{
const string filename = @"c:\%AB.xml";
string targetFullPath = Path.Combine(testDirectory,filename);
XmlDocument doc1 = new XmlDocument();
doc1.LoadXml("<a>test</a>");
doc1.Save(targetFullPath);
XmlDocument doc2 = DOMLoad.FromFile(targetFullPath);
Trace.Assert( doc2.OuterXml == "<a>test</a>" );
bool flag1 = false;
XmlDocument doc3 = new XmlDocument();
try
{
// DOMLoad.FromFileではなく、Loadを使うとFileNotFoundExceptionが投げられる
// ということを示しておくためのテスト。2つのメソッドの役割の違いを示す
doc3.Load(targetFullPath);
}
catch( FileNotFoundException )
{
flag1 = true;
}
Trace.Assert( flag1 == true );
}
finally
{
Directory.Delete(testDirectory,true);
}
}
public static void RunSuite()
{
TestFromFile1();
}
}
}