Пример #1
0
    [TestCase("/b/c", true, 1002)] // (hence the 2005 collision)
    public void GetByRouteHide(string route, bool hide, int expected)
    {
        GlobalSettings.HideTopLevelNodeFromPath = hide;

        var xml = GetXmlContent(1234);

        IEnumerable <ContentNodeKit> kits = PublishedContentXmlAdapter.GetContentNodeKits(
            xml,
            TestHelper.ShortStringHelper,
            out var contentTypes,
            out var dataTypes).ToList();

        InitializedCache(kits, contentTypes, dataTypes);

        var cache = GetPublishedSnapshot().Content;

        const bool preview = false; // make sure we don't cache - but HOW? should be some sort of switch?!
        var        content = cache.GetByRoute(preview, route);

        if (expected < 0)
        {
            Assert.IsNull(content);
        }
        else
        {
            Assert.IsNotNull(content);
            Assert.AreEqual(expected, content.Id);
        }
    }
        private async Task <(ContentFinderByUrl finder, IPublishedRequestBuilder frequest)> GetContentFinder(string urlString)
        {
            string xml = PublishedContentXml.BaseWebTestXml(1234);

            IEnumerable <ContentNodeKit> kits = PublishedContentXmlAdapter.GetContentNodeKits(
                xml,
                TestHelper.ShortStringHelper,
                out ContentType[] contentTypes,
                out DataType[] dataTypes).ToList();
        public override void Setup()
        {
            base.Setup();

            IEnumerable <ContentNodeKit> kits = PublishedContentXmlAdapter.GetContentNodeKits(
                XmlContent,
                TestHelper.ShortStringHelper,
                out ContentType[] contentTypes,
                out DataType[] dataTypes).ToList();
        public override void Setup()
        {
            base.Setup();

            string xml = PublishedContentXml.PublishedContentTestXml(1234, _node1173Guid);

            IEnumerable <ContentNodeKit> kits = PublishedContentXmlAdapter.GetContentNodeKits(
                xml,
                TestHelper.ShortStringHelper,
                out ContentType[] contentTypes,
                out DataType[] dataTypes).ToList();
Пример #5
0
        public void GetRouteByIdNoHide(int id, bool hide, string expected)
        {
            GlobalSettings.HideTopLevelNodeFromPath = hide;

            string xml = GetXmlContent(1234);

            IEnumerable <ContentNodeKit> kits = PublishedContentXmlAdapter.GetContentNodeKits(
                xml,
                TestHelper.ShortStringHelper,
                out ContentType[] contentTypes,
                out DataType[] dataTypes).ToList();
Пример #6
0
        public void Ensure_Cache_Is_Correct()
        {
            var requestHandlerSettings = new RequestHandlerSettings {
                AddTrailingSlash = false
            };

            string xml = PublishedContentXml.BaseWebTestXml(1234);

            IEnumerable <ContentNodeKit> kits = PublishedContentXmlAdapter.GetContentNodeKits(
                xml,
                TestHelper.ShortStringHelper,
                out ContentType[] contentTypes,
                out DataType[] dataTypes).ToList();
Пример #7
0
    public override void Setup()
    {
        base.Setup();

        var xml = PublishedContentXml.BaseWebTestXml(1234);

        IEnumerable <ContentNodeKit> kits = PublishedContentXmlAdapter.GetContentNodeKits(
            xml,
            TestHelper.ShortStringHelper,
            out var contentTypes,
            out var dataTypes).ToList();

        InitializedCache(kits, contentTypes, dataTypes);
    }
        public override void Setup()
        {
            base.Setup();

            _webRoutingSettings     = new WebRoutingSettings();
            _requestHandlerSettings = new RequestHandlerSettings {
                AddTrailingSlash = true
            };

            GlobalSettings.HideTopLevelNodeFromPath = false;

            string xml = PublishedContentXml.BaseWebTestXml(1234);

            IEnumerable <ContentNodeKit> kits = PublishedContentXmlAdapter.GetContentNodeKits(
                xml,
                TestHelper.ShortStringHelper,
                out ContentType[] contentTypes,
                out DataType[] dataTypes).ToList();
Пример #9
0
    public void GetRouteByIdCache()
    {
        GlobalSettings.HideTopLevelNodeFromPath = false;

        var xml = GetXmlContent(1234);

        IEnumerable <ContentNodeKit> kits = PublishedContentXmlAdapter.GetContentNodeKits(
            xml,
            TestHelper.ShortStringHelper,
            out var contentTypes,
            out var dataTypes).ToList();

        InitializedCache(kits, contentTypes, dataTypes);

        var cache = GetPublishedSnapshot().Content;

        var route = cache.GetRouteById(false, 1000);

        Assert.AreEqual("/a", route);
    }
Пример #10
0
    public override void Setup()
    {
        base.Setup();

        IEnumerable <ContentNodeKit> kits = PublishedContentXmlAdapter.GetContentNodeKits(
            XmlContent,
            TestHelper.ShortStringHelper,
            out var contentTypes,
            out var dataTypes).ToList();

        // configure inheritance for content types
        var baseType = new ContentType(TestHelper.ShortStringHelper, -1)
        {
            Alias = "Base"
        };

        contentTypes[0].AddContentType(baseType);

        InitializedCache(kits, contentTypes, dataTypes);
    }
Пример #11
0
    public void GetByRouteCache()
    {
        GlobalSettings.HideTopLevelNodeFromPath = false;

        var xml = GetXmlContent(1234);

        IEnumerable <ContentNodeKit> kits = PublishedContentXmlAdapter.GetContentNodeKits(
            xml,
            TestHelper.ShortStringHelper,
            out var contentTypes,
            out var dataTypes).ToList();

        InitializedCache(kits, contentTypes, dataTypes);

        var cache = GetPublishedSnapshot().Content;

        var content = cache.GetByRoute(false, "/a/b/c");

        Assert.IsNotNull(content);
        Assert.AreEqual(1002, content.Id);
    }
    private async Task <(ContentFinderByUrl finder, IPublishedRequestBuilder frequest)> GetContentFinder(
        string urlString)
    {
        var xml = PublishedContentXml.BaseWebTestXml(1234);

        IEnumerable <ContentNodeKit> kits = PublishedContentXmlAdapter.GetContentNodeKits(
            xml,
            TestHelper.ShortStringHelper,
            out var contentTypes,
            out var dataTypes).ToList();

        InitializedCache(kits, contentTypes, dataTypes);

        var umbracoContextAccessor = GetUmbracoContextAccessor(urlString);
        var umbracoContext         = umbracoContextAccessor.GetRequiredUmbracoContext();
        var publishedRouter        = CreatePublishedRouter(umbracoContextAccessor);
        var frequest = await publishedRouter.CreateRequestAsync(umbracoContext.CleanedUmbracoUrl);

        var lookup = new ContentFinderByUrl(Mock.Of <ILogger <ContentFinderByUrl> >(), umbracoContextAccessor);

        return(lookup, frequest);
    }
Пример #13
0
    public override void Setup()
    {
        base.Setup();

        var xml = PublishedContentXml.PublishedContentTestXml(1234, _node1173Guid);

        IEnumerable <ContentNodeKit> kits = PublishedContentXmlAdapter.GetContentNodeKits(
            xml,
            TestHelper.ShortStringHelper,
            out var contentTypes,
            out var dataTypes).ToList();

        _dataTypes = dataTypes;

        // configure the Home content type to be composed of another for tests.
        var compositionType = new ContentType(TestHelper.ShortStringHelper, -1)
        {
            Alias = "MyCompositionAlias"
        };

        contentTypes.First(x => x.Alias == "Home").AddContentType(compositionType);

        InitializedCache(kits, contentTypes, dataTypes);
    }