public void GetLinkMetadata_PageIsFound_ReturnsStatusCodeAndPageModel(HttpStatusCode statusCode)
            {
                // Arrange
                var pageModel = new LinkModel
                {
                    LinkType = LinkTypeEnum.Page
                };

                getLinkMetadataActionMock.ProcessAction(Arg.Any <string>()).Returns(new GetLinkMetadataActionResult(statusCode, linkModel: pageModel));

                // Act
                var result = richTextController.GetLinkMetadata("pageUrlPath");

                // Assert
                Assert.Multiple(() =>
                {
                    Assert.That(result, Is.TypeOf <JsonCamelCaseResult>());
                    Assert.That((result as JsonCamelCaseResult).Data, Is.EqualTo(pageModel));
                });
            }
        /// <summary>
        /// Serves the link meta data for the given URL.
        /// </summary>
        /// <param name="linkUrl">The link URL.</param>
        public IHttpActionResult GetLinkMetadata(string linkUrl)
        {
            var actionResult = richTextGetLinkMetadataAction.ProcessAction(linkUrl);

            if (actionResult.StatusCode == HttpStatusCode.OK)
            {
                return(Ok(actionResult.LinkModel));
            }

            eventLogService.LogEvent(EventType.ERROR, nameof(KenticoRichTextController), nameof(GetLinkMetadata), actionResult.StatusCodeMessage);

            return(StatusCode(actionResult.StatusCode));
        }
Пример #3
0
        public ActionResult GetLinkMetadata(string linkUrl)
        {
            var actionResult = getLinkMetadataAction.ProcessAction(linkUrl);

            if (actionResult.StatusCode == HttpStatusCode.OK)
            {
                return(new JsonCamelCaseResult(actionResult.LinkModel, JsonRequestBehavior.AllowGet));
            }

            eventLogService.LogEvent(EventType.ERROR, nameof(KenticoRichTextWidgetController), nameof(GetLinkMetadata), actionResult.StatusCodeMessage);

            return(new HttpStatusCodeResult(actionResult.StatusCode));
        }