public async Task RenameTag_should_ignore_and_normalize_whitespace_for_tag(string existingTags, string expectedTags) { // given string tagToSearch = "typo-tag"; string newTag = "fixed-tag"; List <Page> pagesWithTags = _fixture.CreateMany <Page>().ToList(); pagesWithTags.ForEach(p => { p.Tags = existingTags; }); _pageRepositoryMock .FindPagesContainingTagAsync(tagToSearch) .Returns(pagesWithTags); // when await _tagsController.Rename(tagToSearch, newTag); // then await _pageRepositoryMock .Received(1) .FindPagesContainingTagAsync(tagToSearch); await _pageRepositoryMock .Received(pagesWithTags.Count) .UpdateExistingAsync(Arg.Is <Page>(p => p.Tags == expectedTags)); }
public async Task RenameTag_should_ignore_and_normalize_whitespace_for_tag_and_return_nocontent(string existingTags, string expectedTags) { // given string tagToSearch = "typo-tag"; string newTag = "fixed-tag"; List <Page> pagesWithTags = _fixture.CreateMany <Page>().ToList(); pagesWithTags.ForEach(p => { p.Tags = existingTags; }); _pageRepositoryMock .FindPagesContainingTagAsync(tagToSearch) .Returns(pagesWithTags); // when ActionResult <string> actionResult = await _tagsController.Rename(tagToSearch, newTag); // then actionResult.ShouldBeNoContentResult(); foreach (Page page in pagesWithTags) { page.Tags.ShouldBe(expectedTags); } }