Skip to content

Commit e58891d

Browse files
committed
test: adds test cases for other functions
1 parent a7c9a57 commit e58891d

File tree

1 file changed

+98
-6
lines changed

1 file changed

+98
-6
lines changed

Contentstack.Core.Tests/TaxonomyTest.cs

Lines changed: 98 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@ public class TaxonomyTest
2424

2525
[Fact]
2626

27-
public async Task GetEntriesWithAnyTaxonomyTerms()
27+
public async Task TaxonomyExists()
2828
{
29+
// Description: Taxonomy Exists - Get Entries With Any Taxonomy Terms ($exists)
2930
Taxonomy query = client.Taxonomies();
3031
query.Exists("taxonomies.one");
3132
var result = await query.Find<Entry>();
3233
if (result == null && result.Items.Count() == 0)
3334
{
34-
Assert.False(true, "Query.Exec is not match with expected result.");
35+
Assert.Fail("Query.Exec is not match with expected result.");
3536
}
3637
else if (result != null)
3738
{
@@ -48,19 +49,20 @@ public async Task GetEntriesWithAnyTaxonomyTerms()
4849
}
4950
else
5051
{
51-
Assert.False(true, "Result doesn't mathced the count.");
52+
Assert.Fail("Result doesn't mathced the count.");
5253
}
5354
}
5455

5556
[Fact]
56-
public async Task GetEntriesWithTaxonomyTermsandAlsoMatchingItsChildrenTerm()
57+
public async Task TaxonomyEqualAndBelow()
5758
{
59+
// Description: Taxonomy EqualAndBelow - Get Entries With Taxonomy Terms and Also Matching Its Children Term ($eq_below, level)
5860
Taxonomy query = client.Taxonomies();
5961
query.EqualAndBelow("taxonomies.one", "term_one");
6062
var result = await query.Find<Entry>();
6163
if (result == null && result.Items.Count() == 0)
6264
{
63-
Assert.False(true, "Query.Exec is not match with expected result.");
65+
Assert.Fail("Query.Exec is not match with expected result.");
6466
}
6567
else if (result != null)
6668
{
@@ -77,7 +79,97 @@ public async Task GetEntriesWithTaxonomyTermsandAlsoMatchingItsChildrenTerm()
7779
}
7880
else
7981
{
80-
Assert.False(true, "Result doesn't mathced the count.");
82+
Assert.Fail("Result doesn't mathced the count.");
83+
}
84+
}
85+
86+
[Fact]
87+
public async Task TaxonomyBelow()
88+
{
89+
// Description: Taxonomy Below - Get Entries With Taxonomy Terms Children\'s and Excluding the term itself ($below, level)
90+
Taxonomy query = client.Taxonomies();
91+
query.Below("taxonomies.one", "term_one");
92+
var result = await query.Find<Entry>();
93+
if (result == null && result.Items.Count() == 0)
94+
{
95+
Assert.Fail("Query.Exec is not match with expected result.");
96+
}
97+
else if (result != null)
98+
{
99+
bool IsTrue = false;
100+
foreach (Entry data in result.Items)
101+
{
102+
IsTrue = data.GetContentType() != null;
103+
if (!IsTrue)
104+
{
105+
break;
106+
}
107+
}
108+
Assert.True(IsTrue);
109+
}
110+
else
111+
{
112+
Assert.Fail("Result doesn't mathced the count.");
113+
}
114+
}
115+
116+
[Fact]
117+
public async Task TaxonomyEqualAndAbove()
118+
{
119+
// Description: Taxonomy EqualAndAbove - Get Entries With Taxonomy Terms and Also Matching Its Parent Term ($eq_above, level)
120+
Taxonomy query = client.Taxonomies();
121+
query.EqualAndAbove("taxonomies.one", "term_one");
122+
var result = await query.Find<Entry>();
123+
if (result == null && result.Items.Count() == 0)
124+
{
125+
Assert.Fail("Query.Exec is not match with expected result.");
126+
}
127+
else if (result != null)
128+
{
129+
bool IsTrue = false;
130+
foreach (Entry data in result.Items)
131+
{
132+
IsTrue = data.GetContentType() != null;
133+
if (!IsTrue)
134+
{
135+
break;
136+
}
137+
}
138+
Assert.True(IsTrue);
139+
}
140+
else
141+
{
142+
Assert.Fail("Result doesn't mathced the count.");
143+
}
144+
}
145+
146+
[Fact]
147+
public async Task TaxonomyAbove()
148+
{
149+
// Description: Taxonomy Above - Get Entries With Taxonomy Terms Parent and Excluding the term itself ($above, level)
150+
Taxonomy query = client.Taxonomies();
151+
query.Above("taxonomies.one", "term_one");
152+
var result = await query.Find<Entry>();
153+
if (result == null && result.Items.Count() == 0)
154+
{
155+
Assert.Fail("Query.Exec is not match with expected result.");
156+
}
157+
else if (result != null)
158+
{
159+
bool IsTrue = false;
160+
foreach (Entry data in result.Items)
161+
{
162+
IsTrue = data.GetContentType() != null;
163+
if (!IsTrue)
164+
{
165+
break;
166+
}
167+
}
168+
Assert.True(IsTrue);
169+
}
170+
else
171+
{
172+
Assert.Fail("Result doesn't mathced the count.");
81173
}
82174
}
83175

0 commit comments

Comments
 (0)