public void TestJson() { var json = @"{ 'connections': [ { 'provider': 'file', 'file': 'good.txt' }, { 'provider': 'file' }, { 'provider': 'folder', 'folder': 'c:\\good' }, { 'provider': 'folder', 'file': 'bad.txt' } ] } ".Replace("'", "\""); var cfg = new CustomProblemCfg(json, new TraceLogger()); var problems = cfg.Errors(); Assert.AreEqual(3, problems.Length); Assert.IsTrue(problems[0] == "file provider needs file attribute."); Assert.IsTrue(problems[1] == "I don't like c:\\good."); Assert.IsTrue(problems[2] == "folder provider needs folder attribute."); }
public void TestXml() { var xml = @" <cfg> <connections> <add provider='file' file='good.txt' /> <add provider='file' /><!-- bad, missing file --> <add provider='folder' folder='c:\good' /> <add provider='folder' file='bad.txt' /><!-- bad, missing folder --> </connections> </cfg> ".Replace("'", "\""); var cfg = new CustomProblemCfg(xml, new TraceLogger()); var problems = cfg.Errors(); Assert.AreEqual(3, problems.Length); Assert.IsTrue(problems[0] == "file provider needs file attribute."); Assert.IsTrue(problems[1] == "I don't like c:\\good."); Assert.IsTrue(problems[2] == "folder provider needs folder attribute."); }
public void TestXml() { var xml = @" <cfg> <connections> <add provider='file' file='good.txt' /> <add provider='file' /><!-- bad, missing file --> <add provider='folder' folder='c:\good' /> <add provider='folder' file='bad.txt' /><!-- bad, missing folder --> </connections> </cfg> ".Replace("'", "\""); var anotherLogger = new MemoryLogger(); var cfg = new CustomProblemCfg(xml, anotherLogger); var problems = cfg.Errors(); Assert.AreEqual(3, problems.Length); Assert.IsTrue(problems[0] == "file provider needs file attribute."); Assert.IsTrue(problems[1] == "I don't like c:\\good."); Assert.IsTrue(problems[2] == "folder provider needs folder attribute."); Assert.AreEqual(3, anotherLogger.Errors().Length); }