public void Update_NameIncorrect_ShouldThrownGenreIncorrectException() { var dto = new GenreDto() { Id = DefaultData.Genres.DotNet.Id }; Assert.Throws <GenreIncorrectException>(async() => { await GenresService.Update(dto.Id, dto); }); }
public async Task Update_ShouldUpdated() { var genre = Genres.First(); var dto = new GenreDto() { Id = genre.Id, Name = "very updated genre name" }; await GenresService.Update(dto.Id, dto); Assert.That(Genres.SingleOrDefault(x => string.Equals(x.Name, dto.Name, StringComparison.CurrentCultureIgnoreCase)), Is.Not.Null); }
public void Update_ExistingName_ShouldThrownGenresDublicateException() { var dto = new GenreDto() { Id = DefaultData.Genres.CSharp.Id, Name = DefaultData.Genres.LanguageAndTools.Name, }; Assert.Throws <GenreDublicateException>(async() => { await GenresService.Update(dto.Id, dto); }); }
private void btnEdit_Click(object sender, System.EventArgs e) { if (Helpers.IsAnyEmpty(string.IsNullOrEmpty, txtName.Text)) { MetroMessageBox.Show(this, "Заполните название жанра для изменения", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var genre = _genresService.Find((lstGenres.SelectedItems[0].Tag as Genre).Id); genre.Name = txtName.Text.Trim(); _genresService.Update(genre); MetroMessageBox.Show(this, $"Изменено", "Справка", MessageBoxButtons.OK, MessageBoxIcon.Information); lstGenres.SelectedItems[0].Text = genre.Name; }