using Novelly.Api.Novels; namespace Novelly.Api.Tests; [TestFixture] public class GenreServiceTests : ServiceTestFixture { [Test] public async Task The_genre_list_arrives_seeded_and_alphabetical() { var listed = await Genres.ListAsync(); Assert.Multiple(() => { Assert.That(listed, Is.Not.Empty); Assert.That(listed.Select(g => g.Name), Has.Member("Fantasy").And.Member("Literary Fiction")); Assert.That(listed.Select(g => g.Name), Is.Ordered); Assert.That(listed.Select(g => g.Id), Is.Unique); }); } [Test] public async Task A_novel_can_be_filed_under_a_genre_off_the_list() { var fantasy = (await Genres.ListAsync()).First(g => g.Name == "Fantasy"); var novel = await Novels.CreateAsync(new CreateNovelRequest("The Salt Road", Genre: fantasy.Name)); Assert.That(novel.Genre, Is.EqualTo("Fantasy")); } [Test] public async Task A_novel_can_still_carry_a_genre_that_is_not_on_the_list() { var novel = await Novels.CreateAsync( new CreateNovelRequest("The Salt Road", Genre: "Nautical Gothic")); Assert.Multiple(async () => { Assert.That(novel.Genre, Is.EqualTo("Nautical Gothic")); Assert.That((await Genres.ListAsync()).Select(g => g.Name), Has.No.Member("Nautical Gothic")); }); } }