Skip to content

Commit 811b6ea

Browse files
Merge pull request #138 from contentstack/staging
DX | 13-10-2025 | Release
2 parents fd9fc81 + d59269a commit 811b6ea

File tree

11 files changed

+982
-73
lines changed

11 files changed

+982
-73
lines changed

.talismanrc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ fileignoreconfig:
33
ignore_detectors:
44
- filecontent
55
- filename: Contentstack.Core/Internals/HttpRequestHandler.cs
6-
checksum: 94288e483056f41ff3a4c2ab652c3ce9ecb53dc0b9d4029456b34baed4f34891
6+
checksum: 62053e1b8772f44db054efc504d5d57f28fb7962c81021325854d478f570de09
77
- filename: Contentstack.Core/Models/Entry.cs
88
checksum: 78a09b03b9fd6aefd0251353b2d8c70962bdfced16a6e1e28d10dc9af43da244
99
- filename: Contentstack.Core/ContentstackClient.cs
1010
checksum: 687dc0a5f20037509731cfe540dcec9c3cc2b6cf50373cd183ece4f3249dc88e
1111
- filename: Contentstack.Core/Models/AssetLibrary.cs
12-
checksum: 7e05fd0bbb43b15e6b7f387d746cc64d709e17e0e8e26a7495a99025077ff507
12+
checksum: 0c67f8bb3b7ffdb9b04cd38ae096904b53d6d4372e86c91c1f935e36b6b0ce56
13+
- filename: Contentstack.Core.Tests/AssetTest.cs
14+
checksum: 9e197065aa6ea46af795a8ddb9d652a4972d9d4b4bfc7b1772d304d848f1c3e1
1315
- filename: Contentstack.Core/Models/Asset.cs
1416
checksum: d192718723e6cb2aa8f08f873d3a7ea7268c89cc15da3bdeea4c16fd304c410e
1517
- filename: Contentstack.Core/Models/Query.cs
@@ -20,7 +22,5 @@ fileignoreconfig:
2022
checksum: 53ba4ce874c4d2362ad00deb23f5a6ec219318860352f997b945e9161a580651
2123
- filename: Contentstack.Core.Tests/ContentstackClientTest.cs
2224
checksum: b63897181a8cb5993d1305248cfc3e711c4039b5677b6c1e4e2a639e4ecb391b
23-
- filename: Contentstack.Core.Tests/AssetTest.cs
24-
checksum: 3e7bf50c7223c458561f0217484d5e70cf3770490c569e0a7083b0a12af9ab86
2525
- filename: Contentstack.Core.Tests/RegionHandlerTest.cs
2626
checksum: 69899138754908e156aa477d775d12fd6b3fefc1a6c2afec22cb409bd6e6446c

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
### Version: 2.25.0
2+
#### Date: Jan-07-2025
3+
4+
##### Feat:
5+
- AssetLibrary
6+
- Added new `Where` method for simple key-value pair queries
7+
- Enhanced `Query` method to support multiple calls with intelligent merging
8+
- Improved query handling with better null safety and error handling
9+
110
### Version: 2.24.0
211
#### Date: Sep-29-2025
312

Contentstack.AspNetCore/Contentstack.AspNetCore.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<Owners>Contentstack</Owners>
99
<PackageVersion>$(Version)</PackageVersion>
1010
<Description>Main release</Description>
11-
<Copyright>Copyright (c) 2012-2024 Contentstack (http://app.contentstack.com). All Rights Reserved</Copyright>
11+
<Copyright>Copyright (c) 2012-2025 Contentstack (http://app.contentstack.com). All Rights Reserved</Copyright>
1212
<PackageProjectUrl>https://github.com/contentstack/contentstack-dotnet</PackageProjectUrl>
1313
<PackageTags>v$(Version)</PackageTags>
1414
<ReleaseVersion>$(Version)</ReleaseVersion>

Contentstack.Core.Tests/AssetTest.cs

Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,5 +661,295 @@ public async Task AssetTags_CaseSensitivityVerification_ShouldTestCaseBehavior_T
661661
}
662662
}
663663
}
664+
665+
[Fact]
666+
public void Query_MultipleCalls_ShouldMergeQueries_Test()
667+
{
668+
// Arrange
669+
AssetLibrary assetLibrary = client.AssetLibrary();
670+
JObject firstQuery = new JObject
671+
{
672+
{ "filename", "test1.png" },
673+
{ "content_type", "image/png" }
674+
};
675+
JObject secondQuery = new JObject
676+
{
677+
{ "file_size", 1024 },
678+
{ "tags", new JArray { "test", "image" } }
679+
};
680+
681+
// Act
682+
var result = assetLibrary.Query(firstQuery).Query(secondQuery);
683+
684+
// Assert
685+
Assert.NotNull(result);
686+
Assert.IsType<AssetLibrary>(result);
687+
// The method should not throw an exception when called multiple times
688+
}
689+
690+
[Fact]
691+
public void Query_SingleCall_ShouldWorkAsBefore_Test()
692+
{
693+
// Arrange
694+
AssetLibrary assetLibrary = client.AssetLibrary();
695+
JObject queryObject = new JObject
696+
{
697+
{ "filename", "test.png" }
698+
};
699+
700+
// Act
701+
var result = assetLibrary.Query(queryObject);
702+
703+
// Assert
704+
Assert.NotNull(result);
705+
Assert.IsType<AssetLibrary>(result);
706+
}
707+
708+
[Fact]
709+
public void Query_WithEmptyObject_ShouldNotThrowException_Test()
710+
{
711+
// Arrange
712+
AssetLibrary assetLibrary = client.AssetLibrary();
713+
JObject emptyQuery = new JObject();
714+
715+
// Act & Assert
716+
var result = assetLibrary.Query(emptyQuery);
717+
Assert.NotNull(result);
718+
Assert.IsType<AssetLibrary>(result);
719+
}
720+
721+
[Fact]
722+
public void Query_WithNullValues_ShouldHandleGracefully_Test()
723+
{
724+
// Arrange
725+
AssetLibrary assetLibrary = client.AssetLibrary();
726+
JObject queryWithNulls = new JObject
727+
{
728+
{ "filename", "test.png" },
729+
{ "null_field", null }
730+
};
731+
732+
// Act & Assert
733+
var result = assetLibrary.Query(queryWithNulls);
734+
Assert.NotNull(result);
735+
Assert.IsType<AssetLibrary>(result);
736+
}
737+
738+
[Fact]
739+
public void Query_ChainedWithOtherMethods_ShouldWork_Test()
740+
{
741+
// Arrange
742+
AssetLibrary assetLibrary = client.AssetLibrary();
743+
JObject queryObject = new JObject
744+
{
745+
{ "filename", "test.png" }
746+
};
747+
748+
// Act
749+
var result = assetLibrary
750+
.Query(queryObject)
751+
.Limit(10)
752+
.Skip(0)
753+
.IncludeMetadata();
754+
755+
// Assert
756+
Assert.NotNull(result);
757+
Assert.IsType<AssetLibrary>(result);
758+
}
759+
760+
[Fact]
761+
public void Query_MultipleCallsWithSameKeys_ShouldMergeValues_Test()
762+
{
763+
// Arrange
764+
AssetLibrary assetLibrary = client.AssetLibrary();
765+
JObject firstQuery = new JObject
766+
{
767+
{ "tags", new JArray { "tag1", "tag2" } }
768+
};
769+
JObject secondQuery = new JObject
770+
{
771+
{ "tags", new JArray { "tag3", "tag4" } }
772+
};
773+
774+
// Act
775+
var result = assetLibrary.Query(firstQuery).Query(secondQuery);
776+
777+
// Assert
778+
Assert.NotNull(result);
779+
Assert.IsType<AssetLibrary>(result);
780+
// The method should handle merging arrays without throwing exceptions
781+
}
782+
783+
[Fact]
784+
public void Query_WithComplexNestedObjects_ShouldMergeCorrectly_Test()
785+
{
786+
// Arrange
787+
AssetLibrary assetLibrary = client.AssetLibrary();
788+
JObject firstQuery = new JObject
789+
{
790+
{ "metadata", new JObject
791+
{
792+
{ "author", "John Doe" },
793+
{ "version", 1 }
794+
}
795+
}
796+
};
797+
JObject secondQuery = new JObject
798+
{
799+
{ "metadata", new JObject
800+
{
801+
{ "department", "IT" }
802+
}
803+
},
804+
{ "filename", "test.png" }
805+
};
806+
807+
// Act
808+
var result = assetLibrary.Query(firstQuery).Query(secondQuery);
809+
810+
// Assert
811+
Assert.NotNull(result);
812+
Assert.IsType<AssetLibrary>(result);
813+
}
814+
815+
[Fact]
816+
public void Where_SingleCall_ShouldAddKeyValuePair_Test()
817+
{
818+
// Arrange
819+
AssetLibrary assetLibrary = client.AssetLibrary();
820+
string key = "filename";
821+
string value = "test.png";
822+
823+
// Act
824+
var result = assetLibrary.Where(key, value);
825+
826+
// Assert
827+
Assert.NotNull(result);
828+
Assert.IsType<AssetLibrary>(result);
829+
}
830+
831+
[Fact]
832+
public void Where_MultipleCalls_ShouldAddMultipleKeyValuePairs_Test()
833+
{
834+
// Arrange
835+
AssetLibrary assetLibrary = client.AssetLibrary();
836+
837+
// Act
838+
var result = assetLibrary
839+
.Where("filename", "test.png")
840+
.Where("content_type", "image/png")
841+
.Where("file_size", "1024");
842+
843+
// Assert
844+
Assert.NotNull(result);
845+
Assert.IsType<AssetLibrary>(result);
846+
}
847+
848+
[Fact]
849+
public void Where_WithEmptyStrings_ShouldHandleGracefully_Test()
850+
{
851+
// Arrange
852+
AssetLibrary assetLibrary = client.AssetLibrary();
853+
854+
// Act & Assert
855+
var result = assetLibrary.Where("", "");
856+
Assert.NotNull(result);
857+
Assert.IsType<AssetLibrary>(result);
858+
}
859+
860+
[Fact]
861+
public void Where_WithNullKey_ShouldHandleGracefully_Test()
862+
{
863+
// Arrange
864+
AssetLibrary assetLibrary = client.AssetLibrary();
865+
866+
// Act & Assert
867+
var result = assetLibrary.Where(null, "value");
868+
Assert.NotNull(result);
869+
Assert.IsType<AssetLibrary>(result);
870+
}
871+
872+
[Fact]
873+
public void Where_WithNullValue_ShouldHandleGracefully_Test()
874+
{
875+
// Arrange
876+
AssetLibrary assetLibrary = client.AssetLibrary();
877+
878+
// Act & Assert
879+
var result = assetLibrary.Where("key", null);
880+
Assert.NotNull(result);
881+
Assert.IsType<AssetLibrary>(result);
882+
}
883+
884+
[Fact]
885+
public void Where_ChainedWithOtherMethods_ShouldWork_Test()
886+
{
887+
// Arrange
888+
AssetLibrary assetLibrary = client.AssetLibrary();
889+
890+
// Act
891+
var result = assetLibrary
892+
.Where("filename", "test.png")
893+
.Limit(10)
894+
.Skip(0)
895+
.IncludeMetadata();
896+
897+
// Assert
898+
Assert.NotNull(result);
899+
Assert.IsType<AssetLibrary>(result);
900+
}
901+
902+
[Fact]
903+
public void Where_WithQueryMethod_ShouldWorkTogether_Test()
904+
{
905+
// Arrange
906+
AssetLibrary assetLibrary = client.AssetLibrary();
907+
JObject queryObject = new JObject
908+
{
909+
{ "content_type", "image/png" }
910+
};
911+
912+
// Act
913+
var result = assetLibrary
914+
.Query(queryObject)
915+
.Where("filename", "test.png")
916+
.Where("file_size", "1024");
917+
918+
// Assert
919+
Assert.NotNull(result);
920+
Assert.IsType<AssetLibrary>(result);
921+
}
922+
923+
[Fact]
924+
public void Where_OverwritesExistingKey_ShouldReplaceValue_Test()
925+
{
926+
// Arrange
927+
AssetLibrary assetLibrary = client.AssetLibrary();
928+
929+
// Act
930+
var result = assetLibrary
931+
.Where("filename", "original.png")
932+
.Where("filename", "updated.png");
933+
934+
// Assert
935+
Assert.NotNull(result);
936+
Assert.IsType<AssetLibrary>(result);
937+
}
938+
939+
[Fact]
940+
public void Where_WithSpecialCharacters_ShouldHandleCorrectly_Test()
941+
{
942+
// Arrange
943+
AssetLibrary assetLibrary = client.AssetLibrary();
944+
945+
// Act
946+
var result = assetLibrary
947+
.Where("file_name", "test-file_123.png")
948+
.Where("description", "File with special chars: @#$%");
949+
950+
// Assert
951+
Assert.NotNull(result);
952+
Assert.IsType<AssetLibrary>(result);
953+
}
664954
}
665955
}

0 commit comments

Comments
 (0)