Esempio n. 1
0
        public void AddRemoveTest()
        {
            // init database connection
            ConnectionManager.Connect();
            Computers computersInterface = new Computers();

            // add localhost/127.0.0.1 to db
            computersInterface.Insert("dummy", "127.0.0.1", "", "");

            // check the db to see if it's there
            bool      found = false;
            DataTable all   = computersInterface.SelectAll();

            Assert.AreNotEqual(0, all.Rows.Count);
            foreach (DataRow row in all.Rows)
            {
                if (row["Hostname"].ToString().Equals("dummy"))
                {
                    found = true;
                }
            }

            Assert.IsTrue(found);

            // delete it from the db
            computersInterface.Delete("dummy", "127.0.0.1");

            // check the db to see if it's there (it shouldn't be)
            found = false;
            all   = computersInterface.SelectAll();
            foreach (DataRow row in all.Rows)
            {
                if (row["Hostname"].ToString().Equals("dummy"))
                {
                    found = true;
                }
            }

            Assert.IsFalse(found);
        }