Пример #1
0
        public void TestCreateDeleteJedis() 
        {
            DalManager manager = new DalManager();
            List<Jedi> list1 = manager.getJedis();
            
            Jedi newJedi = new Jedi(12, "JediTest", true, null);

            manager.InsertJedi(newJedi);
            List<Jedi> listTemp = list1;
            listTemp.Add(newJedi);

            List<Jedi> list2 = manager.getJedis();
            Assert.AreEqual(listTemp.Count, list2.Count);
            Assert.AreEqual(list1[listTemp.Count - 1].ID, list2[list2.Count - 1].ID);
            Assert.AreEqual(list1[listTemp.Count - 1].IsSith, list2[list2.Count - 1].IsSith);
            Assert.AreEqual(list1[listTemp.Count - 1].Nom, list2[list2.Count - 1].Nom);

            manager.DeleteJedis(newJedi);
            list2 = manager.getJedis();
            Assert.AreEqual(list1.Count, list2.Count);
            Assert.AreEqual(list1[list1.Count - 1].ID, list2[list2.Count - 1].ID);
            Assert.AreEqual(list1[list1.Count - 1].IsSith, list2[list2.Count - 1].IsSith);
            Assert.AreEqual(list1[list1.Count - 1].Nom, list2[list2.Count - 1].Nom);

        }
Пример #2
0
        public void getJediTest() {
            DalManager manager = new DalManager();

            List<Jedi> list = manager.getJedis();

            Console.WriteLine(list.Count);
        }
Пример #3
0
        public void getUpdateJedisTest()
        {
            int         taille    = 0;
            int         debTaille = 0;
            List <Jedi> liste     = bdd.getJedis();

            debTaille = liste.Count;
            Assert.AreNotEqual <int>(liste.Count, 0);
            if (liste.Count > 0)
            {
                Jedi j = new Jedi(0, null, true, "Testman", "John.png");
                liste.Add(j);
                bdd.updateJedis(liste);
                taille = liste.Count;
                liste  = bdd.getJedis();
                Assert.AreEqual <int>(taille, liste.Count);
                Assert.AreNotEqual <int>(0, (liste.Where(x => x.Nom == j.Nom)).ToList().Count);
                liste.Remove(liste.Last());
                bdd.updateJedis(liste);
                Assert.AreEqual(debTaille, bdd.getJedis().Count);
            }
        }
Пример #4
0
        public void TestUpdateJedis()
        {
            DalManager manager = new DalManager();
            List<Jedi> list1 = manager.getJedis();

            Jedi updatedJedi = list1[0];
            updatedJedi.IsSith = true;
            updatedJedi.Nom = "JediTest";

            manager.UpdateJedi(updatedJedi); //Modification du premier Jedi

            List<Jedi> list2 = manager.getJedis();
            //Assert.AreEqual(updatedJedi, list2[0]); //Test si le premier Jedi à bien été modifié
            Assert.AreEqual(list1.Count, list2.Count);
            Assert.AreEqual(updatedJedi.ID, list2[0].ID);
            Assert.AreEqual(updatedJedi.IsSith, list2[0].IsSith);
            Assert.AreEqual(updatedJedi.Nom, list2[0].Nom);

            updatedJedi.IsSith = list1[0].IsSith;
            updatedJedi.Nom = list1[0].Nom;

            manager.UpdateJedi(updatedJedi); //Reinitialisation du premier Jedi
            list2 = manager.getJedis();

            //Assert.AreEqual(list1, list2); //Test si le jedi est bien réinitialisé
            Assert.AreEqual(list1.Count, list2.Count);
            Assert.AreEqual(list1[list1.Count - 1].ID, list2[0].ID);
            Assert.AreEqual(list1[list1.Count - 1].IsSith, list2[0].IsSith);
            Assert.AreEqual(list1[list1.Count - 1].Nom, list2[0].Nom);

        }
 public List <Jedi> getJedis()
 {
     return(bdd.getJedis());
 }