From b095ab4320e938c596d3f0804b53692382752d47 Mon Sep 17 00:00:00 2001 From: Nadeem Patwekar Date: Wed, 7 Aug 2024 12:31:58 +0530 Subject: [PATCH] test: add Variants tests --- Contentstack.Core.Tests/EntryTest.cs | 47 +++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/Contentstack.Core.Tests/EntryTest.cs b/Contentstack.Core.Tests/EntryTest.cs index 17e5491..e35bcba 100644 --- a/Contentstack.Core.Tests/EntryTest.cs +++ b/Contentstack.Core.Tests/EntryTest.cs @@ -71,7 +71,8 @@ public async Task FetchEntryByUIDPublishFallback() list.Add("ja-jp"); ContentType contenttype = client.ContentType(source); string uid = await GetUID("source1"); - Entry sourceEntry = await contenttype.Entry(uid) + Entry sourceEntry = contenttype.Entry(uid); + await sourceEntry .SetLocale("ja-jp") .IncludeFallback() .Fetch(); @@ -79,6 +80,50 @@ public async Task FetchEntryByUIDPublishFallback() Assert.Contains((string)(sourceEntry.Get("publish_details") as JObject).GetValue("locale"), list); } + [Fact] + public async Task FetchEntryByVariant() + { + ContentType contenttype = client.ContentType(source); + string uid = await GetUID("source1"); + Entry sourceEntry = contenttype.Entry(uid); + await sourceEntry + .Variant("variant1") + .Fetch().ContinueWith((t) => + { + Entry result = t.Result; + if (result == null) + { + Assert.False(true, "Entry.Fetch is not match with expected result."); + } + else + { + Assert.True(result.Uid == sourceEntry.Uid); + } + }); + } + + [Fact] + public async Task FetchEntryByVariants() + { + ContentType contenttype = client.ContentType(source); + string uid = await GetUID("source1"); + Entry sourceEntry = contenttype.Entry(uid); + await sourceEntry + .Variant(new List { "variant1", "variant2" }) + .Fetch().ContinueWith((t) => + { + Entry result = t.Result; + if (result == null) + { + Assert.False(true, "Entry.Fetch is not match with expected result."); + } + else + { + Assert.True(result.Uid == sourceEntry.Uid); + } + }); + } + [Fact] public async Task FetchEntryByUIDPublishWithoutFallback() {