Skip to content

Commit f76c8ab

Browse files
committed
Add tests for count string deserialization (fixes #35)
The API returns the count field as a JSON string instead of a number, causing JsonException on Lookup(), BulkLookup(), and Lookup(culture). Added test cases for both string and numeric count values, and updated the test fixture to include count as a string matching real API behavior. https://claude.ai/code/session_01V2uek6e28i6ARom7qVt1Mz
1 parent b702a97 commit f76c8ab

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

test/Unit/IPData.Tests/DataSources/TestData/IPLookupResult.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,6 @@
6767
"is_bogon": false,
6868
"blocklists": []
6969
},
70-
"status": 200
70+
"status": 200,
71+
"count": "213586"
7172
}

test/Unit/IPData.Tests/Http/Serializer/JsonSerializerTests.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,32 @@ public void Deserialize_WhenCalled_ReturnedIPLookupResult(string json)
2121
actual.Should().NotBeNull();
2222
}
2323

24+
[Fact]
25+
public void Deserialize_CountAsString_ParsedCorrectly()
26+
{
27+
// Arrange - API returns count as a string (issue #35)
28+
var json = "{\"count\": \"213586\"}";
29+
30+
// Act
31+
var actual = _sut.Deserialize<IPLookupResult>(json);
32+
33+
// Assert
34+
actual.Count.Should().Be(213586);
35+
}
36+
37+
[Fact]
38+
public void Deserialize_CountAsNumber_ParsedCorrectly()
39+
{
40+
// Arrange
41+
var json = "{\"count\": 213586}";
42+
43+
// Act
44+
var actual = _sut.Deserialize<IPLookupResult>(json);
45+
46+
// Assert
47+
actual.Count.Should().Be(213586);
48+
}
49+
2450
[Theory, AutoMoqData]
2551
public void SerializeIPLookupResult_WhenCalled_ReturnedString(IPLookupResult ipInfo)
2652
{

0 commit comments

Comments
 (0)