Skip to content

Commit e993a98

Browse files
committed
fix: Comprehensive Integration Test Suite
1 parent 2608820 commit e993a98

8 files changed

Lines changed: 513 additions & 734 deletions

File tree

.talismanrc

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
# Talisman configuration file
2-
# This file lists intentional patterns that Talisman should ignore
3-
# All entries below are FALSE POSITIVES verified by security audit
4-
51
fileignoreconfig:
6-
# Test files with TestDataHelper.ApiKey (loads from config, not hardcoded)
2+
- filename: Contentstack.Core.Tests/Integration/ConfigurationTests/RegionSupportTest.cs
3+
checksum: fd424a7595c59a0d5b48d317f70d9be2646e5b246bcae865c5de391701e8b1dd
74
- filename: Contentstack.Core.Tests/Integration/ModularBlocksTests/ModularBlocksComprehensiveTest.cs
85
checksum: 17a32d5d99819b4d00a6ab786484322640accc619936564e2fa5de060b2304d2
96
- filename: Contentstack.Core.Tests/Integration/PaginationTests/PaginationComprehensiveTest.cs
@@ -80,15 +77,10 @@ fileignoreconfig:
8077
checksum: 43aa302af75031f4621de1287dbcdaa63151659230f20a0a785cc0dd5be0e1c4
8178
- filename: Contentstack.Core.Tests/Integration/LivePreview/LivePreviewBasicTest.cs
8279
checksum: 01517f2224fbb2956d79292e6d3d23d1cc970dbfc190623496bcac1335bcd683
83-
84-
# Helper files (TestDataHelper loads from config, AssertionHelper has word "key" in comments)
8580
- filename: Contentstack.Core.Tests/Helpers/AssertionHelper.cs
8681
checksum: 17efa53b38647d0f0d98771a50ee6d44f17650745a60a5e8fdff086ac8ab7596
8782
- filename: Contentstack.Core.Tests/Helpers/TestDataHelper.cs
8883
checksum: 67c8afb436287676e0db3a62a9213d800239cf5bb543cc4d81f438655abf0e1f
89-
90-
# HTML report generator (Python script with variable names like "passed")
9184
- filename: Contentstack.Core.Tests/generate_html_report.py
9285
checksum: b4bec9ef853703e989b3d8077edc5c3ec6ea13a23826699d8beca5e87323e128
93-
9486
version: "1.0"

Contentstack.Core.Tests/ContentstackClientTest.cs renamed to Contentstack.Core.Tests/Integration/ClientTests/ContentstackClientTest.cs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
using Xunit;
77
using Contentstack.Core.Configuration;
88

9-
namespace Contentstack.Core.Tests
9+
namespace Contentstack.Core.Tests.Integration.ClientTests
1010
{
11+
[Trait("Category", "ClientInternal")]
1112
public class ContentstackClientTest
1213
{
1314
private ContentstackClient CreateClient()
@@ -37,15 +38,15 @@ private string GetPrivateField(ContentstackClient client, string fieldName)
3738
return (string)field.GetValue(client);
3839
}
3940

40-
[Fact]
41+
[Fact(DisplayName = "Set Entry Uid Sets Value When Non Empty")]
4142
public void SetEntryUid_SetsValue_WhenNonEmpty()
4243
{
4344
var client = CreateClient();
4445
client.SetEntryUid("entry123");
4546
Assert.Equal("entry123", GetPrivateField(client, "currentEntryUid"));
4647
}
4748

48-
[Fact]
49+
[Fact(DisplayName = "Set Entry Uid Does Not Set When Empty")]
4950
public void SetEntryUid_DoesNotSet_WhenEmpty()
5051
{
5152
var client = CreateClient();
@@ -54,7 +55,7 @@ public void SetEntryUid_DoesNotSet_WhenEmpty()
5455
Assert.Equal("entry123", GetPrivateField(client, "currentEntryUid"));
5556
}
5657

57-
[Fact]
58+
[Fact(DisplayName = "Set Entry Uid Does Not Set When Null")]
5859
public void SetEntryUid_DoesNotSet_WhenNull()
5960
{
6061
var client = CreateClient();
@@ -63,15 +64,15 @@ public void SetEntryUid_DoesNotSet_WhenNull()
6364
Assert.Equal("entry123", GetPrivateField(client, "currentEntryUid"));
6465
}
6566

66-
[Fact]
67+
[Fact(DisplayName = "Content Type Setscurrent Contenttype Uid When Non Empty")]
6768
public void ContentType_SetscurrentContenttypeUid_WhenNonEmpty()
6869
{
6970
var client = CreateClient();
7071
client.ContentType("blog");
7172
Assert.Equal("blog", GetPrivateField(client, "currentContenttypeUid"));
7273
}
7374

74-
[Fact]
75+
[Fact(DisplayName = "Content Type Does Not Set When Empty")]
7576
public void ContentType_DoesNotSet_WhenEmpty()
7677
{
7778
var client = CreateClient();
@@ -80,7 +81,7 @@ public void ContentType_DoesNotSet_WhenEmpty()
8081
Assert.Equal("blog", GetPrivateField(client, "currentContenttypeUid"));
8182
}
8283

83-
[Fact]
84+
[Fact(DisplayName = "Content Type Does Not Set When Null")]
8485
public void ContentType_DoesNotSet_WhenNull()
8586
{
8687
var client = CreateClient();
@@ -89,7 +90,7 @@ public void ContentType_DoesNotSet_WhenNull()
8990
Assert.Equal("blog", GetPrivateField(client, "currentContenttypeUid"));
9091
}
9192

92-
[Fact]
93+
[Fact(DisplayName = "Content Type Returns Content Type Instance")]
9394
public void ContentType_ReturnsContentTypeInstance()
9495
{
9596
var client = CreateClient();
@@ -98,7 +99,7 @@ public void ContentType_ReturnsContentTypeInstance()
9899
Assert.Equal("blog", contentType.ContentTypeId);
99100
}
100101

101-
[Fact]
102+
[Fact(DisplayName = "Global Field Returns Global Field Instance")]
102103
public void GlobalField_ReturnsGlobalFieldInstance()
103104
{
104105
var client = CreateClient();
@@ -107,7 +108,7 @@ public void GlobalField_ReturnsGlobalFieldInstance()
107108
Assert.Equal("author", globalField.GlobalFieldId);
108109
}
109110

110-
[Fact]
111+
[Fact(DisplayName = "Asset Returns Asset Instance")]
111112
public void Asset_ReturnsAssetInstance()
112113
{
113114
var client = CreateClient();
@@ -116,52 +117,52 @@ public void Asset_ReturnsAssetInstance()
116117
Assert.Equal("asset_uid", asset.Uid);
117118
}
118119

119-
[Fact]
120+
[Fact(DisplayName = "Asset Library Returns Asset Library Instance")]
120121
public void AssetLibrary_ReturnsAssetLibraryInstance()
121122
{
122123
var client = CreateClient();
123124
var assetLibrary = client.AssetLibrary();
124125
Assert.NotNull(assetLibrary);
125126
}
126127

127-
[Fact]
128+
[Fact(DisplayName = "Taxonomies Returns Taxonomy Instance")]
128129
public void Taxonomies_ReturnsTaxonomyInstance()
129130
{
130131
var client = CreateClient();
131132
var taxonomy = client.Taxonomies();
132133
Assert.NotNull(taxonomy);
133134
}
134135

135-
[Fact]
136+
[Fact(DisplayName = "Get Version Returns Version")]
136137
public void GetVersion_ReturnsVersion()
137138
{
138139
var client = CreateClient();
139140
var t = client.GetVersion();
140141
Assert.Equal("1.2.3", client.GetVersion());
141142
}
142143

143-
[Fact]
144+
[Fact(DisplayName = "Get Application Key Returns Api Key")]
144145
public void GetApplicationKey_ReturnsApiKey()
145146
{
146147
var client = CreateClient();
147148
Assert.Equal("api_key", client.GetApplicationKey());
148149
}
149150

150-
[Fact]
151+
[Fact(DisplayName = "Get Access Token Returns Delivery Token")]
151152
public void GetAccessToken_ReturnsDeliveryToken()
152153
{
153154
var client = CreateClient();
154155
Assert.Equal("delivery_token", client.GetAccessToken());
155156
}
156157

157-
[Fact]
158+
[Fact(DisplayName = "Get Live Preview Config Returns Config")]
158159
public void GetLivePreviewConfig_ReturnsConfig()
159160
{
160161
var client = CreateClient();
161162
Assert.NotNull(client.GetLivePreviewConfig());
162163
}
163164

164-
[Fact]
165+
[Fact(DisplayName = "Remove Header Removes Header")]
165166
public void RemoveHeader_RemovesHeader()
166167
{
167168
var client = CreateClient();
@@ -173,7 +174,7 @@ public void RemoveHeader_RemovesHeader()
173174
Assert.False(localHeaders.ContainsKey("custom"));
174175
}
175176

176-
[Fact]
177+
[Fact(DisplayName = "Set Header Adds Header")]
177178
public void SetHeader_AddsHeader()
178179
{
179180
var client = CreateClient();
@@ -185,7 +186,7 @@ public void SetHeader_AddsHeader()
185186
Assert.Equal("value", localHeaders["custom"]);
186187
}
187188

188-
[Fact]
189+
[Fact(DisplayName = "Live Preview Query Async Sets Live Preview Config Fields")]
189190
public async Task LivePreviewQueryAsync_SetsLivePreviewConfigFields()
190191
{
191192
var client = CreateClient();
@@ -218,21 +219,21 @@ public async Task LivePreviewQueryAsync_SetsLivePreviewConfigFields()
218219

219220
// For SyncRecursive, SyncPaginationToken, SyncToken, you should mock HTTP calls.
220221
// Here we just check that the methods exist and can be called (will throw if not configured).
221-
[Fact]
222+
[Fact(DisplayName = "Sync Recursive Throws Or Returns")]
222223
public async Task SyncRecursive_ThrowsOrReturns()
223224
{
224225
var client = CreateClient();
225226
await Assert.ThrowsAnyAsync<Exception>(() => client.SyncRecursive());
226227
}
227228

228-
[Fact]
229+
[Fact(DisplayName = "Sync Pagination Token Throws Or Returns")]
229230
public async Task SyncPaginationToken_ThrowsOrReturns()
230231
{
231232
var client = CreateClient();
232233
await Assert.ThrowsAnyAsync<Exception>(() => client.SyncPaginationToken("pagetoken"));
233234
}
234235

235-
[Fact]
236+
[Fact(DisplayName = "Sync Token Throws Or Returns")]
236237
public async Task SyncToken_ThrowsOrReturns()
237238
{
238239
var client = CreateClient();

Contentstack.Core.Tests/Integration/ConfigurationTests/RegionSupportTest.cs

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Threading.Tasks;
55
using Xunit;
66
using Contentstack.Core.Configuration;
7+
using Contentstack.Core.Internals;
78
using Contentstack.Core.Models;
89
using Contentstack.Core.Tests.Helpers;
910

@@ -211,6 +212,131 @@ public void Region_NullHost_ThrowsError()
211212

212213
#endregion
213214

215+
#region Region Enum and Options Tests (Merged from RegionHandlerTest.cs)
216+
217+
[Theory(DisplayName = "Region Configuration - Region Enum Values Are Correct")]
218+
[InlineData(ContentstackRegion.US, 0)]
219+
[InlineData(ContentstackRegion.EU, 1)]
220+
[InlineData(ContentstackRegion.AZURE_EU, 2)]
221+
[InlineData(ContentstackRegion.AZURE_NA, 3)]
222+
[InlineData(ContentstackRegion.GCP_NA, 4)]
223+
[InlineData(ContentstackRegion.AU, 5)]
224+
public void Region_EnumValues_AreCorrect(ContentstackRegion region, int expectedValue)
225+
{
226+
Assert.Equal(expectedValue, (int)region);
227+
}
228+
229+
[Fact(DisplayName = "Region Configuration - Region All Values Are Defined")]
230+
public void Region_AllValues_AreDefined()
231+
{
232+
var regions = Enum.GetValues<ContentstackRegion>();
233+
Assert.Equal(6, regions.Length);
234+
Assert.Contains(ContentstackRegion.US, regions);
235+
Assert.Contains(ContentstackRegion.EU, regions);
236+
Assert.Contains(ContentstackRegion.AZURE_EU, regions);
237+
Assert.Contains(ContentstackRegion.AZURE_NA, regions);
238+
Assert.Contains(ContentstackRegion.GCP_NA, regions);
239+
Assert.Contains(ContentstackRegion.AU, regions);
240+
}
241+
242+
[Fact(DisplayName = "Region Configuration - Region Options Default Value Is US")]
243+
public void Region_OptionsDefaultValue_IsUS()
244+
{
245+
var options = new ContentstackOptions();
246+
Assert.Equal(ContentstackRegion.US, options.Region);
247+
}
248+
249+
[Theory(DisplayName = "Region Configuration - Region Options Can Be Set")]
250+
[InlineData(ContentstackRegion.US)]
251+
[InlineData(ContentstackRegion.EU)]
252+
[InlineData(ContentstackRegion.AZURE_EU)]
253+
[InlineData(ContentstackRegion.AZURE_NA)]
254+
[InlineData(ContentstackRegion.GCP_NA)]
255+
[InlineData(ContentstackRegion.AU)]
256+
public void Region_OptionsCanBeSet(ContentstackRegion region)
257+
{
258+
var options = new ContentstackOptions();
259+
options.Region = region;
260+
Assert.Equal(region, options.Region);
261+
}
262+
263+
[Fact(DisplayName = "Region Configuration - Region Enum Can Be Parsed From String")]
264+
public void Region_EnumCanBeParsedFromString()
265+
{
266+
Assert.True(Enum.TryParse<ContentstackRegion>("US", out var usRegion));
267+
Assert.Equal(ContentstackRegion.US, usRegion);
268+
269+
Assert.True(Enum.TryParse<ContentstackRegion>("EU", out var euRegion));
270+
Assert.Equal(ContentstackRegion.EU, euRegion);
271+
272+
Assert.True(Enum.TryParse<ContentstackRegion>("AU", out var auRegion));
273+
Assert.Equal(ContentstackRegion.AU, auRegion);
274+
}
275+
276+
[Fact(DisplayName = "Region Configuration - Region Enum Case Insensitive Parse Works")]
277+
public void Region_EnumCaseInsensitiveParse_Works()
278+
{
279+
Assert.True(Enum.TryParse<ContentstackRegion>("us", true, out var usRegion));
280+
Assert.Equal(ContentstackRegion.US, usRegion);
281+
282+
Assert.True(Enum.TryParse<ContentstackRegion>("eu", true, out var euRegion));
283+
Assert.Equal(ContentstackRegion.EU, euRegion);
284+
285+
Assert.True(Enum.TryParse<ContentstackRegion>("au", true, out var auRegion));
286+
Assert.Equal(ContentstackRegion.AU, auRegion);
287+
}
288+
289+
[Fact(DisplayName = "Region Configuration - Region Enum Invalid String Returns False")]
290+
public void Region_EnumInvalidString_ReturnsFalse()
291+
{
292+
Assert.False(Enum.TryParse<ContentstackRegion>("INVALID", out var invalidRegion));
293+
Assert.Equal(default(ContentstackRegion), invalidRegion);
294+
}
295+
296+
[Fact(DisplayName = "Region Configuration - Region Options Can Be Changed After Creation")]
297+
public void Region_OptionsCanBeChangedAfterCreation()
298+
{
299+
var options = new ContentstackOptions
300+
{
301+
Region = ContentstackRegion.US
302+
};
303+
304+
Assert.Equal(ContentstackRegion.US, options.Region);
305+
306+
options.Region = ContentstackRegion.AU;
307+
Assert.Equal(ContentstackRegion.AU, options.Region);
308+
}
309+
310+
[Fact(DisplayName = "Region Configuration - Region Different Clients Have Different Regions")]
311+
public void Region_DifferentClients_HaveDifferentRegions()
312+
{
313+
var usOptions = new ContentstackOptions
314+
{
315+
ApiKey = TestDataHelper.ApiKey,
316+
DeliveryToken = TestDataHelper.DeliveryToken,
317+
Environment = TestDataHelper.Environment,
318+
Region = ContentstackRegion.US
319+
};
320+
321+
var auOptions = new ContentstackOptions
322+
{
323+
ApiKey = TestDataHelper.ApiKey,
324+
DeliveryToken = TestDataHelper.DeliveryToken,
325+
Environment = TestDataHelper.Environment,
326+
Region = ContentstackRegion.AU
327+
};
328+
329+
var usClient = new ContentstackClient(usOptions);
330+
var auClient = new ContentstackClient(auOptions);
331+
332+
// Both clients should be valid and different
333+
Assert.NotNull(usClient);
334+
Assert.NotNull(auClient);
335+
Assert.NotEqual(usClient, auClient);
336+
}
337+
338+
#endregion
339+
214340
#region Helper Methods
215341

216342
private ContentstackClient CreateClient(string host)

0 commit comments

Comments
 (0)