Ejemplo n.º 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");
        }