Skip to content

Commit cedca2c

Browse files
author
Justin Skiles
authored
Merge pull request #38 from babelshift/issue-36-http-response-headers
Issue 36 http response headers
2 parents a92fda5 + 23b0ae7 commit cedca2c

64 files changed

Lines changed: 1080 additions & 572 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

SteamWebAPI2.Net451/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("3.0.0.0")]
35+
[assembly: AssemblyVersion("3.1.0.0")]
3636
[assembly: AssemblyFileVersion("3.0.0.0")]

SteamWebAPI2.Net451/SteamWebAPI2.Net451.csproj

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@
3131
<WarningLevel>4</WarningLevel>
3232
</PropertyGroup>
3333
<ItemGroup>
34-
<Reference Include="AutoMapper, Version=4.2.1.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
35-
<HintPath>..\packages\AutoMapper.4.2.1\lib\net45\AutoMapper.dll</HintPath>
34+
<Reference Include="AutoMapper, Version=5.2.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
35+
<HintPath>..\packages\AutoMapper.5.2.0\lib\net45\AutoMapper.dll</HintPath>
3636
<Private>True</Private>
3737
</Reference>
3838
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
3939
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
4040
<Private>True</Private>
4141
</Reference>
42-
<Reference Include="Steam.Models, Version=2.0.0.2, Culture=neutral, processorArchitecture=MSIL">
43-
<HintPath>..\packages\Steam.Models.2.0.0.2\lib\net451\Steam.Models.dll</HintPath>
42+
<Reference Include="Steam.Models, Version=2.0.0.3, Culture=neutral, processorArchitecture=MSIL">
43+
<HintPath>..\packages\Steam.Models.2.0.0.3\lib\net451\Steam.Models.dll</HintPath>
4444
<Private>True</Private>
4545
</Reference>
4646
<Reference Include="System" />
@@ -378,6 +378,9 @@
378378
<Compile Include="..\SteamWebAPI2\Utilities\ISteamWebRequest.cs">
379379
<Link>Utilities\ISteamWebRequest.cs</Link>
380380
</Compile>
381+
<Compile Include="..\SteamWebAPI2\Utilities\ISteamWebResponse.cs">
382+
<Link>Utilities\ISteamWebResponse.cs</Link>
383+
</Compile>
381384
<Compile Include="..\SteamWebAPI2\Utilities\JsonConverters\AssetClassInfoJsonConverter.cs">
382385
<Link>Utilities\JsonConverters\AssetClassInfoJsonConverter.cs</Link>
383386
</Compile>
@@ -411,6 +414,9 @@
411414
<Compile Include="..\SteamWebAPI2\Utilities\SteamWebRequestParameterExtensions.cs">
412415
<Link>Utilities\SteamWebRequestParameterExtensions.cs</Link>
413416
</Compile>
417+
<Compile Include="..\SteamWebAPI2\Utilities\SteamWebResponse.cs">
418+
<Link>Utilities\SteamWebResponse.cs</Link>
419+
</Compile>
414420
<Compile Include="Properties\AssemblyInfo.cs" />
415421
</ItemGroup>
416422
<ItemGroup>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="AutoMapper" version="4.2.1" targetFramework="net451" />
3+
<package id="AutoMapper" version="5.2.0" targetFramework="net451" />
44
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net451" />
5-
<package id="Steam.Models" version="2.0.0.2" targetFramework="net451" />
5+
<package id="Steam.Models" version="2.0.0.3" targetFramework="net451" />
66
</packages>

SteamWebAPI2.Net452/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("3.0.0.0")]
35+
[assembly: AssemblyVersion("3.1.0.0")]
3636
[assembly: AssemblyFileVersion("3.0.0.0")]

SteamWebAPI2.Net452/SteamWebAPI2.Net452.csproj

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@
3131
<WarningLevel>4</WarningLevel>
3232
</PropertyGroup>
3333
<ItemGroup>
34-
<Reference Include="AutoMapper, Version=4.2.1.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
35-
<HintPath>..\packages\AutoMapper.4.2.1\lib\net45\AutoMapper.dll</HintPath>
34+
<Reference Include="AutoMapper, Version=5.2.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
35+
<HintPath>..\packages\AutoMapper.5.2.0\lib\net45\AutoMapper.dll</HintPath>
3636
<Private>True</Private>
3737
</Reference>
3838
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
3939
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
4040
<Private>True</Private>
4141
</Reference>
42-
<Reference Include="Steam.Models, Version=2.0.0.2, Culture=neutral, processorArchitecture=MSIL">
43-
<HintPath>..\packages\Steam.Models.2.0.0.2\lib\net452\Steam.Models.dll</HintPath>
42+
<Reference Include="Steam.Models, Version=2.0.0.3, Culture=neutral, processorArchitecture=MSIL">
43+
<HintPath>..\packages\Steam.Models.2.0.0.3\lib\net452\Steam.Models.dll</HintPath>
4444
<Private>True</Private>
4545
</Reference>
4646
<Reference Include="System" />
@@ -379,6 +379,9 @@
379379
<Compile Include="..\SteamWebAPI2\Utilities\ISteamWebRequest.cs">
380380
<Link>Utilities\ISteamWebRequest.cs</Link>
381381
</Compile>
382+
<Compile Include="..\SteamWebAPI2\Utilities\ISteamWebResponse.cs">
383+
<Link>Utilities\ISteamWebResponse.cs</Link>
384+
</Compile>
382385
<Compile Include="..\SteamWebAPI2\Utilities\JsonConverters\AssetClassInfoJsonConverter.cs">
383386
<Link>Utilities\JsonConverters\AssetClassInfoJsonConverter.cs</Link>
384387
</Compile>
@@ -412,6 +415,9 @@
412415
<Compile Include="..\SteamWebAPI2\Utilities\SteamWebRequestParameterExtensions.cs">
413416
<Link>Utilities\SteamWebRequestParameterExtensions.cs</Link>
414417
</Compile>
418+
<Compile Include="..\SteamWebAPI2\Utilities\SteamWebResponse.cs">
419+
<Link>Utilities\SteamWebResponse.cs</Link>
420+
</Compile>
415421
<Compile Include="Properties\AssemblyInfo.cs" />
416422
</ItemGroup>
417423
<ItemGroup>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="AutoMapper" version="4.2.1" targetFramework="net452" />
3+
<package id="AutoMapper" version="5.2.0" targetFramework="net452" />
44
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
5-
<package id="Steam.Models" version="2.0.0.2" targetFramework="net452" />
5+
<package id="Steam.Models" version="2.0.0.3" targetFramework="net452" />
66
</packages>

SteamWebAPI2.Tests/PlayerServiceTests.cs

Lines changed: 58 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,32 @@ public async Task PlayerService_IsPlayingSharedGameAsync_Return_Null_If_Web_Inte
3232
var mockSteamWebRequest = new Mock<ISteamWebInterface>();
3333

3434
mockSteamWebRequest.Setup(x => x.GetAsync<PlayingSharedGameResultContainer>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IList<SteamWebRequestParameter>>()))
35-
.ReturnsAsync((PlayingSharedGameResultContainer)null);
35+
.ReturnsAsync((ISteamWebResponse<PlayingSharedGameResultContainer>)null);
3636

3737
var service = new PlayerService(String.Empty, mockSteamWebRequest.Object);
3838
var result = await service.IsPlayingSharedGameAsync(It.IsAny<ulong>(), It.IsAny<uint>());
3939

40-
Assert.IsTrue(!result.HasValue);
40+
Assert.IsNull(result);
4141
}
4242

4343
[TestMethod]
44-
public async Task PlayerService_IsPlayingSharedGameAsync_Return_Null_If_Web_Interface_Result_Is_Null()
44+
public async Task PlayerService_IsPlayingSharedGameAsync_Return_Null_Data_If_Web_Interface_Result_Is_Null()
4545
{
4646
var mockSteamWebRequest = new Mock<ISteamWebInterface>();
4747

4848
mockSteamWebRequest.Setup(x => x.GetAsync<PlayingSharedGameResultContainer>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IList<SteamWebRequestParameter>>()))
49-
.ReturnsAsync(new PlayingSharedGameResultContainer()
49+
.ReturnsAsync(new SteamWebResponse<PlayingSharedGameResultContainer>()
5050
{
51-
Result = null
51+
Data = new PlayingSharedGameResultContainer()
52+
{
53+
Result = null
54+
}
5255
});
5356

5457
var service = new PlayerService(String.Empty, mockSteamWebRequest.Object);
5558
var result = await service.IsPlayingSharedGameAsync(It.IsAny<ulong>(), It.IsAny<uint>());
5659

57-
Assert.IsTrue(!result.HasValue);
60+
Assert.IsNull(result.Data);
5861
}
5962

6063
[TestMethod]
@@ -63,7 +66,7 @@ public async Task PlayerService_GetBadgesAsync_Return_Null_If_Web_Interface_Retu
6366
var mockSteamWebRequest = new Mock<ISteamWebInterface>();
6467

6568
mockSteamWebRequest.Setup(x => x.GetAsync<BadgesResultContainer>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IList<SteamWebRequestParameter>>()))
66-
.ReturnsAsync((BadgesResultContainer)null);
69+
.ReturnsAsync((ISteamWebResponse<BadgesResultContainer>)null);
6770

6871
var service = new PlayerService(String.Empty, mockSteamWebRequest.Object);
6972
var result = await service.GetBadgesAsync(It.IsAny<ulong>());
@@ -72,20 +75,23 @@ public async Task PlayerService_GetBadgesAsync_Return_Null_If_Web_Interface_Retu
7275
}
7376

7477
[TestMethod]
75-
public async Task PlayerService_GetBadgesAsync_Return_Null_If_Web_Interface_Result_Is_Null()
78+
public async Task PlayerService_GetBadgesAsync_Return_Null_Data_If_Web_Interface_Result_Is_Null()
7679
{
7780
var mockSteamWebRequest = new Mock<ISteamWebInterface>();
7881

7982
mockSteamWebRequest.Setup(x => x.GetAsync<BadgesResultContainer>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IList<SteamWebRequestParameter>>()))
80-
.ReturnsAsync(new BadgesResultContainer()
83+
.ReturnsAsync(new SteamWebResponse<BadgesResultContainer>()
8184
{
82-
Result = null
85+
Data = new BadgesResultContainer()
86+
{
87+
Result = null
88+
}
8389
});
8490

8591
var service = new PlayerService(String.Empty, mockSteamWebRequest.Object);
8692
var result = await service.GetBadgesAsync(It.IsAny<ulong>());
8793

88-
Assert.IsNull(result);
94+
Assert.IsNull(result.Data);
8995
}
9096

9197
[TestMethod]
@@ -94,7 +100,7 @@ public async Task PlayerService_GetCommunityBadgeProgressAsync_Return_Null_If_We
94100
var mockSteamWebRequest = new Mock<ISteamWebInterface>();
95101

96102
mockSteamWebRequest.Setup(x => x.GetAsync<CommunityBadgeProgressResultContainer>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IList<SteamWebRequestParameter>>()))
97-
.ReturnsAsync((CommunityBadgeProgressResultContainer)null);
103+
.ReturnsAsync((ISteamWebResponse<CommunityBadgeProgressResultContainer>)null);
98104

99105
var service = new PlayerService(String.Empty, mockSteamWebRequest.Object);
100106
var result = await service.GetCommunityBadgeProgressAsync(It.IsAny<uint>(), It.IsAny<uint?>());
@@ -103,20 +109,23 @@ public async Task PlayerService_GetCommunityBadgeProgressAsync_Return_Null_If_We
103109
}
104110

105111
[TestMethod]
106-
public async Task PlayerService_GetCommunityBadgeProgressAsync_Return_Null_If_Web_Interface_Result_Is_Null()
112+
public async Task PlayerService_GetCommunityBadgeProgressAsync_Return_Empty_Data_If_Web_Interface_Result_Is_Null()
107113
{
108114
var mockSteamWebRequest = new Mock<ISteamWebInterface>();
109115

110116
mockSteamWebRequest.Setup(x => x.GetAsync<CommunityBadgeProgressResultContainer>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IList<SteamWebRequestParameter>>()))
111-
.ReturnsAsync(new CommunityBadgeProgressResultContainer()
117+
.ReturnsAsync(new SteamWebResponse<CommunityBadgeProgressResultContainer>()
112118
{
113-
Result = null
119+
Data = new CommunityBadgeProgressResultContainer()
120+
{
121+
Result = null
122+
}
114123
});
115124

116125
var service = new PlayerService(String.Empty, mockSteamWebRequest.Object);
117126
var result = await service.GetCommunityBadgeProgressAsync(It.IsAny<uint>(), It.IsAny<uint?>());
118127

119-
Assert.IsNull(result);
128+
Assert.IsTrue(result.Data.Count == 0);
120129
}
121130

122131
[TestMethod]
@@ -125,7 +134,7 @@ public async Task PlayerService_GetSteamLevelAsync_Return_Null_If_Web_Interface_
125134
var mockSteamWebRequest = new Mock<ISteamWebInterface>();
126135

127136
mockSteamWebRequest.Setup(x => x.GetAsync<SteamLevelResultContainer>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IList<SteamWebRequestParameter>>()))
128-
.ReturnsAsync((SteamLevelResultContainer)null);
137+
.ReturnsAsync((ISteamWebResponse<SteamLevelResultContainer>)null);
129138

130139
var service = new PlayerService(String.Empty, mockSteamWebRequest.Object);
131140
var result = await service.GetSteamLevelAsync(It.IsAny<uint>());
@@ -134,20 +143,23 @@ public async Task PlayerService_GetSteamLevelAsync_Return_Null_If_Web_Interface_
134143
}
135144

136145
[TestMethod]
137-
public async Task PlayerService_GetSteamLevelAsync_Return_Null_If_Web_Interface_Result_Is_Null()
146+
public async Task PlayerService_GetSteamLevelAsync_Return_Default_Data_If_Web_Interface_Result_Is_Null()
138147
{
139148
var mockSteamWebRequest = new Mock<ISteamWebInterface>();
140149

141150
mockSteamWebRequest.Setup(x => x.GetAsync<SteamLevelResultContainer>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IList<SteamWebRequestParameter>>()))
142-
.ReturnsAsync(new SteamLevelResultContainer()
151+
.ReturnsAsync(new SteamWebResponse<SteamLevelResultContainer>()
143152
{
144-
Result = null
153+
Data = new SteamLevelResultContainer()
154+
{
155+
Result = null
156+
}
145157
});
146158

147159
var service = new PlayerService(String.Empty, mockSteamWebRequest.Object);
148-
var result = await service.GetSteamLevelAsync(It.IsAny<uint>());
160+
var result = await service.GetSteamLevelAsync(It.IsAny<ulong>());
149161

150-
Assert.IsNull(result);
162+
Assert.IsNull(result.Data);
151163
}
152164

153165
[TestMethod]
@@ -156,7 +168,7 @@ public async Task PlayerService_GetOwnedGamesAsync_Return_Null_If_Web_Interface_
156168
var mockSteamWebRequest = new Mock<ISteamWebInterface>();
157169

158170
mockSteamWebRequest.Setup(x => x.GetAsync<OwnedGamesResultContainer>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IList<SteamWebRequestParameter>>()))
159-
.ReturnsAsync((OwnedGamesResultContainer)null);
171+
.ReturnsAsync((ISteamWebResponse<OwnedGamesResultContainer>)null);
160172

161173
var service = new PlayerService(String.Empty, mockSteamWebRequest.Object);
162174
var result = await service.GetOwnedGamesAsync(It.IsAny<ulong>(), It.IsAny<bool?>(), It.IsAny<bool?>(), It.IsAny<IReadOnlyCollection<uint>>());
@@ -165,20 +177,23 @@ public async Task PlayerService_GetOwnedGamesAsync_Return_Null_If_Web_Interface_
165177
}
166178

167179
[TestMethod]
168-
public async Task PlayerService_GetOwnedGamesAsync_Return_Null_If_Web_Interface_Result_Is_Null()
180+
public async Task PlayerService_GetOwnedGamesAsync_Return_Null_Data_If_Web_Interface_Result_Is_Null()
169181
{
170182
var mockSteamWebRequest = new Mock<ISteamWebInterface>();
171183

172184
mockSteamWebRequest.Setup(x => x.GetAsync<OwnedGamesResultContainer>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IList<SteamWebRequestParameter>>()))
173-
.ReturnsAsync(new OwnedGamesResultContainer()
185+
.ReturnsAsync(new SteamWebResponse<OwnedGamesResultContainer>()
174186
{
175-
Result = null
187+
Data = new OwnedGamesResultContainer()
188+
{
189+
Result = null
190+
}
176191
});
177192

178193
var service = new PlayerService(String.Empty, mockSteamWebRequest.Object);
179194
var result = await service.GetOwnedGamesAsync(It.IsAny<ulong>(), It.IsAny<bool?>(), It.IsAny<bool?>(), It.IsAny<IReadOnlyCollection<uint>>());
180195

181-
Assert.IsNull(result);
196+
Assert.IsNull(result.Data);
182197
}
183198

184199
[TestMethod]
@@ -187,27 +202,30 @@ public async Task PlayerService_GetOwnedGamesAsync_Trim_Starting_And_Ending_Spac
187202
var mockSteamWebRequest = new Mock<ISteamWebInterface>();
188203

189204
mockSteamWebRequest.Setup(x => x.GetAsync<OwnedGamesResultContainer>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IList<SteamWebRequestParameter>>()))
190-
.ReturnsAsync(new OwnedGamesResultContainer()
205+
.ReturnsAsync(new SteamWebResponse<OwnedGamesResultContainer>()
191206
{
192-
Result = new OwnedGamesResult()
207+
Data = new OwnedGamesResultContainer()
193208
{
194-
GameCount = 10,
195-
OwnedGames = new List<OwnedGame>()
209+
Result = new OwnedGamesResult()
210+
{
211+
GameCount = 10,
212+
OwnedGames = new List<OwnedGame>()
196213
{
197214
new OwnedGame() { Name = " Test Game 1 " },
198215
new OwnedGame() { Name = " Test Game 2 " },
199216
new OwnedGame() { Name = " Test Game 3 " },
200217
new OwnedGame() { Name = " Test Game 4 " },
201218
new OwnedGame() { Name = " Test Game 5 " },
202219
}
220+
}
203221
}
204222
});
205223

206224
var service = new PlayerService(String.Empty, mockSteamWebRequest.Object);
207225
var result = await service.GetOwnedGamesAsync(It.IsAny<ulong>(), It.IsAny<bool?>(), It.IsAny<bool?>(), It.IsAny<IReadOnlyCollection<uint>>());
208226

209227
// Make sure all game names have been trimmed on the edges
210-
foreach(var game in result.OwnedGames)
228+
foreach (var game in result.Data.OwnedGames)
211229
{
212230
Assert.IsTrue(!game.Name.StartsWith(" "));
213231
Assert.IsTrue(!game.Name.EndsWith(" "));
@@ -220,7 +238,7 @@ public async Task PlayerService_GetRecentlyPlayedGamesAsync_Return_Null_If_Web_I
220238
var mockSteamWebRequest = new Mock<ISteamWebInterface>();
221239

222240
mockSteamWebRequest.Setup(x => x.GetAsync<RecentlyPlayedGameResultContainer>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IList<SteamWebRequestParameter>>()))
223-
.ReturnsAsync((RecentlyPlayedGameResultContainer)null);
241+
.ReturnsAsync((ISteamWebResponse<RecentlyPlayedGameResultContainer>)null);
224242

225243
var service = new PlayerService(String.Empty, mockSteamWebRequest.Object);
226244
var result = await service.GetRecentlyPlayedGamesAsync(It.IsAny<ulong>());
@@ -229,20 +247,23 @@ public async Task PlayerService_GetRecentlyPlayedGamesAsync_Return_Null_If_Web_I
229247
}
230248

231249
[TestMethod]
232-
public async Task PlayerService_GetRecentlyPlayedGamesAsync_Return_Null_If_Web_Interface_Result_Is_Null()
250+
public async Task PlayerService_GetRecentlyPlayedGamesAsync_Return_Null_Data_If_Web_Interface_Result_Is_Null()
233251
{
234252
var mockSteamWebRequest = new Mock<ISteamWebInterface>();
235253

236254
mockSteamWebRequest.Setup(x => x.GetAsync<RecentlyPlayedGameResultContainer>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IList<SteamWebRequestParameter>>()))
237-
.ReturnsAsync(new RecentlyPlayedGameResultContainer()
255+
.ReturnsAsync(new SteamWebResponse<RecentlyPlayedGameResultContainer>()
238256
{
239-
Result = null
257+
Data = new RecentlyPlayedGameResultContainer()
258+
{
259+
Result = null
260+
}
240261
});
241262

242263
var service = new PlayerService(String.Empty, mockSteamWebRequest.Object);
243264
var result = await service.GetRecentlyPlayedGamesAsync(It.IsAny<ulong>());
244265

245-
Assert.IsNull(result);
266+
Assert.IsNull(result.Data);
246267
}
247268
}
248269
}

0 commit comments

Comments
 (0)