public void addTournoi(TournoiWCF tournoi) { List<Tournoi> tournois = bm.getTournoi(); List<Match> listMatch = new List<Match>(); foreach (MatchWCF match in tournoi.Matches) { listMatch.Add(match.toMatch()); } tournois.Add(new Tournoi(listMatch,tournoi.Nom)); bm.updateTournoi(tournois); }
public void TournoiTest() { //get ServiceJediReference.ServiceJediClient service = new ServiceJediReference.ServiceJediClient(); List<TournoiWCF> result = service.getAllTournoi(); BusinessLayer.BusinessManager bm = new BusinessLayer.BusinessManager(); List<Tournoi> original = bm.getTournoi(); List<TournoiWCF> expected = new List<TournoiWCF>(); foreach (Tournoi tournois in original) { expected.Add(new TournoiWCF(tournois)); } foreach (TournoiWCF tournois in expected) { Assert.IsTrue(result.Exists(x=> x.Nom == tournois.Nom),"Le tournoi " + tournois.Nom + " n'est pas present"); } //add List<Match> matches = bm.getMatches(); TournoiWCF t = new TournoiWCF(new Tournoi(matches, "Tournoistest" )); service.addTournoi(t); result = service.getAllTournoi(); Assert.IsTrue(result.Exists(x => x.Nom == t.Nom), "Le tournois " + t.Nom + " n'est pas present"); //update t = result.Find(x => x.Nom == "Tournoistest"); t.Nom = "Tournoistest2"; service.updateTournois(t); result = service.getAllTournoi(); Assert.IsTrue(result.Exists(x => x.Nom == "Tournoistest2"), "Le tournois " + t.Nom + " n'a pas ete modife"); //delete service.deleteTournois(t); result = service.getAllTournoi(); Assert.IsTrue(!result.Exists(x => x.Nom == "Tournoistest2"), "Le tournois " + t.Nom + "existe toujours"); }
public TournoiWCF playTournoi(TournoiWCF tournoi) { return new TournoiWCF(bm.playTournoi(tournoi.toTournoi())); }
public void updateTournois(TournoiWCF tournoi) { List<Tournoi> tournois = bm.getTournoi(); int index_to_modify = tournois.FindIndex(x => x.Id == tournoi.Id); tournois[index_to_modify] = tournoi.toTournoi(); bm.updateTournoi(tournois); }
public void deleteTournois(TournoiWCF tournoi) { List<Tournoi> tournois = bm.getTournoi(); int index_to_modify = tournois.FindIndex(x => x.Id == tournoi.Id); tournois.RemoveAt(index_to_modify); bm.updateTournoi(tournois); }