-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Road to 100% endpoint test coverage (Part 1/?) (#202)
This PR adds 100% test coverage for LeaderboardEndpoints
- Loading branch information
Showing
5 changed files
with
317 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.Xml; | ||
using System.Xml.Serialization; | ||
|
||
namespace RefreshTests.GameServer; | ||
|
||
public static class HttpContentExtensions | ||
{ | ||
public async static Task<T> ReadAsXML<T>(this HttpContent content) | ||
{ | ||
XmlSerializer serializer = new(typeof(T)); | ||
|
||
return (T)serializer.Deserialize(new XmlTextReader(await content.ReadAsStreamAsync()))!; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.Xml.Serialization; | ||
|
||
namespace RefreshTests.GameServer; | ||
|
||
public static class ObjectExtensions | ||
{ | ||
public static string AsXML(this object obj) | ||
{ | ||
XmlSerializer serializer = new(obj.GetType()); | ||
|
||
TextWriter writer = new StringWriter(); | ||
serializer.Serialize(writer, obj); | ||
|
||
return writer.ToString()!; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters