Пример #1
0
        public void MatchTest()
        {
            //get
            ServiceJediReference.ServiceJediClient service = new ServiceJediReference.ServiceJediClient();
            BusinessLayer.BusinessManager          bm      = new BusinessLayer.BusinessManager();
            List <MatchWCF> result   = service.getAllMatch();
            List <Match>    original = bm.getMatches();
            List <MatchWCF> expected = new List <MatchWCF>();

            foreach (Match match in original)
            {
                expected.Add(new MatchWCF(match));
            }
            foreach (MatchWCF match in expected)
            {
                Assert.IsTrue(result.Exists(x => (x.Jedi1.Nom == match.Jedi1.Nom && x.Jedi2.Nom == match.Jedi2.Nom)),
                              "Le match " + match.Jedi1.Nom + " contre " + match.Jedi2.Nom + " n'est pas present");
            }

            //add
            List <Jedi>  jedis  = bm.getJedis();
            List <Stade> stades = bm.getStades();
            MatchWCF     m      = new MatchWCF(new Match(0, jedis[0], jedis[1], EPhaseTournoi.DemiFinale, stades[0]));

            service.addMatch(m);
            result = service.getAllMatch();
            m      = result.Find(x => x.Jedi1.Id == jedis[0].Id && x.Jedi2.Id == jedis[1].Id && x.PhaseTournoi == EPhaseTournoi.DemiFinale && x.Stade.Id == stades[0].Id);
            Assert.IsTrue(result.Exists(x => x.Id == m.Id), "Le match " + m.ToString() + " n'est pas present");

            //update
            m.PhaseTournoi = EPhaseTournoi.Finale;
            service.updateMatch(m);
            result = service.getAllMatch();
            Assert.IsTrue(result.Exists(x => x.Id == m.Id && x.PhaseTournoi == EPhaseTournoi.Finale), "Le match " + m.ToString() + " n'a pas ete modife");

            //delete
            service.deleteMatch(m);
            result = service.getAllMatch();
            Assert.IsTrue(!result.Exists(x => x.Id == m.Id), "Le match " + m.ToString() + "existe toujours");
        }
Пример #2
0
        public void JediWCFTest()
        {
            //get
            ServiceJediReference.ServiceJediClient service = new ServiceJediReference.ServiceJediClient();
            BusinessLayer.BusinessManager          bm      = new BusinessLayer.BusinessManager();
            List <JediWCF> result   = service.getAllJedi();
            List <Jedi>    original = bm.getJedis(); //met a jour l'id
            List <JediWCF> expected = new List <JediWCF>();

            foreach (Jedi jedi in original)
            {
                expected.Add(new JediWCF(jedi));
            }
            foreach (JediWCF jedi in expected)
            {
                Assert.IsTrue(result.Exists(x => x.Nom == jedi.Nom), "Le jedi " + jedi.Nom + " n'est pas present");
            }

            //add
            List <Caracteristique> list_carac = bm.getCaracteristique().FindAll(x => x.Id == 1);
            JediWCF j = new JediWCF(new Jedi("TestAjout", false, list_carac));

            service.addJedi(j);
            result = service.getAllJedi();
            Assert.IsTrue(result.Exists(x => x.Nom == j.Nom), "Le jedi " + j.Nom + " n'est pas present");

            //update
            j        = result.Find(x => x.Nom == "TestAjout");
            j.IsSith = true;
            service.updateJedi(j);
            result = service.getAllJedi();
            Assert.IsTrue(result.Exists(x => x.Nom == j.Nom && x.IsSith == true), "Le jedi " + j.Nom + " n'a pas ete modife");

            //delete
            service.deleteJedi(j);
            result = service.getAllJedi();
            Assert.IsTrue(!result.Exists(x => x.Nom == j.Nom), "Le jedi " + j.Nom + "existe toujours");
        }
        public void JediWCFTest()
        {
            //get
            ServiceJediReference.ServiceJediClient service = new ServiceJediReference.ServiceJediClient();
            BusinessLayer.BusinessManager bm = new BusinessLayer.BusinessManager();
            List<JediWCF> result = service.getAllJedi();
            List<Jedi> original = bm.getJedis(); //met a jour l'id
            List<JediWCF> expected = new List<JediWCF>();
            foreach (Jedi jedi in original)
            {
                expected.Add(new JediWCF(jedi));
            }
            foreach (JediWCF jedi in expected)
            {
                Assert.IsTrue(result.Exists(x=> x.Nom == jedi.Nom),"Le jedi " + jedi.Nom + " n'est pas present");
            }

            //add
            List<Caracteristique> list_carac = bm.getCaracteristique().FindAll(x => x.Id == 1);
            JediWCF j = new JediWCF(new Jedi("TestAjout", false, list_carac));
            service.addJedi(j);
            result = service.getAllJedi();
            Assert.IsTrue(result.Exists(x => x.Nom == j.Nom), "Le jedi " + j.Nom + " n'est pas present");

            //update
            j = result.Find(x => x.Nom == "TestAjout");
            j.IsSith = true;
            service.updateJedi(j);
            result = service.getAllJedi();
            Assert.IsTrue(result.Exists(x => x.Nom == j.Nom && x.IsSith == true), "Le jedi " + j.Nom + " n'a pas ete modife");

            //delete
            service.deleteJedi(j);
            result = service.getAllJedi();
            Assert.IsTrue(!result.Exists(x => x.Nom == j.Nom), "Le jedi " + j.Nom + "existe toujours");
        }
        public void MatchTest()
        {
            //get
            ServiceJediReference.ServiceJediClient service = new ServiceJediReference.ServiceJediClient();
            BusinessLayer.BusinessManager bm = new BusinessLayer.BusinessManager();
            List<MatchWCF> result = service.getAllMatch();
            List<Match> original = bm.getMatches();
            List<MatchWCF> expected = new List<MatchWCF>();
            foreach (Match match in original)
            {
                expected.Add(new MatchWCF(match));
            }
            foreach (MatchWCF match in expected)
            {
                Assert.IsTrue(result.Exists(x=> (x.Jedi1.Nom == match.Jedi1.Nom && x.Jedi2.Nom == match.Jedi2.Nom)),
                    "Le match " + match.Jedi1.Nom + " contre " + match.Jedi2.Nom + " n'est pas present");
            }

            //add
            List<Jedi> jedis = bm.getJedis();
            List<Stade> stades = bm.getStades();
            MatchWCF m = new MatchWCF(new Match(0, jedis[0], jedis[1], EPhaseTournoi.DemiFinale, stades[0]));
            service.addMatch(m);
            result = service.getAllMatch();
            m = result.Find(x => x.Jedi1.Id == jedis[0].Id && x.Jedi2.Id == jedis[1].Id && x.PhaseTournoi == EPhaseTournoi.DemiFinale && x.Stade.Id == stades[0].Id);
            Assert.IsTrue(result.Exists(x => x.Id == m.Id), "Le match " + m.ToString() + " n'est pas present");

            //update
            m.PhaseTournoi = EPhaseTournoi.Finale;
            service.updateMatch(m);
            result = service.getAllMatch();
            Assert.IsTrue(result.Exists(x => x.Id == m.Id && x.PhaseTournoi == EPhaseTournoi.Finale), "Le match " + m.ToString() + " n'a pas ete modife");

            //delete
            service.deleteMatch(m);
            result = service.getAllMatch();
            Assert.IsTrue(!result.Exists(x => x.Id == m.Id), "Le match " + m.ToString() + "existe toujours");
        }