public async Task Test_AddCategorie_Verifie_Si_La_Methode_AddAsync_Est_Appelee(string libelle) { Categorie categorie = new Categorie(6, libelle); _mockCategorieRepository.Setup(m => m.GetByLibelleAsync(It.IsAny <string>())) .Returns(getByLibelle(categorie.Libelle)); var categorieAvecLibelle = _listeCategories.Where(c => c.Libelle == libelle).FirstOrDefault(); int nombreAppel = (categorieAvecLibelle != null ? 0 : 1); if (nombreAppel == 0) { await Assert.ThrowsAsync <RecordAlreadyExistException>(() => _categorieService.AddCategorie(categorie)); } else { await _categorieService.AddCategorie(categorie); } _mockCategorieRepository.Verify(x => x.AddAsync(It.IsAny <Categorie>()), Times.Exactly(nombreAppel)); }
private void button1_Click(object sender, EventArgs e) { var newFilm = new CategorieModel { Nom = this.textBoxCat.Text, }; if (_categorieService.AddCategorie(newFilm)) { MessageBox.Show("Categorie ajouté avec succès.", "Succès ajout", MessageBoxButtons.OK, MessageBoxIcon.Information); } }