public void addJedi(JediWCF jedi) { List<Jedi> jedis = bm.getJedis(); List<Caracteristique> listCaract = new List<Caracteristique>(); foreach (CaracteristiqueWCF car in jedi.Caracteristiques) { listCaract.Add(car.toCaracteristique()); } jedis.Add(new Jedi(jedi.Nom,jedi.IsSith,listCaract)); bm.updateJedi(jedis); }
public MatchWCF(Match match) : base(match) { this.jedi1 = new JediWCF(match.Jedi1); this.jedi2 = new JediWCF(match.Jedi2); if (match.JediVainqueur != null) { this.jediVainqueur = new JediWCF(match.JediVainqueur); } this.stade = new StadeWCF(match.Stade); this.phaseTournoi = match.PhaseTournoi; }
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 deleteJedi(JediWCF jedi) { List<Jedi> jedis = bm.getJedis(); int index_to_modify = jedis.FindIndex(x => x.Id == jedi.Id); jedis.RemoveAt(index_to_modify); bm.updateJedi(jedis); }
public void updateJedi(JediWCF jedi) { List<Jedi> jedis = bm.getJedis(); int index_to_modify = jedis.FindIndex(x => x.Id == jedi.Id); jedis[index_to_modify] = jedi.toJedi(); bm.updateJedi(jedis); }