Skip to content

Commit b095ab4

Browse files
committed
test: add Variants tests
1 parent 34869ae commit b095ab4

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

Contentstack.Core.Tests/EntryTest.cs

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,59 @@ public async Task FetchEntryByUIDPublishFallback()
7171
list.Add("ja-jp");
7272
ContentType contenttype = client.ContentType(source);
7373
string uid = await GetUID("source1");
74-
Entry sourceEntry = await contenttype.Entry(uid)
74+
Entry sourceEntry = contenttype.Entry(uid);
75+
await sourceEntry
7576
.SetLocale("ja-jp")
7677
.IncludeFallback()
7778
.Fetch<Entry>();
7879

7980
Assert.Contains((string)(sourceEntry.Get("publish_details") as JObject).GetValue("locale"), list);
8081
}
8182

83+
[Fact]
84+
public async Task FetchEntryByVariant()
85+
{
86+
ContentType contenttype = client.ContentType(source);
87+
string uid = await GetUID("source1");
88+
Entry sourceEntry = contenttype.Entry(uid);
89+
await sourceEntry
90+
.Variant("variant1")
91+
.Fetch<Entry>().ContinueWith((t) =>
92+
{
93+
Entry result = t.Result;
94+
if (result == null)
95+
{
96+
Assert.False(true, "Entry.Fetch is not match with expected result.");
97+
}
98+
else
99+
{
100+
Assert.True(result.Uid == sourceEntry.Uid);
101+
}
102+
});
103+
}
104+
105+
[Fact]
106+
public async Task FetchEntryByVariants()
107+
{
108+
ContentType contenttype = client.ContentType(source);
109+
string uid = await GetUID("source1");
110+
Entry sourceEntry = contenttype.Entry(uid);
111+
await sourceEntry
112+
.Variant(new List<string> { "variant1", "variant2" })
113+
.Fetch<Entry>().ContinueWith((t) =>
114+
{
115+
Entry result = t.Result;
116+
if (result == null)
117+
{
118+
Assert.False(true, "Entry.Fetch is not match with expected result.");
119+
}
120+
else
121+
{
122+
Assert.True(result.Uid == sourceEntry.Uid);
123+
}
124+
});
125+
}
126+
82127
[Fact]
83128
public async Task FetchEntryByUIDPublishWithoutFallback()
84129
{

0 commit comments

Comments
 (0)