Exemplo n.º 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);
        }
Exemplo n.º 2
0
        public void TestUserToGebruikerAdapter()
        {
            IDatabase     db      = new MySQLDatabase();
            UserToPortaal adapter = new UserToPortaal(db);
            Gebruiker     g       = new Gebruiker()
            {
                GebruikersCode = 1, VoorNaam = "John", Achternaam = "Doe"
            };

            adapter.VoegToe(g);
            db.OpenConnection();
            User test = db.SelectAllUsers().First(s => s.ID == 1);

            Assert.AreEqual("John", test.FirstName);
            Assert.AreEqual("Doe", test.LastName);
            db.CloseConnection();

            g.VoorNaam = "Jane";
            adapter.PasAan(g);
            db.OpenConnection();
            test = db.SelectAllUsers().First(s => s.ID == 1);
            Assert.AreEqual("Jane", test.FirstName);
            db.CloseConnection();

            adapter.Verwijder(g);
            db.OpenConnection();
            test = db.SelectAllUsers().FirstOrDefault(s => s.ID == 1);
            Assert.IsNull(test);
            db.CloseConnection();
        }