示例#1
0
        public async void GetTypeAsync()
        {
            mockHttp.When($"{baseUrl}/types/article").
            Respond("application/json", File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "Fixtures\\DeliveryClient\\article.json")));

            mockHttp.When($"{baseUrl}/types/coffee").
            Respond("application/json", File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "Fixtures\\DeliveryClient\\coffee.json")));

            DeliveryClient client = InitializeDeliverClientWithACustomeTypeProvider();

            var articleType = await client.GetTypeAsync("article");

            var coffeeType = await client.GetTypeAsync("coffee");

            var taxonomyElement           = articleType.Elements["personas"];
            var processingTaxonomyElement = coffeeType.Elements["processing"];

            Assert.Equal("article", articleType.System.Codename);
            Assert.Equal("text", articleType.Elements["title"].Type);
            Assert.Equal("rich_text", articleType.Elements["body_copy"].Type);
            Assert.Equal("date_time", articleType.Elements["post_date"].Type);
            Assert.Equal("asset", articleType.Elements["teaser_image"].Type);
            Assert.Equal("modular_content", articleType.Elements["related_articles"].Type);
            Assert.Equal("taxonomy", articleType.Elements["personas"].Type);

            Assert.Equal("number", coffeeType.Elements["price"].Type);
            Assert.Equal("taxonomy", coffeeType.Elements["processing"].Type);

            Assert.Equal("personas", taxonomyElement.TaxonomyGroup);
            Assert.Equal("processing", processingTaxonomyElement.TaxonomyGroup);
        }
示例#2
0
 /// <summary>
 /// Returns a content type.
 /// </summary>
 /// <param name="codename">The codename of a content type.</param>
 /// <returns>The content type with the specified codename.</returns>
 public async Task <DeliveryTypeResponse> GetTypeAsync(string codename)
 {
     return(await CacheManager.GetOrAddAsync(
                CacheHelper.GetTypeKey(codename),
                () => DeliveryClient.GetTypeAsync(codename),
                response => response != null));
 }
示例#3
0
        public void GetTypeAsync_NotFound()
        {
            var client = new DeliveryClient(PROJECT_ID);
            AsyncTestDelegate action = async() => await client.GetTypeAsync("unequestrian_nonadjournment_sur_achoerodus");

            Assert.ThrowsAsync <DeliveryException>(action);
        }
示例#4
0
        public async void GetTypeAsync_NotFound()
        {
            string messsge = "{'message': 'The requested content type unequestrian_nonadjournment_sur_achoerodus was not found','request_id': '','error_code': 101,'specific_code': 0}";

            mockHttp.When($"{baseUrl}/types/unequestrian_nonadjournment_sur_achoerodus").
            Respond(HttpStatusCode.NotFound, "application/json", messsge);

            DeliveryClient client = InitializeDeliverClientWithACustomeTypeProvider();

            await Assert.ThrowsAsync <DeliveryException>(async() => await client.GetTypeAsync("unequestrian_nonadjournment_sur_achoerodus"));
        }
示例#5
0
        public void GetTypeAsync()
        {
            var client                = new DeliveryClient(PROJECT_ID);
            var articleType           = Task.Run(() => client.GetTypeAsync("article")).Result;
            var coffeeType            = Task.Run(() => client.GetTypeAsync("coffee")).Result;
            var taxonomyElement       = articleType.Elements["personas"];
            var multipleChoiceElement = coffeeType.Elements["processing"];

            Assert.AreEqual("article", articleType.System.Codename);
            Assert.AreEqual("text", articleType.Elements["title"].Type);
            Assert.AreEqual("rich_text", articleType.Elements["body_copy"].Type);
            Assert.AreEqual("date_time", articleType.Elements["post_date"].Type);
            Assert.AreEqual("asset", articleType.Elements["teaser_image"].Type);
            Assert.AreEqual("modular_content", articleType.Elements["related_articles"].Type);
            Assert.AreEqual("taxonomy", articleType.Elements["personas"].Type);
            Assert.AreEqual("number", coffeeType.Elements["price"].Type);
            Assert.AreEqual("multiple_choice", coffeeType.Elements["processing"].Type);

            Assert.AreEqual("personas", taxonomyElement.TaxonomyGroup);
            Assert.GreaterOrEqual(multipleChoiceElement.Options.Count, 1);
        }
示例#6
0
        public async void GetTypeAsync()
        {
            var articleType = await client.GetTypeAsync("article");

            var coffeeType = await client.GetTypeAsync("coffee");

            var taxonomyElement           = articleType.Elements["personas"];
            var processingTaxonomyElement = coffeeType.Elements["processing"];

            Assert.Equal("article", articleType.System.Codename);
            Assert.Equal("text", articleType.Elements["title"].Type);
            Assert.Equal("rich_text", articleType.Elements["body_copy"].Type);
            Assert.Equal("date_time", articleType.Elements["post_date"].Type);
            Assert.Equal("asset", articleType.Elements["teaser_image"].Type);
            Assert.Equal("modular_content", articleType.Elements["related_articles"].Type);
            Assert.Equal("taxonomy", articleType.Elements["personas"].Type);
            Assert.Equal("number", coffeeType.Elements["price"].Type);
            Assert.Equal("taxonomy", coffeeType.Elements["processing"].Type);

            Assert.Equal("personas", taxonomyElement.TaxonomyGroup);
            Assert.Equal("processing", processingTaxonomyElement.TaxonomyGroup);
        }
        /// <summary>
        /// Returns a content type.
        /// </summary>
        /// <param name="codename">The codename of a content type.</param>
        /// <returns>The content type with the specified codename.</returns>
        public async Task <ContentType> GetTypeAsync(string codename)
        {
            var identifierTokens = new List <string> {
                KenticoCloudCacheHelper.CONTENT_TYPE_SINGLE_IDENTIFIER, codename
            };

            return(await CacheManager.GetOrCreateAsync(
                       identifierTokens,
                       () => DeliveryClient.GetTypeAsync(codename),
                       response => response == null,
                       GetTypeSingleDependencies,
                       ProjectOptions.CreateCacheEntriesInBackground));
        }
 public Task <ContentType> GetTypeAsync(string codename)
 {
     return(_client.GetTypeAsync(codename));
 }