-
Notifications
You must be signed in to change notification settings - Fork 520
Open
Labels
Milestone
Description
SteamKit doesn't seem to offer any options for testing of consuming code. Given that this library hits the network, it's important to be able to mock away that behavior. I'm finding that I have to write a lot of wrapper types since most types aren't mockable. Take for example:
sealed class SteamUserStatsAdapter : ISteamUserStats
{
public SteamUserStatsAdapter(SteamUserStats steamUserStats)
{
this.steamUserStats = steamUserStats ?? throw new ArgumentNullException(nameof(steamUserStats), $"{nameof(steamUserStats)} is null.");
}
readonly SteamUserStats steamUserStats;
public IAsyncJob<LeaderboardEntriesCallback> GetLeaderboardEntries(uint appId, int id, int rangeStart, int rangeEnd, ELeaderboardDataRequest dataRequest)
{
var asyncJob = steamUserStats.GetLeaderboardEntries(appId, id, rangeStart, rangeEnd, dataRequest);
return new AsyncJobAdapter<LeaderboardEntriesCallback>(asyncJob);
}
}
public interface ISteamUserStats
{
IAsyncJob<LeaderboardEntriesCallback> GetLeaderboardEntries(uint appId, int id, int rangeStart, int rangeEnd, ELeaderboardDataRequest dataRequest);
}
SteamUserStatsAdapter
and ISteamUserStats
makes it possible for me to test code that consumes SteamUserStats
. However, this pattern results in 2 additional types for each type I use.
Could representative interfaces be added for SteamKit types so that they become mockable? I realize it'd be a breaking change but it'd vastly improve testability.