public async Task GetById()
        {
            // given
            PageVersionRepository repository   = CreateRepository();
            List <PageVersion>    pageVersions = CreateTenPages(repository);
            PageVersion           pageVersion  = pageVersions[0];

            // when
            PageVersion latestVersion = await repository.GetByIdAsync(pageVersion.Id);

            // then
            Assert.NotNull(latestVersion);
            latestVersion.ShouldNotBeNull();
            latestVersion.ShouldBeEquivalent(pageVersion);
        }
        public async Task GetLatestVersions()
        {
            // given
            PageVersionRepository repository   = CreateRepository();
            List <PageVersion>    pageVersions = CreateTenPages(repository);

            int         pageId   = pageVersions[0].PageId;
            PageVersion version2 = await repository.AddNewVersionAsync(pageId, "v2 text", "editedBy", DateTime.Today.AddMinutes(10));

            PageVersion version3 = await repository.AddNewVersionAsync(pageId, "v3 text", "editedBy", DateTime.Today.AddMinutes(30));

            // when
            PageVersion latestVersion = await repository.GetLatestVersionAsync(pageId);

            // then
            latestVersion.ShouldNotBeNull();
            latestVersion.ShouldBeEquivalent(version3);
        }
        public async void AddNewVersion()
        {
            // given
            PageVersionRepository repository   = CreateRepository();
            List <PageVersion>    pages        = CreateTenPages(repository);
            PageVersion           expectedPage = pages.Last();
            await repository.AddNewVersionAsync(expectedPage.PageId, "v2 text", "brian");

            // when
            PageVersion thirdVersion = await repository.AddNewVersionAsync(expectedPage.PageId, "v3 text", "author2");

            // then
            thirdVersion.ShouldNotBeNull();

            PageVersion savedVersion = await repository.GetByIdAsync(thirdVersion.Id);

            savedVersion.ShouldNotBeNull();
            savedVersion.ShouldBeEquivalent(thirdVersion);
        }
        public async Task UpdateExistingVersion()
        {
            // given
            PageVersionRepository repository   = CreateRepository();
            List <PageVersion>    pageVersions = CreateTenPages(repository);

            PageVersion newVersion = pageVersions[0];

            newVersion.Text   = "some new text";
            newVersion.Author = "blake";

            // when
            await repository.UpdateExistingVersionAsync(newVersion);

            // then
            PageVersion savedVersion = await repository.GetByIdAsync(newVersion.Id);

            savedVersion.ShouldNotBeNull();
            savedVersion.ShouldBeEquivalent(newVersion);
        }