-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: taxonomy implementation with test cases
- Loading branch information
Showing
5 changed files
with
407 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
using System; | ||
using Xunit; | ||
using Contentstack.Core; | ||
using Contentstack.Core.Configuration; | ||
using Contentstack.Core.Models; | ||
using System.Threading.Tasks; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Contentstack.Core.Tests.Models; | ||
using Newtonsoft.Json.Linq; | ||
using System.Reflection.PortableExecutable; | ||
|
||
namespace Contentstack.Core.Tests | ||
{ | ||
|
||
public class TaxonomyTest | ||
{ | ||
ContentstackClient client = StackConfig.GetStack(); | ||
|
||
private String numbersContentType = "numbers_content_type"; | ||
String source = "source"; | ||
|
||
public double EPSILON { get; private set; } | ||
|
||
[Fact] | ||
|
||
public async Task GetEntriesWithAnyTaxonomyTerms() | ||
{ | ||
Taxonomy query = client.Taxonomies(); | ||
query.Exists("taxonomies.one"); | ||
var result = await query.Find<Entry>(); | ||
if (result == null && result.Items.Count() == 0) | ||
{ | ||
Assert.False(true, "Query.Exec is not match with expected result."); | ||
} | ||
else if (result != null) | ||
{ | ||
bool IsTrue = false; | ||
foreach (Entry data in result.Items) | ||
{ | ||
IsTrue = data.GetContentType() != null; | ||
if (!IsTrue) | ||
{ | ||
break; | ||
} | ||
} | ||
Assert.True(IsTrue); | ||
} | ||
else | ||
{ | ||
Assert.False(true, "Result doesn't mathced the count."); | ||
} | ||
} | ||
|
||
[Fact] | ||
public async Task GetEntriesWithTaxonomyTermsandAlsoMatchingItsChildrenTerm() | ||
{ | ||
Taxonomy query = client.Taxonomies(); | ||
query.EqualAndBelow("taxonomies.one", "term_one"); | ||
var result = await query.Find<Entry>(); | ||
if (result == null && result.Items.Count() == 0) | ||
{ | ||
Assert.False(true, "Query.Exec is not match with expected result."); | ||
} | ||
else if (result != null) | ||
{ | ||
bool IsTrue = false; | ||
foreach (Entry data in result.Items) | ||
{ | ||
IsTrue = data.GetContentType() != null; | ||
if (!IsTrue) | ||
{ | ||
break; | ||
} | ||
} | ||
Assert.True(IsTrue); | ||
} | ||
else | ||
{ | ||
Assert.False(true, "Result doesn't mathced the count."); | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
This file contains 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
This file contains 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
Oops, something went wrong.