public async Task Remove_Series()
        {
            var series = await SeriesHelpers.CreateValidSeries();

            var repository = new SeriesRepository(_fixture.Context);

            (await repository.ExistsAsync(series.Id)).Should().BeTrue();

            await SeriesHelpers.RemoveSeries(series.Id);

            var sut = await repository.GetAsync(series.Id);

            await _fixture.Context.Entry(sut).ReloadAsync();

            (await repository.ExistsAsync(series.Id)).Should().BeFalse();
        }
        public async Task Set_Series_Read_Order()
        {
            var series = await SeriesHelpers.CreateValidSeriesWithBooks();

            var repository = new SeriesRepository(_fixture.Context);

            (await repository.ExistsAsync(series.Id)).Should().BeTrue();

            var sut = await repository.LoadAsync(series.Id);

            var seriesId = sut.Id;

            sut.Should().NotBeNull();
            sut.Books.Count.Should().Be(2);
            sut.Books.SingleOrDefault(b => b.Instalment == 1)?.BooksId
            .Should().Be(sut.Books.SingleOrDefault(r => r.Book.Title == "Book 1")?.BooksId);
            sut.Books.SingleOrDefault(b => b.Instalment == 2)?.BooksId
            .Should().Be(sut.Books.SingleOrDefault(r => r.Book.Title == "Book 2")?.BooksId);

            // Re-order collection
            sut = await repository.LoadAsync(series.Id);

            sut.Books.Single(b => b.Instalment == 1).Instalment = 0;
            sut.Books.Single(b => b.Instalment == 2).Instalment = 1;
            sut.Books.Single(b => b.Instalment == 0).Instalment = 2;

            await repository.SaveAsync();

            sut = await repository.LoadAsync(series.Id);

            sut.Books.SingleOrDefault(b => b.Instalment == 2)?.BooksId
            .Should().Be(sut.Books.SingleOrDefault(r => r.Book.Title == "Book 1")?.BooksId);
            sut.Books.SingleOrDefault(b => b.Instalment == 1)?.BooksId
            .Should().Be(sut.Books.SingleOrDefault(r => r.Book.Title == "Book 2")?.BooksId);
        }
        public async Task Update_Series_Books()
        {
            var series = await SeriesHelpers.CreateValidSeriesWithBooks();

            var repository = new SeriesRepository(_fixture.Context);

            (await repository.ExistsAsync(series.Id)).Should().BeTrue();

            var sut = await repository.LoadAsync(series.Id);

            var seriesId = sut.Id;

            sut.Should().NotBeNull();
            sut.Books.Count.Should().Be(2);

            // Add one more book to series
            var book1 = await BookHelpers.CreateValidBook();

            var book2 = await BookHelpers.CreateValidBook();

            var newReadOrder = new List <ReadOrder>
            {
                ReadOrder.NewReadOrder(book1, null, 3),
                ReadOrder.NewReadOrder(book2, null, 4)
            };
            await SeriesHelpers.UpdateSeriesReadOrder(sut.Id, newReadOrder);

            sut = await repository.LoadAsync(series.Id);

            sut.Books.Count.Should().Be(4);
            sut.Id.Should().Be(seriesId);
        }
        public async Task Series_inserted_to_database()
        {
            var series = await SeriesHelpers.CreateValidSeries();

            var repository = new SeriesRepository(_fixture.Context);

            (await repository.ExistsAsync(series.Id)).Should().BeTrue();
        }
        public async Task Update_Series_LogoPath()
        {
            var series = await SeriesHelpers.CreateValidSeries();

            var repository = new SeriesRepository(_fixture.Context);

            (await repository.ExistsAsync(series.Id)).Should().BeTrue();

            var sut = await repository.GetAsync(series.Id);

            var seriesId = sut.Id;

            sut.Should().NotBeNull();
            sut.PicturePath.Should().Be(@"\\filepath\file.jpg");

            await SeriesHelpers.UpdateSeriesPicturePath(sut.Id, @"\\filepath\newFile.jpg");

            await _fixture.Context.Entry(sut).ReloadAsync();

            sut.PicturePath.Should().Be(@"\\filepath\newFile.jpg");
            sut.Id.Should().Be(seriesId);
        }
        public async Task Update_Series_Name()
        {
            var series = await SeriesHelpers.CreateValidSeries();

            var repository = new SeriesRepository(_fixture.Context);

            (await repository.ExistsAsync(series.Id)).Should().BeTrue();

            var sut = await repository.GetAsync(series.Id);

            var seriesId = sut.Id;

            sut.Should().NotBeNull();
            sut.Name.Should().Be("Series to be");

            await SeriesHelpers.UpdateSeriesName(sut.Id, "Series of more books");

            await _fixture.Context.Entry(sut).ReloadAsync();

            sut.Name.Should().Be("Series of more books");
            sut.Id.Should().Be(seriesId);
        }
        public async Task Update_Series_Description()
        {
            var series = await SeriesHelpers.CreateValidSeries();

            var repository = new SeriesRepository(_fixture.Context);

            (await repository.ExistsAsync(series.Id)).Should().BeTrue();

            var sut = await repository.GetAsync(series.Id);

            var seriesId = sut.Id;

            sut.Should().NotBeNull();
            sut.Description.Should().Contain("Best books in the world!");

            await SeriesHelpers.UpdateSeriesDescription(sut.Id, "Bacon ipsum...");

            await _fixture.Context.Entry(sut).ReloadAsync();

            sut.Description.Should().Contain("Bacon ipsum");
            sut.Id.Should().Be(seriesId);
        }