Skip to content

Commit

Permalink
Merge pull request #48 from contentstack/test/DX-750-variants-test
Browse files Browse the repository at this point in the history
test: add Variants tests
  • Loading branch information
nadeem-cs authored Aug 7, 2024
2 parents 34869ae + b095ab4 commit ba53621
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion Contentstack.Core.Tests/EntryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,59 @@ 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<Entry>();

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<Entry>().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<string> { "variant1", "variant2" })
.Fetch<Entry>().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()
{
Expand Down

0 comments on commit ba53621

Please sign in to comment.