Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 36 http response headers #38

Merged
merged 6 commits into from
Feb 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SteamWebAPI2.Net451/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.0.0.0")]
[assembly: AssemblyVersion("3.1.0.0")]
[assembly: AssemblyFileVersion("3.0.0.0")]
14 changes: 10 additions & 4 deletions SteamWebAPI2.Net451/SteamWebAPI2.Net451.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="AutoMapper, Version=4.2.1.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
<HintPath>..\packages\AutoMapper.4.2.1\lib\net45\AutoMapper.dll</HintPath>
<Reference Include="AutoMapper, Version=5.2.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
<HintPath>..\packages\AutoMapper.5.2.0\lib\net45\AutoMapper.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Steam.Models, Version=2.0.0.2, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Steam.Models.2.0.0.2\lib\net451\Steam.Models.dll</HintPath>
<Reference Include="Steam.Models, Version=2.0.0.3, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Steam.Models.2.0.0.3\lib\net451\Steam.Models.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand Down Expand Up @@ -378,6 +378,9 @@
<Compile Include="..\SteamWebAPI2\Utilities\ISteamWebRequest.cs">
<Link>Utilities\ISteamWebRequest.cs</Link>
</Compile>
<Compile Include="..\SteamWebAPI2\Utilities\ISteamWebResponse.cs">
<Link>Utilities\ISteamWebResponse.cs</Link>
</Compile>
<Compile Include="..\SteamWebAPI2\Utilities\JsonConverters\AssetClassInfoJsonConverter.cs">
<Link>Utilities\JsonConverters\AssetClassInfoJsonConverter.cs</Link>
</Compile>
Expand Down Expand Up @@ -411,6 +414,9 @@
<Compile Include="..\SteamWebAPI2\Utilities\SteamWebRequestParameterExtensions.cs">
<Link>Utilities\SteamWebRequestParameterExtensions.cs</Link>
</Compile>
<Compile Include="..\SteamWebAPI2\Utilities\SteamWebResponse.cs">
<Link>Utilities\SteamWebResponse.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions SteamWebAPI2.Net451/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AutoMapper" version="4.2.1" targetFramework="net451" />
<package id="AutoMapper" version="5.2.0" targetFramework="net451" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net451" />
<package id="Steam.Models" version="2.0.0.2" targetFramework="net451" />
<package id="Steam.Models" version="2.0.0.3" targetFramework="net451" />
</packages>
2 changes: 1 addition & 1 deletion SteamWebAPI2.Net452/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.0.0.0")]
[assembly: AssemblyVersion("3.1.0.0")]
[assembly: AssemblyFileVersion("3.0.0.0")]
14 changes: 10 additions & 4 deletions SteamWebAPI2.Net452/SteamWebAPI2.Net452.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="AutoMapper, Version=4.2.1.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
<HintPath>..\packages\AutoMapper.4.2.1\lib\net45\AutoMapper.dll</HintPath>
<Reference Include="AutoMapper, Version=5.2.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
<HintPath>..\packages\AutoMapper.5.2.0\lib\net45\AutoMapper.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Steam.Models, Version=2.0.0.2, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Steam.Models.2.0.0.2\lib\net452\Steam.Models.dll</HintPath>
<Reference Include="Steam.Models, Version=2.0.0.3, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Steam.Models.2.0.0.3\lib\net452\Steam.Models.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand Down Expand Up @@ -379,6 +379,9 @@
<Compile Include="..\SteamWebAPI2\Utilities\ISteamWebRequest.cs">
<Link>Utilities\ISteamWebRequest.cs</Link>
</Compile>
<Compile Include="..\SteamWebAPI2\Utilities\ISteamWebResponse.cs">
<Link>Utilities\ISteamWebResponse.cs</Link>
</Compile>
<Compile Include="..\SteamWebAPI2\Utilities\JsonConverters\AssetClassInfoJsonConverter.cs">
<Link>Utilities\JsonConverters\AssetClassInfoJsonConverter.cs</Link>
</Compile>
Expand Down Expand Up @@ -412,6 +415,9 @@
<Compile Include="..\SteamWebAPI2\Utilities\SteamWebRequestParameterExtensions.cs">
<Link>Utilities\SteamWebRequestParameterExtensions.cs</Link>
</Compile>
<Compile Include="..\SteamWebAPI2\Utilities\SteamWebResponse.cs">
<Link>Utilities\SteamWebResponse.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions SteamWebAPI2.Net452/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AutoMapper" version="4.2.1" targetFramework="net452" />
<package id="AutoMapper" version="5.2.0" targetFramework="net452" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
<package id="Steam.Models" version="2.0.0.2" targetFramework="net452" />
<package id="Steam.Models" version="2.0.0.3" targetFramework="net452" />
</packages>
95 changes: 58 additions & 37 deletions SteamWebAPI2.Tests/PlayerServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,32 @@ public async Task PlayerService_IsPlayingSharedGameAsync_Return_Null_If_Web_Inte
var mockSteamWebRequest = new Mock<ISteamWebInterface>();

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

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

Assert.IsTrue(!result.HasValue);
Assert.IsNull(result);
}

[TestMethod]
public async Task PlayerService_IsPlayingSharedGameAsync_Return_Null_If_Web_Interface_Result_Is_Null()
public async Task PlayerService_IsPlayingSharedGameAsync_Return_Null_Data_If_Web_Interface_Result_Is_Null()
{
var mockSteamWebRequest = new Mock<ISteamWebInterface>();

mockSteamWebRequest.Setup(x => x.GetAsync<PlayingSharedGameResultContainer>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IList<SteamWebRequestParameter>>()))
.ReturnsAsync(new PlayingSharedGameResultContainer()
.ReturnsAsync(new SteamWebResponse<PlayingSharedGameResultContainer>()
{
Result = null
Data = new PlayingSharedGameResultContainer()
{
Result = null
}
});

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

Assert.IsTrue(!result.HasValue);
Assert.IsNull(result.Data);
}

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

mockSteamWebRequest.Setup(x => x.GetAsync<BadgesResultContainer>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IList<SteamWebRequestParameter>>()))
.ReturnsAsync((BadgesResultContainer)null);
.ReturnsAsync((ISteamWebResponse<BadgesResultContainer>)null);

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

[TestMethod]
public async Task PlayerService_GetBadgesAsync_Return_Null_If_Web_Interface_Result_Is_Null()
public async Task PlayerService_GetBadgesAsync_Return_Null_Data_If_Web_Interface_Result_Is_Null()
{
var mockSteamWebRequest = new Mock<ISteamWebInterface>();

mockSteamWebRequest.Setup(x => x.GetAsync<BadgesResultContainer>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IList<SteamWebRequestParameter>>()))
.ReturnsAsync(new BadgesResultContainer()
.ReturnsAsync(new SteamWebResponse<BadgesResultContainer>()
{
Result = null
Data = new BadgesResultContainer()
{
Result = null
}
});

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

Assert.IsNull(result);
Assert.IsNull(result.Data);
}

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

mockSteamWebRequest.Setup(x => x.GetAsync<CommunityBadgeProgressResultContainer>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IList<SteamWebRequestParameter>>()))
.ReturnsAsync((CommunityBadgeProgressResultContainer)null);
.ReturnsAsync((ISteamWebResponse<CommunityBadgeProgressResultContainer>)null);

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

[TestMethod]
public async Task PlayerService_GetCommunityBadgeProgressAsync_Return_Null_If_Web_Interface_Result_Is_Null()
public async Task PlayerService_GetCommunityBadgeProgressAsync_Return_Empty_Data_If_Web_Interface_Result_Is_Null()
{
var mockSteamWebRequest = new Mock<ISteamWebInterface>();

mockSteamWebRequest.Setup(x => x.GetAsync<CommunityBadgeProgressResultContainer>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IList<SteamWebRequestParameter>>()))
.ReturnsAsync(new CommunityBadgeProgressResultContainer()
.ReturnsAsync(new SteamWebResponse<CommunityBadgeProgressResultContainer>()
{
Result = null
Data = new CommunityBadgeProgressResultContainer()
{
Result = null
}
});

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

Assert.IsNull(result);
Assert.IsTrue(result.Data.Count == 0);
}

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

mockSteamWebRequest.Setup(x => x.GetAsync<SteamLevelResultContainer>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IList<SteamWebRequestParameter>>()))
.ReturnsAsync((SteamLevelResultContainer)null);
.ReturnsAsync((ISteamWebResponse<SteamLevelResultContainer>)null);

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

[TestMethod]
public async Task PlayerService_GetSteamLevelAsync_Return_Null_If_Web_Interface_Result_Is_Null()
public async Task PlayerService_GetSteamLevelAsync_Return_Default_Data_If_Web_Interface_Result_Is_Null()
{
var mockSteamWebRequest = new Mock<ISteamWebInterface>();

mockSteamWebRequest.Setup(x => x.GetAsync<SteamLevelResultContainer>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IList<SteamWebRequestParameter>>()))
.ReturnsAsync(new SteamLevelResultContainer()
.ReturnsAsync(new SteamWebResponse<SteamLevelResultContainer>()
{
Result = null
Data = new SteamLevelResultContainer()
{
Result = null
}
});

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

Assert.IsNull(result);
Assert.IsNull(result.Data);
}

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

mockSteamWebRequest.Setup(x => x.GetAsync<OwnedGamesResultContainer>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IList<SteamWebRequestParameter>>()))
.ReturnsAsync((OwnedGamesResultContainer)null);
.ReturnsAsync((ISteamWebResponse<OwnedGamesResultContainer>)null);

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

[TestMethod]
public async Task PlayerService_GetOwnedGamesAsync_Return_Null_If_Web_Interface_Result_Is_Null()
public async Task PlayerService_GetOwnedGamesAsync_Return_Null_Data_If_Web_Interface_Result_Is_Null()
{
var mockSteamWebRequest = new Mock<ISteamWebInterface>();

mockSteamWebRequest.Setup(x => x.GetAsync<OwnedGamesResultContainer>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IList<SteamWebRequestParameter>>()))
.ReturnsAsync(new OwnedGamesResultContainer()
.ReturnsAsync(new SteamWebResponse<OwnedGamesResultContainer>()
{
Result = null
Data = new OwnedGamesResultContainer()
{
Result = null
}
});

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

Assert.IsNull(result);
Assert.IsNull(result.Data);
}

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

mockSteamWebRequest.Setup(x => x.GetAsync<OwnedGamesResultContainer>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IList<SteamWebRequestParameter>>()))
.ReturnsAsync(new OwnedGamesResultContainer()
.ReturnsAsync(new SteamWebResponse<OwnedGamesResultContainer>()
{
Result = new OwnedGamesResult()
Data = new OwnedGamesResultContainer()
{
GameCount = 10,
OwnedGames = new List<OwnedGame>()
Result = new OwnedGamesResult()
{
GameCount = 10,
OwnedGames = new List<OwnedGame>()
{
new OwnedGame() { Name = " Test Game 1 " },
new OwnedGame() { Name = " Test Game 2 " },
new OwnedGame() { Name = " Test Game 3 " },
new OwnedGame() { Name = " Test Game 4 " },
new OwnedGame() { Name = " Test Game 5 " },
}
}
}
});

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

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

mockSteamWebRequest.Setup(x => x.GetAsync<RecentlyPlayedGameResultContainer>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IList<SteamWebRequestParameter>>()))
.ReturnsAsync((RecentlyPlayedGameResultContainer)null);
.ReturnsAsync((ISteamWebResponse<RecentlyPlayedGameResultContainer>)null);

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

[TestMethod]
public async Task PlayerService_GetRecentlyPlayedGamesAsync_Return_Null_If_Web_Interface_Result_Is_Null()
public async Task PlayerService_GetRecentlyPlayedGamesAsync_Return_Null_Data_If_Web_Interface_Result_Is_Null()
{
var mockSteamWebRequest = new Mock<ISteamWebInterface>();

mockSteamWebRequest.Setup(x => x.GetAsync<RecentlyPlayedGameResultContainer>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IList<SteamWebRequestParameter>>()))
.ReturnsAsync(new RecentlyPlayedGameResultContainer()
.ReturnsAsync(new SteamWebResponse<RecentlyPlayedGameResultContainer>()
{
Result = null
Data = new RecentlyPlayedGameResultContainer()
{
Result = null
}
});

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

Assert.IsNull(result);
Assert.IsNull(result.Data);
}
}
}
Loading