Skip to content

Commit 6d78a22

Browse files
committed
feat: Fetch Assets by tag value
1 parent 7c96c98 commit 6d78a22

File tree

6 files changed

+573
-2
lines changed

6 files changed

+573
-2
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
### Version: 2.23.0
2+
#### Date: Aug-05-2025
3+
4+
##### Feat:
5+
- Fetch Assets using tags
6+
7+
18
### Version: 2.22.1
29
#### Date: June-13-2025
310

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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+
// Basic test to verify Tags method exists and works
18+
AssetLibrary assetLibrary = client.AssetLibrary();
19+
20+
// This should not throw an exception
21+
assetLibrary.Tags(new string[] { "test" });
22+
23+
// Verify the method returns AssetLibrary for chaining
24+
Assert.NotNull(assetLibrary);
25+
26+
// Test with multiple tags
27+
assetLibrary.Tags(new string[] { "tag1", "tag2", "tag3" });
28+
Assert.NotNull(assetLibrary);
29+
}
30+
31+
[Fact]
32+
public async Task AssetTags_ChainWithOtherMethods_Test()
33+
{
34+
// Test chaining Tags with other methods
35+
AssetLibrary assetLibrary = client.AssetLibrary();
36+
37+
var chainedLibrary = assetLibrary
38+
.Tags(new string[] { "test" })
39+
.Limit(1)
40+
.Skip(0);
41+
42+
Assert.NotNull(chainedLibrary);
43+
}
44+
45+
[Fact]
46+
public async Task AssetTags_NullAndEmptyHandling_Test()
47+
{
48+
AssetLibrary assetLibrary = client.AssetLibrary();
49+
50+
// Should handle null gracefully
51+
assetLibrary.Tags(null);
52+
Assert.NotNull(assetLibrary);
53+
54+
// Should handle empty array gracefully
55+
assetLibrary.Tags(new string[] { });
56+
Assert.NotNull(assetLibrary);
57+
}
58+
59+
[Fact]
60+
public void AssetTags_MethodExists_Test()
61+
{
62+
// Verify the Tags method exists with correct signature
63+
AssetLibrary assetLibrary = client.AssetLibrary();
64+
65+
// This will compile only if the method exists with correct signature
66+
var result = assetLibrary.Tags(new string[] { "test" });
67+
68+
// Should return AssetLibrary type for method chaining
69+
Assert.IsType<AssetLibrary>(result);
70+
}
71+
72+
[Fact]
73+
public void AssetTags_MultipleCalls_ShouldNotThrowException_Test()
74+
{
75+
// Test multiple calls to Tags() method on same instance
76+
AssetLibrary assetLibrary = client.AssetLibrary();
77+
78+
// First call
79+
assetLibrary.Tags(new string[] { "tag1", "tag2" });
80+
81+
// Second call should not throw "An item with the same key has already been added" exception
82+
assetLibrary.Tags(new string[] { "tag3", "tag4" });
83+
84+
// Third call with different tags
85+
assetLibrary.Tags(new string[] { "newtag1", "newtag2", "newtag3" });
86+
87+
// Should return AssetLibrary type for method chaining
88+
Assert.IsType<AssetLibrary>(assetLibrary);
89+
}
90+
}
91+
}

0 commit comments

Comments
 (0)