You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: improve array validation in integration test assertions
- Add support for string[], int[], bool[] typed arrays in test assertions
- Extract array validation logic into ValidateArrayAttribute helper method
- Handle JArray deserialization from JSON properly
- Improve error messages with type information
- Add regular attributes to empty array test endpoints to ensure transaction capture
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: tests/Agent/IntegrationTests/Applications/AspNetCoreWebApiCustomAttributesApplication/Controllers/AttributeTestingController.cs
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -73,6 +73,10 @@ public string CustomArrayAttributes()
73
73
[Route("api/CustomEmptyArrayAttributes")]
74
74
publicstringCustomEmptyArrayAttributes()
75
75
{
76
+
// Add a regular attribute to ensure transaction gets traced
thrownewNotImplementedException("Attribute handling for your type has not yet been implemented. The method only supports strings and bools. Update to add your type!");
builder.AppendFormat("Attribute named {0} in the {3} had an unexpected value. Expected: array [{1}], Actual: {2}",expectedAttribute.Key,string.Join(", ",expectedArray),rawActualValue,wireModelTypeName);
builder.AppendFormat("Attribute named {0} in the {3} had an unexpected array length. Expected: {1}, Actual: {2}",expectedAttribute.Key,expectedArray.Length,actualValue.Length,wireModelTypeName);
1098
-
builder.AppendLine();
1099
-
succeeded=false;
1161
+
elementsEqual=expectedLong==actualInt;
1100
1162
}
1101
1163
else
1102
1164
{
1103
-
// Compare array elements
1104
-
for(inti=0;i<expectedArray.Length;i++)
1105
-
{
1106
-
if(!Equals(expectedArray[i],actualValue[i]))
1107
-
{
1108
-
builder.AppendFormat("Attribute named {0} in the {3} had an unexpected value at index {4}. Expected: {1}, Actual: {2}",expectedAttribute.Key,expectedArray[i],actualValue[i],wireModelTypeName,i);
thrownewNotImplementedException("Attribute handling for your type has not yet been implemented. The method only supports strings and bools. Update to add your type!");
0 commit comments