Skip to content

Commit c1679b1

Browse files
authored
Merge pull request #123 from contentstack/feat/DX-3249
feat: Fetch Assets by tag value
2 parents cab1943 + 5216619 commit c1679b1

File tree

6 files changed

+531
-3
lines changed

6 files changed

+531
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
### Version: 2.23.0
2+
#### Date: Aug-05-2025
3+
4+
##### Feat:
5+
- Fetch Assets using tags
6+
17
### Version: 2.22.2
28
#### Date: July-14-2025
39

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
using System;
2+
using Xunit;
3+
using Contentstack.Core.Models;
4+
using System.Threading.Tasks;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
8+
namespace Contentstack.Core.Tests
9+
{
10+
public class AssetTagsBasicTest
11+
{
12+
ContentstackClient client = StackConfig.GetStack();
13+
14+
[Fact]
15+
public async Task AssetTags_BasicFunctionality_Test()
16+
{
17+
AssetLibrary assetLibrary = client.AssetLibrary();
18+
19+
assetLibrary.Tags(new string[] { "test" });
20+
21+
Assert.NotNull(assetLibrary);
22+
23+
assetLibrary.Tags(new string[] { "tag1", "tag2", "tag3" });
24+
Assert.NotNull(assetLibrary);
25+
}
26+
27+
[Fact]
28+
public async Task AssetTags_ChainWithOtherMethods_Test()
29+
{
30+
AssetLibrary assetLibrary = client.AssetLibrary();
31+
32+
var chainedLibrary = assetLibrary
33+
.Tags(new string[] { "test" })
34+
.Limit(1)
35+
.Skip(0);
36+
37+
Assert.NotNull(chainedLibrary);
38+
}
39+
40+
[Fact]
41+
public async Task AssetTags_NullAndEmptyHandling_Test()
42+
{
43+
AssetLibrary assetLibrary = client.AssetLibrary();
44+
45+
assetLibrary.Tags(null);
46+
Assert.NotNull(assetLibrary);
47+
48+
assetLibrary.Tags(new string[] { });
49+
Assert.NotNull(assetLibrary);
50+
}
51+
52+
[Fact]
53+
public void AssetTags_MethodExists_Test()
54+
{
55+
AssetLibrary assetLibrary = client.AssetLibrary();
56+
57+
var result = assetLibrary.Tags(new string[] { "test" });
58+
59+
Assert.IsType<AssetLibrary>(result);
60+
}
61+
62+
[Fact]
63+
public void AssetTags_MultipleCalls_ShouldNotThrowException_Test()
64+
{
65+
AssetLibrary assetLibrary = client.AssetLibrary();
66+
67+
assetLibrary.Tags(new string[] { "tag1", "tag2" });
68+
assetLibrary.Tags(new string[] { "tag3", "tag4" });
69+
assetLibrary.Tags(new string[] { "newtag1", "newtag2", "newtag3" });
70+
71+
Assert.IsType<AssetLibrary>(assetLibrary);
72+
}
73+
}
74+
}

0 commit comments

Comments
 (0)