Пример #1
0
        public void TestUserDatabase()
        {
            IDatabase db = new MySQLDatabase();

            db.OpenConnection();
            Assert.IsTrue(db.IsConnected);

            User u = new User()
            {
                ID = 1, FirstName = "John", LastName = "Doe"
            };

            db.InsertUser(u);
            Assert.IsTrue(db.SelectAllUsers().Contains(u));

            u.FirstName = "Jane";
            db.UpdateUser(u);
            User test = db.SelectAllUsers().First(s => s.ID == 1);

            Assert.AreEqual("Jane", test.FirstName);

            db.DeleteUser(u);
            Assert.IsFalse(db.SelectAllUsers().Contains(u));

            db.CloseConnection();
            Assert.IsFalse(db.IsConnected);
        }