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");
        }
 public void updateMatch(MatchWCF match)
 {
     List<Match> matches = bm.getMatches();
     int index_to_modify = matches.FindIndex(x => x.Id == match.Id);
     matches[index_to_modify] = match.toMatch();
     bm.updateMatch(matches);
 }
 public void addMatch(MatchWCF match)
 {
     List<Match> matches = bm.getMatches();
     matches.Add(new Match(match.Jedi1.toJedi(), match.Jedi2.toJedi(), match.PhaseTournoi, match.Stade.toStade()));
     bm.updateMatch(matches);
 }
 public void deleteMatch(MatchWCF match)
 {
     List<Match> matches = bm.getMatches();
     int index_to_modify = matches.FindIndex(x => x.Id == match.Id);
     matches.RemoveAt(index_to_modify);
     bm.updateMatch(matches);
 }