public void CanonicalNameConverterTestsReturnsNullForRootPageLocation()
        {
            // Arrange
            var converter    = new CanonicalNameConverter();
            var sourceMember = new CmsApiDataModel();
            var context      = new ResolutionContext(null, null);

            // Act
            var result = converter.Convert(sourceMember, context);

            // Assert
            Assert.Null(result);
        }
Ejemplo n.º 2
0
        private static CmsApiDataModel BuildValidPagesApiDataModel()
        {
            var model = new CmsApiDataModel()
            {
                ItemId             = Guid.NewGuid(),
                CanonicalName      = "an-article",
                Version            = Guid.NewGuid(),
                ExcludeFromSitemap = true,
                Url = new Uri("/aaa/bbb", UriKind.Relative),
                RedirectLocations = new List <string> {
                    "alt-name-1", "alt-name-2"
                },
                Title        = "A title",
                Description  = "a description",
                Keywords     = "some keywords",
                ContentLinks = new ContentLinksModel(new JObject())
                {
                    ContentLinks = new List <KeyValuePair <string, List <ILinkDetails> > >()
                    {
                        new KeyValuePair <string, List <ILinkDetails> >(
                            "test",
                            new List <ILinkDetails>
                        {
                            new LinkDetails
                            {
                                Uri = new Uri("http://www.one.com"),
                            },
                            new LinkDetails
                            {
                                Uri = new Uri("http://www.two.com"),
                            },
                            new LinkDetails
                            {
                                Uri = new Uri("http://www.three.com"),
                            },
                        }),
                    },
                },
                ContentItems = new List <IBaseContentItemModel>
                {
                    new CmsApiHtmlModel {
                        Alignment = "Left", Ordinal = 1, Size = 50, Content = "<h1>A document</h1>",
                    },
                },
                Published = DateTime.UtcNow,
            };

            return(model);
        }
        public void CanonicalNameConverterTestsReturnsRootFromPageLocation()
        {
            // Arrange
            const string expectedResult = "root";
            var          converter      = new CanonicalNameConverter();
            var          sourceMember   = new CmsApiDataModel {
                PageLocation = "/root"
            };
            var context = new ResolutionContext(null, null);

            // Act
            var result = converter.Convert(sourceMember, context);

            // Assert
            Assert.Equal(expectedResult, result);
        }
        public void CanonicalNameConverterTestsReturnsCanonicalName()
        {
            // Arrange
            const string expectedResult = "a-canonical-name";
            var          converter      = new CanonicalNameConverter();
            var          sourceMember   = new CmsApiDataModel {
                CanonicalName = expectedResult
            };
            var context = new ResolutionContext(null, null);

            // Act
            var result = converter.Convert(sourceMember, context);

            // Assert
            Assert.Equal(expectedResult, result);
        }
Ejemplo n.º 5
0
        protected CmsApiDataModel BuildValidPagesApiContentModel()
        {
            var model = new CmsApiDataModel
            {
                ItemId             = Guid.NewGuid(),
                CanonicalName      = "an-article",
                ExcludeFromSitemap = true,
                Version            = Guid.NewGuid(),
                Url          = new Uri("https://localhost"),
                ContentLinks = new ContentLinksModel(new JObject())
                {
                    ContentLinks = new List <KeyValuePair <string, List <ILinkDetails> > >
                    {
                        new KeyValuePair <string, List <ILinkDetails> >(
                            "test",
                            new List <ILinkDetails>
                        {
                            new LinkDetails
                            {
                                Uri = new Uri("http://www.one.com"),
                            },
                            new LinkDetails
                            {
                                Uri = new Uri("http://www.two.com"),
                            },
                            new LinkDetails
                            {
                                Uri = new Uri("http://www.three.com"),
                            },
                        }),
                    },
                },
                ContentItems = new List <IBaseContentItemModel>
                {
                    BuildValidPagesApiPageLocationModel(PageLocationIdForUpdate),
                },
                Published = DateTime.UtcNow,
            };

            return(model);
        }