feat: Add full Taxonomy and Terms API to .NET CMA SDK#138
Open
OMpawar-21 wants to merge 2 commits intofix/test-casesfrom
Open
feat: Add full Taxonomy and Terms API to .NET CMA SDK#138OMpawar-21 wants to merge 2 commits intofix/test-casesfrom
OMpawar-21 wants to merge 2 commits intofix/test-casesfrom
Conversation
- Add Taxonomy and Term support to match the JavaScript CMA SDK. Models: - TaxonomyModel, TermModel (with TermAncestorDescendant, TermMoveModel), TaxonomyImportModel (IUploadInterface for multipart import). Taxonomy: - CRUD, Query(), Export(), Locales(), Localize(), Import(), Terms(termUid). - Stack.Taxonomy(uid) entry point. Term: - CRUD, Query(), Ancestors(), Descendants(), Move(), Locales(), Localize(), Search(typeahead). - Accessed via Stack.Taxonomy(taxonomyUid).Terms() / .Terms(termUid). Services: - Reuse CreateUpdateService, FetchDeleteService, QueryService; extend UploadService with optional query params for Import. Tests: - Unit: TaxonomyTest, TermTest (20 tests). Integration: Contentstack017_TaxonomyTest (create, fetch, query, update, delete). Use static taxonomy UID in integration test so all steps use the same created taxonomy.
cs-raj
approved these changes
Mar 10, 2026
sunil-lakshman
approved these changes
Mar 10, 2026
cs-raj
requested changes
Mar 10, 2026
Contentstack.Management.Core.Tests/IntegrationTest/Contentstack017_TaxonomyTest.cs
Show resolved
Hide resolved
cs-raj
reviewed
Mar 10, 2026
Comment on lines
+111
to
+124
| public void Test007_Should_Throw_When_Fetch_NonExistent_Taxonomy() | ||
| { | ||
| Assert.ThrowsException<ContentstackErrorException>(() => | ||
| _stack.Taxonomy("non_existent_taxonomy_uid_12345").Fetch()); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| [DoNotParallelize] | ||
| public void Test008_Should_Throw_When_Delete_NonExistent_Taxonomy() | ||
| { | ||
| Assert.ThrowsException<ContentstackErrorException>(() => | ||
| _stack.Taxonomy("non_existent_taxonomy_uid_12345").Delete()); | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
Tests for the create, update, query should be added that should throw error should be added.
Same tests we have to cover for the locales and localize.
Along with sync methods we should also cover the async methods as well
cc: @netrajpatel
| namespace Contentstack.Management.Core.Tests.IntegrationTest | ||
| { | ||
| [TestClass] | ||
| public class Contentstack017_TaxonomyTest |
Contributor
There was a problem hiding this comment.
Here the tests for the terms are not added. Make sure to cover all the methods for the terms as well.
Cleanup functions should also be added once the tests are cleared to cleanup the test data.
cc: @netrajpatel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the full Taxonomy and Terms API in the .NET Contentstack Management SDK to align with the JavaScript CMA SDK. Supports managing taxonomies and their terms (CRUD, export, locales, localize, import; term hierarchy, move, search).
Changes
New Models
TaxonomyModel.csTermModel.csTaxonomyImportModel.csIUploadInterfacefor taxonomy import (multipart form key"taxonomy"; file path or Stream + filename)Taxonomy API (
Taxonomy.cs)BaseModel<TaxonomyModel>withresourcePath/taxonomiesor/taxonomies/{uid},fieldName"taxonomy".ParameterCollection).Query()returnsQueryfor listing taxonomies.{resourcePath}/export(sync/async).{resourcePath}/locales(sync/async).{ taxonomy: model }and query params (sync/async)./taxonomies/importviaUploadServicewithTaxonomyImportModel(sync/async).Terms(termUid = null)returnsTerm(requires taxonomy Uid; used for single term or term collection).Term API (
Term.cs)BaseModel<TermModel>withresourcePath/taxonomies/{taxonomyUid}/termsor.../terms/{termUid},fieldName"term".Query()for listing terms (when no term Uid)..../ancestorsand.../descendants(sync/async)..../movewithTermMoveModel(sync/async)..../locales(sync/async).{ term: model }and query params (sync/async)./taxonomies/$all/termswithtypeaheadquery param (sync/async; only when no term Uid).Stack Entry Point
Stack.cs:public Taxonomy Taxonomy(string uid = null)withThrowIfNotLoggedInandThrowIfAPIKeyEmpty; XML docs and example.Services
UploadService.cs: OptionalParameterCollectionfor query string on upload (used by Taxonomy Import).Unit Tests
TaxonomyTest.cs– Init (no uid / with uid), Create, Query, Fetch, Get Terms collection, Get single Term (10 tests).TermTest.cs– Init collection / with uid, Create, Query, Fetch, Search (10 tests)._stack.Taxonomy()/_stack.Taxonomy(uid)and_stack.Taxonomy(taxonomyUid).Terms()/.Terms(termUid); mock client andMockResponse.txt.Integration Tests
Contentstack017_TaxonomyTest.cs– Create, Fetch, Query, Update, FetchAsync, Delete (6 tests,[DoNotParallelize]).Models.cs(Tests): TaxonomyResponseModel and TaxonomiesResponseModel for API response parsing.statictaxonomy UID so the same taxonomy created in Test001 is used by Fetch/Update/Delete tests (avoidsContentstackErrorExceptionfrom operating on non-existent UIDs).Testing
Files Changed
Contentstack.Management.Core/Models/TaxonomyModel.csContentstack.Management.Core/Models/TermModel.csContentstack.Management.Core/Models/TaxonomyImportModel.csContentstack.Management.Core/Models/Taxonomy.csContentstack.Management.Core/Models/Term.csContentstack.Management.Core/Models/Stack.csContentstack.Management.Core/Services/Models/UploadService.csContentstack.Management.Core.Unit.Tests/Models/TaxonomyTest.csContentstack.Management.Core.Unit.Tests/Models/TermTest.csContentstack.Management.Core.Tests/IntegrationTest/Contentstack017_TaxonomyTest.csContentstack.Management.Core.Tests/Model/Models.cs