public void RetrieveAllDatabaseNodesTest()
        {
            Library lib = new Library();
            DatabaseInfo dbInfo = new DatabaseInfo();
            dbInfo.Host = "localhost";
            dbInfo.User = "******";
            dbInfo.Password = "******";
            dbInfo.DatabaseName = "TestDatabase";
            dbInfo.StartTimeHour = 4;
            dbInfo.StartTimeMinute = 30;

            lib.InsertDatabaseNode(dbInfo);
            dbInfo.DatabaseName = "NewDatabase";
            lib.InsertDatabaseNode(dbInfo);

            Assert.AreEqual(2, lib.RetrieveAllDatabaseNodes().Count);

            lib.RemoveDatabaseNode(dbInfo.DatabaseName);
            lib.RemoveDatabaseNode("TestDatabase");
            lib = null;
        }
        public void RetrieveSpecificDatabaseNodeTest()
        {
            Library lib = new Library();
            DatabaseInfo dbInfo = new DatabaseInfo();
            dbInfo.Host = "localhost";
            dbInfo.User = "******";
            dbInfo.Password = "******";
            dbInfo.DatabaseName = "TestDatabase";
            dbInfo.StartTimeHour = 4;
            dbInfo.StartTimeMinute = 30;

            lib.InsertDatabaseNode(dbInfo);

            DatabaseInfo dbInfo2 = lib.RetrieveDatabaseNode(dbInfo.DatabaseName);

            Assert.AreEqual("testdatabase", dbInfo2.DatabaseName);

            lib.RemoveDatabaseNode(dbInfo2.DatabaseName);
            lib = null;
        }
        public void UpdateSpecificDatabaseNodeTest()
        {
            Library lib = new Library();
            DatabaseInfo dbInfo = new DatabaseInfo();
            dbInfo.Host = "localhost";
            dbInfo.User = "******";
            dbInfo.Password = "******";
            dbInfo.DatabaseName = "TestDatabase";
            dbInfo.StartTimeHour = 4;
            dbInfo.StartTimeMinute = 30;

            lib.InsertDatabaseNode(dbInfo);

            //modify the dbInfo start time
            dbInfo.StartTimeHour = 22;
            dbInfo.StartTimeMinute = 59;

            lib.UpdateDatabaseNode(dbInfo);

            Assert.AreEqual("22:59:00", dbInfo.StartTime.ToString());

            lib.RemoveDatabaseNode(dbInfo.DatabaseName);
        }
        public void RemoveSpecificDatabaseNodeTest()
        {
            Library lib = new Library();
            DatabaseInfo dbInfo = new DatabaseInfo();
            dbInfo.Host = "localhost";
            dbInfo.User = "******";
            dbInfo.Password = "******";
            dbInfo.DatabaseName = "TestDatabase";
            dbInfo.StartTimeHour = 4;
            dbInfo.StartTimeMinute = 30;

            lib.InsertDatabaseNode(dbInfo);
            lib.RemoveDatabaseNode(dbInfo.DatabaseName);

            XmlDocument document = new XmlDocument();
            document.Load(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\MySQLBackup\Configuration\Databases.xml");
            XmlNode databaseNode = document.SelectSingleNode("Databases/Database[@Name='" + dbInfo.DatabaseName + "']");

            Assert.IsNull(databaseNode);
            lib = null;
        }