Skip to content

Commit 26ada7e

Browse files
committed
fix: Added fix for failed test cases
1 parent 885e064 commit 26ada7e

6 files changed

Lines changed: 39 additions & 38 deletions

Contentstack.Management.Core.Tests/IntegrationTest/Contentstack011_GlobalFieldTest.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ public void Test029_Should_Fail_Fetch_With_Empty_UID()
689689
{
690690
TestOutputLogger.LogContext("TestScenario", "FetchGlobalField_EmptyUID");
691691

692-
AssertLogger.ThrowsException<InvalidOperationException>(
692+
AssertLogger.ThrowsException<ArgumentException>(
693693
() => _stack.GlobalField("").Fetch(),
694694
"FetchEmptyUID");
695695
}
@@ -700,7 +700,7 @@ public void Test030_Should_Fail_Update_With_Empty_UID()
700700
{
701701
TestOutputLogger.LogContext("TestScenario", "UpdateGlobalField_EmptyUID");
702702

703-
AssertLogger.ThrowsException<InvalidOperationException>(
703+
AssertLogger.ThrowsException<ArgumentException>(
704704
() => _stack.GlobalField("").Update(_modelling),
705705
"UpdateEmptyUID");
706706
}
@@ -711,7 +711,7 @@ public void Test031_Should_Fail_Delete_With_Empty_UID()
711711
{
712712
TestOutputLogger.LogContext("TestScenario", "DeleteGlobalField_EmptyUID");
713713

714-
AssertLogger.ThrowsException<InvalidOperationException>(
714+
AssertLogger.ThrowsException<ArgumentException>(
715715
() => _stack.GlobalField("").Delete(),
716716
"DeleteEmptyUID");
717717
}
@@ -871,9 +871,9 @@ public async System.Threading.Tasks.Task Test042_Should_Fail_Fetch_Async_With_Em
871871
try
872872
{
873873
await _stack.GlobalField("").FetchAsync();
874-
AssertLogger.Fail("Expected InvalidOperationException for empty UID");
874+
AssertLogger.Fail("Expected ArgumentException for empty UID");
875875
}
876-
catch (InvalidOperationException)
876+
catch (ArgumentException)
877877
{
878878
// Expected exception - test passes
879879
}
@@ -888,9 +888,9 @@ public async System.Threading.Tasks.Task Test043_Should_Fail_Update_Async_With_E
888888
try
889889
{
890890
await _stack.GlobalField("").UpdateAsync(_modelling);
891-
AssertLogger.Fail("Expected InvalidOperationException for empty UID");
891+
AssertLogger.Fail("Expected ArgumentException for empty UID");
892892
}
893-
catch (InvalidOperationException)
893+
catch (ArgumentException)
894894
{
895895
// Expected exception - test passes
896896
}
@@ -905,9 +905,9 @@ public async System.Threading.Tasks.Task Test044_Should_Fail_Delete_Async_With_E
905905
try
906906
{
907907
await _stack.GlobalField("").DeleteAsync();
908-
AssertLogger.Fail("Expected InvalidOperationException for empty UID");
908+
AssertLogger.Fail("Expected ArgumentException for empty UID");
909909
}
910-
catch (InvalidOperationException)
910+
catch (ArgumentException)
911911
{
912912
// Expected exception - test passes
913913
}

Contentstack.Management.Core.Tests/IntegrationTest/Contentstack012_ContentTypeTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public void Test012_Should_Throw_When_Fetch_Without_UID()
244244
{
245245
TestOutputLogger.LogContext("TestScenario", "FetchContentType_NoUID");
246246

247-
AssertLogger.ThrowsException<InvalidOperationException>(
247+
AssertLogger.ThrowsException<ArgumentException>(
248248
() => _stack.ContentType().Fetch(),
249249
"Fetch_NoUID");
250250
}
@@ -255,7 +255,7 @@ public async Task Test013_Should_Throw_When_FetchAsync_Without_UID()
255255
{
256256
TestOutputLogger.LogContext("TestScenario", "FetchAsyncContentType_NoUID");
257257

258-
await AssertLogger.ThrowsExceptionAsync<InvalidOperationException>(
258+
await AssertLogger.ThrowsExceptionAsync<ArgumentException>(
259259
() => _stack.ContentType().FetchAsync(),
260260
"FetchAsync_NoUID");
261261
}
@@ -268,7 +268,7 @@ public void Test014_Should_Throw_When_Update_Without_UID()
268268

269269
var model = CreateValidContentTypeModel("update_no_uid");
270270

271-
AssertLogger.ThrowsException<InvalidOperationException>(
271+
AssertLogger.ThrowsException<ArgumentException>(
272272
() => _stack.ContentType().Update(model),
273273
"Update_NoUID");
274274
}
@@ -290,7 +290,7 @@ public void Test016_Should_Throw_When_Delete_Without_UID()
290290
{
291291
TestOutputLogger.LogContext("TestScenario", "DeleteContentType_NoUID");
292292

293-
AssertLogger.ThrowsException<InvalidOperationException>(
293+
AssertLogger.ThrowsException<ArgumentException>(
294294
() => _stack.ContentType().Delete(),
295295
"Delete_NoUID");
296296
}

Contentstack.Management.Core.Tests/IntegrationTest/Contentstack012_NestedGlobalFieldTest.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,9 +1317,9 @@ public void Test028_Should_Fail_Fetch_With_Empty_UID()
13171317
{
13181318
TestOutputLogger.LogContext("TestScenario", "FetchNestedGlobalField_EmptyUID");
13191319

1320-
Assert.ThrowsException<InvalidOperationException>(
1320+
Assert.ThrowsException<ArgumentException>(
13211321
() => _stack.GlobalField("").Fetch(),
1322-
"Expected InvalidOperationException for empty UID");
1322+
"Expected ArgumentException for empty UID");
13231323
}
13241324

13251325
[TestMethod]
@@ -1329,9 +1329,9 @@ public void Test029_Should_Fail_Update_With_Empty_UID()
13291329
TestOutputLogger.LogContext("TestScenario", "UpdateNestedGlobalField_EmptyUID");
13301330
var updateModel = CreateNestedGlobalFieldModel();
13311331

1332-
Assert.ThrowsException<InvalidOperationException>(
1332+
Assert.ThrowsException<ArgumentException>(
13331333
() => _stack.GlobalField("").Update(updateModel),
1334-
"Expected InvalidOperationException for empty UID");
1334+
"Expected ArgumentException for empty UID");
13351335
}
13361336

13371337
[TestMethod]
@@ -1340,9 +1340,9 @@ public void Test030_Should_Fail_Delete_With_Empty_UID()
13401340
{
13411341
TestOutputLogger.LogContext("TestScenario", "DeleteNestedGlobalField_EmptyUID");
13421342

1343-
Assert.ThrowsException<InvalidOperationException>(
1343+
Assert.ThrowsException<ArgumentException>(
13441344
() => _stack.GlobalField("").Delete(),
1345-
"Expected InvalidOperationException for empty UID");
1345+
"Expected ArgumentException for empty UID");
13461346
}
13471347

13481348
[TestMethod]
@@ -1468,9 +1468,9 @@ public async Task Test038_Should_Fail_Fetch_Async_With_Empty_UID()
14681468
try
14691469
{
14701470
await _stack.GlobalField("").FetchAsync();
1471-
Assert.Fail("Expected InvalidOperationException for empty UID");
1471+
Assert.Fail("Expected ArgumentException for empty UID");
14721472
}
1473-
catch (InvalidOperationException)
1473+
catch (ArgumentException)
14741474
{
14751475
// Expected exception - test passes
14761476
}
@@ -1485,9 +1485,9 @@ public async Task Test039_Should_Fail_Delete_Async_With_Empty_UID()
14851485
try
14861486
{
14871487
await _stack.GlobalField("").DeleteAsync();
1488-
Assert.Fail("Expected InvalidOperationException for empty UID");
1488+
Assert.Fail("Expected ArgumentException for empty UID");
14891489
}
1490-
catch (InvalidOperationException)
1490+
catch (ArgumentException)
14911491
{
14921492
// Expected exception - test passes
14931493
}

Contentstack.Management.Core.Tests/IntegrationTest/Contentstack014_EntryTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,10 @@ private static void AssertAuthenticationError(Exception ex, string assertionName
9797
AssertLogger.IsTrue(
9898
cex.StatusCode == HttpStatusCode.Unauthorized ||
9999
cex.StatusCode == HttpStatusCode.Forbidden ||
100+
cex.StatusCode == HttpStatusCode.BadRequest || // API returns 400 for malformed tokens
100101
cex.StatusCode == HttpStatusCode.PreconditionFailed ||
101102
cex.StatusCode == (HttpStatusCode)422, // API treats not found as auth failure
102-
$"Expected 401/403/412/422 for auth error, got {(int)cex.StatusCode} ({cex.StatusCode})",
103+
$"Expected 400/401/403/412/422 for auth error, got {(int)cex.StatusCode} ({cex.StatusCode})",
103104
assertionName);
104105
}
105106
else if (ex is InvalidOperationException && ex.Message.Contains("not logged in"))

Contentstack.Management.Core.Tests/IntegrationTest/Contentstack018_EnvironmentTest.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ await AssertLogger.ThrowsContentstackErrorAsync(
10131013
public void Test044_Should_Fail_With_Null_Environment_UID_Sync()
10141014
{
10151015
TestOutputLogger.LogContext("TestScenario", "Test044_Should_Fail_With_Null_Environment_UID_Sync");
1016-
AssertLogger.ThrowsException<InvalidOperationException>(
1016+
AssertLogger.ThrowsException<ArgumentException>(
10171017
() => _stack.Environment(null).Fetch(),
10181018
"FetchNullUidSync");
10191019
}
@@ -1022,7 +1022,7 @@ public void Test044_Should_Fail_With_Null_Environment_UID_Sync()
10221022
public void Test045_Should_Fail_With_Empty_Environment_UID_Sync()
10231023
{
10241024
TestOutputLogger.LogContext("TestScenario", "Test045_Should_Fail_With_Empty_Environment_UID_Sync");
1025-
AssertLogger.ThrowsException<InvalidOperationException>(
1025+
AssertLogger.ThrowsException<ArgumentException>(
10261026
() => _stack.Environment("").Fetch(),
10271027
"FetchEmptyUidSync");
10281028
}
@@ -1123,15 +1123,15 @@ public async Task Test050_Should_Fail_With_Null_Environment_UID_Async()
11231123
try
11241124
{
11251125
await _stack.Environment(null).FetchAsync();
1126-
AssertLogger.Fail("Expected InvalidOperationException for null UID");
1126+
AssertLogger.Fail("Expected ArgumentException for null UID");
11271127
}
1128-
catch (InvalidOperationException)
1128+
catch (ArgumentException)
11291129
{
1130-
AssertLogger.IsTrue(true, "InvalidOperationException thrown as expected", "FetchNullUidAsync");
1130+
AssertLogger.IsTrue(true, "ArgumentException thrown as expected", "FetchNullUidAsync");
11311131
}
11321132
catch (Exception ex)
11331133
{
1134-
AssertLogger.Fail($"Expected InvalidOperationException but got {ex.GetType().Name}");
1134+
AssertLogger.Fail($"Expected ArgumentException but got {ex.GetType().Name}");
11351135
}
11361136
}
11371137

@@ -1142,15 +1142,15 @@ public async Task Test051_Should_Fail_With_Empty_Environment_UID_Async()
11421142
try
11431143
{
11441144
await _stack.Environment("").FetchAsync();
1145-
AssertLogger.Fail("Expected InvalidOperationException for empty UID");
1145+
AssertLogger.Fail("Expected ArgumentException for empty UID");
11461146
}
1147-
catch (InvalidOperationException)
1147+
catch (ArgumentException)
11481148
{
1149-
AssertLogger.IsTrue(true, "InvalidOperationException thrown as expected", "FetchEmptyUidAsync");
1149+
AssertLogger.IsTrue(true, "ArgumentException thrown as expected", "FetchEmptyUidAsync");
11501150
}
11511151
catch (Exception ex)
11521152
{
1153-
AssertLogger.Fail($"Expected InvalidOperationException but got {ex.GetType().Name}");
1153+
AssertLogger.Fail($"Expected ArgumentException but got {ex.GetType().Name}");
11541154
}
11551155
}
11561156

Contentstack.Management.Core.Tests/IntegrationTest/Contentstack020_WorkflowTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3151,7 +3151,7 @@ public void Test141_Should_Fail_With_Null_Workflow_UID_Parameter()
31513151
try
31523152
{
31533153
// Act & Assert - SDK should validate UID before API call
3154-
AssertLogger.ThrowsException<InvalidOperationException>(() =>
3154+
AssertLogger.ThrowsException<ArgumentException>(() =>
31553155
{
31563156
_stack.Workflow(null).Fetch();
31573157
}, "fetchWorkflowNullUID");
@@ -3160,7 +3160,7 @@ public void Test141_Should_Fail_With_Null_Workflow_UID_Parameter()
31603160
}
31613161
catch (Exception ex)
31623162
{
3163-
FailWithError("Expected InvalidOperationException for null workflow UID", ex);
3163+
FailWithError("Expected ArgumentException for null workflow UID", ex);
31643164
}
31653165
}
31663166

@@ -3172,7 +3172,7 @@ public void Test142_Should_Fail_With_Empty_Workflow_UID_Parameter()
31723172
try
31733173
{
31743174
// Act & Assert - SDK should validate UID before API call
3175-
AssertLogger.ThrowsException<InvalidOperationException>(() =>
3175+
AssertLogger.ThrowsException<ArgumentException>(() =>
31763176
{
31773177
_stack.Workflow("").Fetch();
31783178
}, "fetchWorkflowEmptyUID");
@@ -3181,7 +3181,7 @@ public void Test142_Should_Fail_With_Empty_Workflow_UID_Parameter()
31813181
}
31823182
catch (Exception ex)
31833183
{
3184-
FailWithError("Expected InvalidOperationException for empty workflow UID", ex);
3184+
FailWithError("Expected ArgumentException for empty workflow UID", ex);
31853185
}
31863186
}
31873187

0 commit comments

Comments
 (0)