public void LinkingHelperTests_ConvertAnswerToUrl_Converts()
        {
            var answerDto = new AnswerDto()
            {
                LeftWord  = "a",
                RightWord = "b",
                Phrase    = "c"
            };

            var result = LinkingHelper.ConvertAnswerToUrl(answerDto);

            Assert.Equal(result, "/best-a-for-b-is-c");

            result = LinkingHelper.ConvertAnswerToText(answerDto);

            Assert.Equal(result, "Best a for b is c");

            var commonStrings = new CommonStringsDto()
            {
                Best = "x", For = "y", Is = "z"
            };

            result = LinkingHelper.ConvertAnswerToText(commonStrings, answerDto);
            Assert.Equal(result, "x a y b z c");

            result = LinkingHelper.ConvertAnswerToUrl(commonStrings, answerDto);
            Assert.Equal(result, "/x-a-y-b-z-c");

            result = LinkingHelper.ConvertAnswerToUrlWithCulture("f", commonStrings, answerDto);
            Assert.Equal(result, "/f/x-a-y-b-z-c");
        }
        /// <summary>
        /// Fill in answer details for content page.
        /// Reuse the logic between controllers. Also used by AnswerActionController.
        /// </summary>
        /// <param name="answer"></param>
        /// <param name="answerDescriptionService"></param>
        /// <param name="userManager"></param>
        /// <param name="voteService"></param>
        /// <param name="resourcesService"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public static AnswerDetailsDto FillInDetails(AnswerDto answer, IAnswerDescriptionService answerDescriptionService,
                                                     IUserService userService, IVoteService voteService, IResourcesService resourcesService, string culture, string fullDomainName)
        {
            // Load answer descriptions
            // Have to do the list otherwise setting description.UserDisplayName below will not work.
            var searchResult = answerDescriptionService.FindByAnswerId(answer.Id);
            List <AnswerDescriptionDto> descriptions = searchResult == null ? null : searchResult.ToList();

            // Set the username for each description
            if (descriptions != null)
            {
                foreach (var description in descriptions)
                {
                    GetUserDisplayName(description, userService);
                }
            }

            // Fill in result
            var data = new AnswerDetailsDto()
            {
                Answer        = answer,
                CommonStrings = resourcesService.GetCommonStrings(culture),
                Descriptions  = descriptions,
                NumberVotes   = voteService.CountAnswerVotes(answer.Id)
            };

            GetUserDisplayName(data.Answer, userService);

            // Fill in link to this page and other usefull data.
            data.ThisAnswerLink            = LinkingHelper.ConvertAnswerToUrlWithCulture(culture, data.CommonStrings, answer);
            data.ThisAnswerFullLink        = fullDomainName.EndsWith("/") ? fullDomainName.Substring(0, fullDomainName.Length - 1) : fullDomainName + data.ThisAnswerLink;
            data.ThisAnswerText            = LinkingHelper.ConvertAnswerToText(data.CommonStrings, answer);
            data.ThisAnswerFullLinkEscaped = System.Uri.EscapeDataString(data.ThisAnswerFullLink);

            return(data);
        }