Improvment for your tests
I've added IGameClient
for GameClient
.
This is necessary so that you can write tests, like this
public static class TestExtensions
{
private static readonly ObjectSerializer serializer = new();
public static Task<ServerResponse<T>> AsSuccessResponse<T>(this T value) where T : IGameObject
{
var data = serializer.Encode(value).ToString();
return Task.FromResult(new ServerResponse<T>(HttpStatusCode.OK, data));
}
}
public class Tests
{
public void MyFavoriteTest()
{
var gameClient = A.Fake<IGameClient>();
A.CallTo(() => gameClient.LoginAsync("test", "123")).Returns(new LoginResponse()
{
AccountId = 111,
UserId = 333
}.AsSuccessResponse());
}
}
A.Fake
it is FakeItEasy library, see documentation if you are interested