Skip to content

Commit fbf2cb4

Browse files
committed
Readme, Test case updated
1 parent 97f2231 commit fbf2cb4

20 files changed

Lines changed: 1029 additions & 1287 deletions

Contentstack.Core.Tests/AssetTest.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,25 @@ public class AssetTest
1818
public async Task FetchAssetByUid()
1919
{
2020
Asset asset = client.Asset("blt649cfadb08b577db");
21-
await asset.Fetch();
22-
Assert.True(asset.FileName.Length > 0);
21+
await asset.Fetch().ContinueWith((t) =>
22+
{
23+
Asset result = t.Result;
24+
if (result == null)
25+
{
26+
Assert.False(true, "Entry.Fetch is not match with expected result.");
27+
}
28+
else
29+
{
30+
Assert.True(asset.FileName.Length > 0);
31+
}
32+
});
2333
}
2434

2535
[Fact]
2636
public async Task FetchAssets()
2737
{
2838
AssetLibrary assetLibrary = client.AssetLibrary();
29-
Asset[] assets = await assetLibrary.FetchAll();
39+
ContentstackCollection<Asset> assets = await assetLibrary.FetchAll();
3040
Assert.True(assets.Count() > 0);
3141
foreach (Asset asset in assets)
3242
{
@@ -39,7 +49,7 @@ public async Task FetchAssetsOrderByAscending()
3949
{
4050
AssetLibrary assetLibrary = client.AssetLibrary();
4151
assetLibrary.SortWithKeyAndOrderBy("created_at", Internals.OrderBy.OrderByAscending);
42-
Asset[] assets = await assetLibrary.FetchAll();
52+
ContentstackCollection<Asset> assets = await assetLibrary.FetchAll();
4353
Assert.True(assets.Count() > 0);
4454
DateTime dateTime = new DateTime();
4555
foreach (Asset asset in assets)
@@ -61,7 +71,7 @@ public async Task FetchAssetsIncludeRelativeURL()
6171
{
6272
AssetLibrary assetLibrary = client.AssetLibrary();
6373
assetLibrary.IncludeRelativeUrls();
64-
Asset[] assets = await assetLibrary.FetchAll();
74+
ContentstackCollection<Asset> assets = await assetLibrary.FetchAll();
6575
Assert.True(assets.Count() > 0);
6676
foreach (Asset asset in assets)
6777
{

Contentstack.Core.Tests/EntryTest.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,19 @@ public class EntryTest
2424
public async Task FetchByUid() {
2525
ContentType contenttype = client.ContentType(source);
2626
Entry sourceEntry = contenttype.Entry(singelEntryFetchUID);
27-
SourceModel result = await sourceEntry.Fetch<SourceModel>();
2827

29-
if (result == null) {
30-
Assert.False(true, "Entry.Fetch is not match with expected result.");
31-
} else {
32-
Assert.True(result.Uid == sourceEntry.Uid);
33-
}
28+
await sourceEntry.Fetch<Entry>().ContinueWith((t) =>
29+
{
30+
Entry result = t.Result;
31+
if (result == null)
32+
{
33+
Assert.False(true, "Entry.Fetch is not match with expected result.");
34+
}
35+
else
36+
{
37+
Assert.True(result.Uid == sourceEntry.Uid);
38+
}
39+
});
3440
}
3541

3642
[Fact]
@@ -44,10 +50,10 @@ public async Task IncludeReference() {
4450
} else {
4551

4652
bool IsTrue = false;
47-
List<Dictionary<string, object>> lstReference = result.Reference;
53+
List<Entry> lstReference = result.Reference;
4854

4955
if (lstReference.Count > 0) {
50-
IsTrue = lstReference.All(a => a is Dictionary<string, object>);
56+
IsTrue = lstReference.All(a => a is Entry);
5157
}
5258
Assert.True(IsTrue);
5359
}

Contentstack.Core.Tests/Models/SourceModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class SourceModel
1616
public double? Number;
1717
public Boolean Boolean;
1818
public string Date;
19+
public Asset file;
1920
public List<string> Reference;
2021
public List<string> Other_reference;
2122
public Dictionary<string, object> Group;

Contentstack.Core.Tests/Models/SourceModelIncludeRef.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ public class SourceModelIncludeRef
1111
public string Url;
1212
public string Markdown;
1313
public double? Number;
14+
public Asset file;
1415
public Boolean Boolean;
1516
public string Date;
16-
public List<Dictionary<string, object>> Reference;
17+
public List<Entry> Reference;
1718
public List<string> Other_reference;
1819
public Dictionary<string, object> Group;
1920
public List<Dictionary<string, object>> Modular_blocks;

0 commit comments

Comments
 (0)