public void Create_ExistsGenre_ShouldThrownGenreDublicateException() { var dto = new GenreDto() { Name = DefaultData.Genres.CSharp.Name }; Assert.Throws <GenreDublicateException>(async() => await GenresService.Create(dto)); }
public ActionResult <Genre> Create([FromBody] Genre newGenre) { try { return(Ok(_gs.Create(newGenre))); } catch (System.Exception err) { return(BadRequest(err.Message)); } }
public async Task Create_RootGenre_ShouldValid() { var oldCount = Genres.Count; var dto = new GenreDto() { Name = nameof(Create_RootGenre_ShouldValid) }; await GenresService.Create(dto); Assert.That(Genres.Count, Is.EqualTo(oldCount + 1)); var createdGenre = Genres.SingleOrDefault(x => string.Equals(x.Name, nameof(Create_RootGenre_ShouldValid), StringComparison.CurrentCultureIgnoreCase)); Assert.That(createdGenre, Is.Not.Null); Assert.That(createdGenre.Parent, Is.Null); Assert.That(createdGenre.Children, Is.Empty); }
public void Create_IncorrectName_ShouldThrownGenreIncorrectException() { GenreDto dto = new GenreDto(); Assert.Throws <GenreIncorrectException>(async() => await GenresService.Create(dto)); }