Skip to content

Bug: Person mock serializes as empty JSON due to private properties #35

Description

@DaraOladapo

Description

The Person mock class used in all POST/PUT/PATCH tests declares its properties as private, so JsonConvert.SerializeObject(person) produces {} instead of a real payload. Every test that calls a write-method overload is silently sending an empty body.

Affected File

src/HttpClientServiceHelper.Tests/Mock/Person.cs

// Current — private properties are invisible to Newtonsoft.Json by default
private string FirstName { get; set; }
private string LastName { get; set; }
private string FullName => $"{FirstName} {LastName}";

// Fix — make them public
public string FirstName { get; set; }
public string LastName { get; set; }

Impact

Tests pass because they only assert NotNull and type — they never verify the request body. This masks the fact that POST/PUT/PATCH requests carry an empty payload in the test suite.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions