Esempio n. 1
0
        public async Task AllTags_should_return_all_tags_fill_count_property()
        {
            // given
            List <string> tags = _fixture.CreateMany <string>().ToList();

            var duplicateTags = new List <string>();

            duplicateTags.Add("duplicate-tag");
            duplicateTags.Add("duplicate-tag");
            duplicateTags.Add("duplicate-tag");
            tags.AddRange(duplicateTags);

            int expectedTagCount = tags.Count - (duplicateTags.Count - 1);

            _pageRepositoryMock
            .AllTagsAsync()
            .Returns(tags);

            // when
            IEnumerable <TagResponse> tagViewModels = await _tagsController.AllTags();

            // then
            await _pageRepositoryMock
            .Received(1)
            .AllTagsAsync();

            tagViewModels.Count().ShouldBe(expectedTagCount);
            tagViewModels.First(x => x.Name == "duplicate-tag").Count.ShouldBe(3);
        }
Esempio n. 2
0
        public async Task AllTags_should_return_all_tags_and_fill_count_property()
        {
            // given
            List <string> tags = _fixture.CreateMany <string>().ToList();

            var duplicateTags = new List <string>();

            duplicateTags.Add("duplicate-tag");
            duplicateTags.Add("duplicate-tag");
            duplicateTags.Add("duplicate-tag");
            tags.AddRange(duplicateTags);

            int expectedTagCount = tags.Count - (duplicateTags.Count - 1);

            _pageRepositoryMock
            .AllTagsAsync()
            .Returns(tags);

            // when
            ActionResult <IEnumerable <TagResponse> > actionResult = await _tagsController.AllTags();

            // then
            actionResult.ShouldBeOkObjectResult();
            IEnumerable <TagResponse> response = actionResult.GetOkObjectResultValue();

            response.Count().ShouldBe(expectedTagCount);
            response.First(x => x.Name == "duplicate-tag").Count.ShouldBe(3);
        }