public async void AddNewPage_should_add_page_and_increment_id() { // given string createdBy = "lyon"; DateTime createdOn = DateTime.Today; PageRepository repository = CreateRepository(); Page page = _fixture.Create <Page>(); page.Id = -1; // should be reset page.CreatedBy = createdBy; page.CreatedOn = createdOn; page.LastModifiedBy = createdBy; page.LastModifiedOn = createdOn; // when await repository.AddNewPageAsync(page); Page actualPage = await repository.AddNewPageAsync(page); // then actualPage.ShouldNotBeNull(); actualPage.CreatedOn.ShouldBe(createdOn); actualPage.CreatedBy.ShouldBe(createdBy); Page savedVersion = await repository.GetPageByIdAsync(actualPage.Id); savedVersion.ShouldNotBeNull(); savedVersion.Id.ShouldBeGreaterThanOrEqualTo(1); }
public async Task GetPageById_should_find_by_id() { // given PageRepository repository = CreateRepository(); List <Page> pages = CreateTenPages(repository); Page expectedPage = pages[0]; // when Page actualPage = await repository.GetPageByIdAsync(expectedPage.Id); // then actualPage.ShouldNotBeNull(); actualPage.ShouldBeEquivalent(expectedPage); }
public async void DeletePage_should_delete_specific_page() { // given PageRepository repository = CreateRepository(); CreateTenPages(repository); var pageToDelete = _fixture.Create <Page>(); await repository.AddNewPageAsync(pageToDelete); // when await repository.DeletePageAsync(pageToDelete.Id); // then var deletedPage = await repository.GetPageByIdAsync(pageToDelete.Id); deletedPage.ShouldBeNull(); }
public async Task UpdateExisting_should_save_changes() { // given PageRepository repository = CreateRepository(); List <Page> pages = CreateTenPages(repository); Page expectedPage = pages[0]; expectedPage.Tags = "new-tags"; expectedPage.Title = "new title"; // when await repository.UpdateExistingAsync(expectedPage); // then Page actualPage = await repository.GetPageByIdAsync(expectedPage.Id); actualPage.ShouldBeEquivalent(expectedPage); }