public void TestReadMe() { var xml = File.ReadAllText(@"ReadMe.xml"); var cfg = new TestClasses.Cfg(xml, new NanoXmlParser()); //TEST FOR PROBLEMS Assert.AreEqual(0, cfg.Errors().Length); //TEST GANDALF Assert.AreEqual("Gandalf", cfg.Servers[0].Name); Assert.AreEqual(1, cfg.Servers[0].Databases.Count); Assert.AreEqual("master", cfg.Servers[0].Databases[0].Name); Assert.AreEqual(@"\\san\sql-backups", cfg.Servers[0].Databases[0].BackupFolder); Assert.AreEqual(6, cfg.Servers[0].Databases[0].BackupsToKeep); //TEST SARUMAN Assert.AreEqual("Saruman", cfg.Servers[1].Name); Assert.AreEqual(2, cfg.Servers[1].Databases.Count); Assert.AreEqual("master", cfg.Servers[1].Databases[0].Name); Assert.AreEqual(@"\\san\sql-backups\saruman\master", cfg.Servers[1].Databases[0].BackupFolder); Assert.AreEqual(8, cfg.Servers[1].Databases[0].BackupsToKeep); Assert.AreEqual("model", cfg.Servers[1].Databases[1].Name); Assert.AreEqual(@"\\san\sql-backups\saruman\model", cfg.Servers[1].Databases[1].BackupFolder); Assert.AreEqual(4, cfg.Servers[1].Databases[1].BackupsToKeep); }
public void TestReadMe() { var json = File.ReadAllText(@"ReadMe.json"); var cfg = new TestClasses.Cfg(json, null); foreach (var problem in cfg.Errors()) { Console.WriteLine(problem); } //TEST FOR PROBLEMS Assert.AreEqual(0, cfg.Errors().Length); Assert.AreEqual(2, cfg.Servers.Count); //TEST GANDALF Assert.AreEqual("Gandalf", cfg.Servers[0].Name); Assert.AreEqual(1, cfg.Servers[0].Databases.Count); Assert.AreEqual("master", cfg.Servers[0].Databases[0].Name); Assert.AreEqual(@"\\san\sql-backups", cfg.Servers[0].Databases[0].BackupFolder); Assert.AreEqual(6, cfg.Servers[0].Databases[0].BackupsToKeep); //TEST SARUMAN Assert.AreEqual("Saruman", cfg.Servers[1].Name); Assert.AreEqual(2, cfg.Servers[1].Databases.Count); Assert.AreEqual("master", cfg.Servers[1].Databases[0].Name); Assert.AreEqual(@"\\san\sql-backups\saruman\master", cfg.Servers[1].Databases[0].BackupFolder); Assert.AreEqual(8, cfg.Servers[1].Databases[0].BackupsToKeep); Assert.AreEqual("model", cfg.Servers[1].Databases[1].Name); Assert.AreEqual(@"\\san\sql-backups\saruman\model", cfg.Servers[1].Databases[1].BackupFolder); Assert.AreEqual(4, cfg.Servers[1].Databases[1].BackupsToKeep); }
public void TestReadMe2() { var xml = File.ReadAllText(@"ReadMe2.xml"); var cfg = new TestClasses.Cfg(xml, null); foreach (var problem in cfg.Errors()) { Console.WriteLine(problem); } //TEST FOR PROBLEMS Assert.AreEqual(0, cfg.Errors().Length); //TEST SAM Assert.AreEqual("Sam", cfg.Servers[0].Name); Assert.AreEqual(2, cfg.Servers[0].Databases.Count); Assert.AreEqual("master", cfg.Servers[0].Databases[0].Name); Assert.AreEqual("msdb", cfg.Servers[0].Databases[1].Name); Assert.AreEqual(@"\\san\sql-backups", cfg.Servers[0].Databases[0].BackupFolder); Assert.AreEqual(5, cfg.Servers[0].Databases[0].BackupsToKeep); //TEST VINNY Assert.AreEqual("Vinny", cfg.Servers[1].Name); Assert.AreEqual(2, cfg.Servers[1].Databases.Count); Assert.AreEqual("master", cfg.Servers[1].Databases[0].Name); Assert.AreEqual(@"\\san\sql-backups\vinny\master", cfg.Servers[1].Databases[0].BackupFolder); Assert.AreEqual(3, cfg.Servers[1].Databases[0].BackupsToKeep); Assert.AreEqual("model", cfg.Servers[1].Databases[1].Name); Assert.AreEqual(@"\\san\sql-backups\vinny\model", cfg.Servers[1].Databases[1].BackupFolder); Assert.AreEqual(4, cfg.Servers[1].Databases[1].BackupsToKeep); const string expected = @"<Cfg> <servers> <add name=""Sam""> <databases> <add name=""master"" backupstokeep=""5"" /> <add name=""msdb"" backupstokeep=""2"" /> </databases> </add> <add name=""Vinny""> <databases> <add name=""master"" backupfolder=""\\san\sql-backups\vinny\master"" backupstokeep=""3"" /> <add name=""model"" backupfolder=""\\san\sql-backups\vinny\model"" /> </databases> </add> </servers> </Cfg>"; var actual = cfg.Serialize(); Assert.AreEqual(expected.Replace("\r\n", "\n"), actual.Replace("\r\n", "\n")); }
public void TestReadMe2() { var xml = File.ReadAllText(@"ReadMe2.xml"); var cfg = new TestClasses.Cfg(xml, null); foreach (var problem in cfg.Errors()) { Console.WriteLine(problem); } //TEST FOR PROBLEMS Assert.AreEqual(0, cfg.Errors().Length); //TEST SAM Assert.AreEqual("Sam", cfg.Servers[0].Name); Assert.AreEqual(2, cfg.Servers[0].Databases.Count); Assert.AreEqual("master", cfg.Servers[0].Databases[0].Name); Assert.AreEqual("msdb", cfg.Servers[0].Databases[1].Name); Assert.AreEqual(@"\\san\sql-backups", cfg.Servers[0].Databases[0].BackupFolder); Assert.AreEqual(5, cfg.Servers[0].Databases[0].BackupsToKeep); //TEST VINNY Assert.AreEqual("Vinny", cfg.Servers[1].Name); Assert.AreEqual(2, cfg.Servers[1].Databases.Count); Assert.AreEqual("master", cfg.Servers[1].Databases[0].Name); Assert.AreEqual(@"\\san\sql-backups\vinny\master", cfg.Servers[1].Databases[0].BackupFolder); Assert.AreEqual(3, cfg.Servers[1].Databases[0].BackupsToKeep); Assert.AreEqual("model", cfg.Servers[1].Databases[1].Name); Assert.AreEqual(@"\\san\sql-backups\vinny\model", cfg.Servers[1].Databases[1].BackupFolder); Assert.AreEqual(4, cfg.Servers[1].Databases[1].BackupsToKeep); const string expected = @"<Cfg> <servers> <add name=""Sam""> <databases> <add name=""master"" backupstokeep=""5"" /> <add name=""msdb"" backupstokeep=""2"" /> </databases> </add> <add name=""Vinny""> <databases> <add name=""master"" backupfolder=""\\san\sql-backups\vinny\master"" backupstokeep=""3"" /> <add name=""model"" backupfolder=""\\san\sql-backups\vinny\model"" /> </databases> </add> </servers> </Cfg>"; var actual = cfg.Serialize(); Assert.AreEqual(expected, actual); }