Skip to content

Commit 7e7dedb

Browse files
author
Justin
committed
Added unit test project.
Addd POST web request. Refactored some web request method names. Added GameServersService interface and methods.
1 parent 68e9adb commit 7e7dedb

32 files changed

Lines changed: 448 additions & 180 deletions

SteamWebAPI2.Net451/SteamWebAPI2.Net451.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@
9090
<Compile Include="..\SteamWebAPI2\Interfaces\EconService.cs">
9191
<Link>Interfaces\EconService.cs</Link>
9292
</Compile>
93+
<Compile Include="..\SteamWebAPI2\Interfaces\GameServersService.cs">
94+
<Link>Interfaces\GameServersService.cs</Link>
95+
</Compile>
9396
<Compile Include="..\SteamWebAPI2\Interfaces\GCVersion.cs">
9497
<Link>Interfaces\GCVersion.cs</Link>
9598
</Compile>
@@ -114,6 +117,9 @@
114117
<Compile Include="..\SteamWebAPI2\Interfaces\IEconService.cs">
115118
<Link>Interfaces\IEconService.cs</Link>
116119
</Compile>
120+
<Compile Include="..\SteamWebAPI2\Interfaces\IGameServersService.cs">
121+
<Link>Interfaces\IGameServersService.cs</Link>
122+
</Compile>
117123
<Compile Include="..\SteamWebAPI2\Interfaces\IGCVersion.cs">
118124
<Link>Interfaces\IGCVersion.cs</Link>
119125
</Compile>

SteamWebAPI2.Net452/SteamWebAPI2.Net452.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@
9191
<Compile Include="..\SteamWebAPI2\Interfaces\EconService.cs">
9292
<Link>Interfaces\EconService.cs</Link>
9393
</Compile>
94+
<Compile Include="..\SteamWebAPI2\Interfaces\GameServersService.cs">
95+
<Link>Interfaces\GameServersService.cs</Link>
96+
</Compile>
9497
<Compile Include="..\SteamWebAPI2\Interfaces\GCVersion.cs">
9598
<Link>Interfaces\GCVersion.cs</Link>
9699
</Compile>
@@ -115,6 +118,9 @@
115118
<Compile Include="..\SteamWebAPI2\Interfaces\IEconService.cs">
116119
<Link>Interfaces\IEconService.cs</Link>
117120
</Compile>
121+
<Compile Include="..\SteamWebAPI2\Interfaces\IGameServersService.cs">
122+
<Link>Interfaces\IGameServersService.cs</Link>
123+
</Compile>
118124
<Compile Include="..\SteamWebAPI2\Interfaces\IGCVersion.cs">
119125
<Link>Interfaces\IGCVersion.cs</Link>
120126
</Compile>

SteamWebAPI2.Tests/App.config

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<appSettings file="..\DO_NOT_ADD_TO_GIT\protected.config">
4+
</appSettings>
5+
</configuration>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using SteamWebAPI2.Interfaces;
4+
using System.Threading.Tasks;
5+
using System.Configuration;
6+
7+
namespace SteamWebAPI2.Tests
8+
{
9+
[TestClass]
10+
public class PlayerServiceTests
11+
{
12+
private string steamWebApiKey = String.Empty;
13+
14+
[TestInitialize]
15+
public void Initialize()
16+
{
17+
steamWebApiKey = ConfigurationManager.AppSettings["steamWebApiKey"].ToString();
18+
}
19+
20+
[TestMethod]
21+
public async Task PlayerService_GetPlayerSummaryAsync()
22+
{
23+
var playerService = new PlayerService(steamWebApiKey);
24+
var response = await playerService.GetOwnedGamesAsync(76561197960361544);
25+
Assert.IsNotNull(response);
26+
Assert.IsNotNull(response.OwnedGames);
27+
Assert.IsTrue(response.GameCount > 0);
28+
Assert.IsTrue(response.OwnedGames.Count > 0);
29+
}
30+
}
31+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("SteamWebAPI2.Tests")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("SteamWebAPI2.Tests")]
13+
[assembly: AssemblyCopyright("Copyright © 2017")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("f4fe4936-40e5-4ab7-8dad-ca0b46ccdcaf")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectGuid>{F4FE4936-40E5-4AB7-8DAD-CA0B46CCDCAF}</ProjectGuid>
7+
<OutputType>Library</OutputType>
8+
<AppDesignerFolder>Properties</AppDesignerFolder>
9+
<RootNamespace>SteamWebAPI2.Tests</RootNamespace>
10+
<AssemblyName>SteamWebAPI2.Tests</AssemblyName>
11+
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
15+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
16+
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
17+
<IsCodedUITest>False</IsCodedUITest>
18+
<TestProjectType>UnitTest</TestProjectType>
19+
<TargetFrameworkProfile />
20+
</PropertyGroup>
21+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
22+
<DebugSymbols>true</DebugSymbols>
23+
<DebugType>full</DebugType>
24+
<Optimize>false</Optimize>
25+
<OutputPath>bin\Debug\</OutputPath>
26+
<DefineConstants>DEBUG;TRACE</DefineConstants>
27+
<ErrorReport>prompt</ErrorReport>
28+
<WarningLevel>4</WarningLevel>
29+
</PropertyGroup>
30+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
31+
<DebugType>pdbonly</DebugType>
32+
<Optimize>true</Optimize>
33+
<OutputPath>bin\Release\</OutputPath>
34+
<DefineConstants>TRACE</DefineConstants>
35+
<ErrorReport>prompt</ErrorReport>
36+
<WarningLevel>4</WarningLevel>
37+
</PropertyGroup>
38+
<ItemGroup>
39+
<Reference Include="Steam.Models, Version=1.0.0.52, Culture=neutral, processorArchitecture=MSIL">
40+
<HintPath>..\packages\Steam.Models.1.0.0.52\lib\net46\Steam.Models.dll</HintPath>
41+
<Private>True</Private>
42+
</Reference>
43+
<Reference Include="System" />
44+
<Reference Include="System.Configuration" />
45+
</ItemGroup>
46+
<Choose>
47+
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
48+
<ItemGroup>
49+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
50+
</ItemGroup>
51+
</When>
52+
<Otherwise>
53+
<ItemGroup>
54+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
55+
</ItemGroup>
56+
</Otherwise>
57+
</Choose>
58+
<ItemGroup>
59+
<Compile Include="PlayerServiceTests.cs" />
60+
<Compile Include="Properties\AssemblyInfo.cs" />
61+
</ItemGroup>
62+
<ItemGroup>
63+
<ProjectReference Include="..\SteamWebAPI2\SteamWebAPI2.csproj">
64+
<Project>{f5be3b4f-5f56-45cb-9eeb-2bc017ac8eb5}</Project>
65+
<Name>SteamWebAPI2</Name>
66+
</ProjectReference>
67+
</ItemGroup>
68+
<ItemGroup>
69+
<None Include="App.config" />
70+
<None Include="packages.config" />
71+
</ItemGroup>
72+
<Choose>
73+
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
74+
<ItemGroup>
75+
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
76+
<Private>False</Private>
77+
</Reference>
78+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
79+
<Private>False</Private>
80+
</Reference>
81+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
82+
<Private>False</Private>
83+
</Reference>
84+
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
85+
<Private>False</Private>
86+
</Reference>
87+
</ItemGroup>
88+
</When>
89+
</Choose>
90+
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
91+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
92+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
93+
Other similar extension points exist, see Microsoft.Common.targets.
94+
<Target Name="BeforeBuild">
95+
</Target>
96+
<Target Name="AfterBuild">
97+
</Target>
98+
-->
99+
</Project>

SteamWebAPI2.Tests/packages.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Steam.Models" version="1.0.0.52" targetFramework="net461" />
4+
</packages>

SteamWebAPI2.sln

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
4-
VisualStudioVersion = 14.0.24720.0
4+
VisualStudioVersion = 14.0.25420.1
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SteamWebAPI2", "SteamWebAPI2\SteamWebAPI2.csproj", "{F5BE3B4F-5F56-45CB-9EEB-2BC017AC8EB5}"
77
EndProject
88
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SteamWebAPI2.Net452", "SteamWebAPI2.Net452\SteamWebAPI2.Net452.csproj", "{D16DFA6F-EB9A-4668-8D24-232E7ADA8D98}"
99
EndProject
1010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SteamWebAPI2.Net451", "SteamWebAPI2.Net451\SteamWebAPI2.Net451.csproj", "{41B001A5-D111-4EF5-93DD-6F23AF6E8B95}"
1111
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SteamWebAPI2.Tests", "SteamWebAPI2.Tests\SteamWebAPI2.Tests.csproj", "{F4FE4936-40E5-4AB7-8DAD-CA0B46CCDCAF}"
13+
EndProject
1214
Global
1315
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1416
Debug|Any CPU = Debug|Any CPU
@@ -69,6 +71,22 @@ Global
6971
{41B001A5-D111-4EF5-93DD-6F23AF6E8B95}.Release|x64.Build.0 = Release|Any CPU
7072
{41B001A5-D111-4EF5-93DD-6F23AF6E8B95}.Release|x86.ActiveCfg = Release|Any CPU
7173
{41B001A5-D111-4EF5-93DD-6F23AF6E8B95}.Release|x86.Build.0 = Release|Any CPU
74+
{F4FE4936-40E5-4AB7-8DAD-CA0B46CCDCAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
75+
{F4FE4936-40E5-4AB7-8DAD-CA0B46CCDCAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
76+
{F4FE4936-40E5-4AB7-8DAD-CA0B46CCDCAF}.Debug|ARM.ActiveCfg = Debug|Any CPU
77+
{F4FE4936-40E5-4AB7-8DAD-CA0B46CCDCAF}.Debug|ARM.Build.0 = Debug|Any CPU
78+
{F4FE4936-40E5-4AB7-8DAD-CA0B46CCDCAF}.Debug|x64.ActiveCfg = Debug|Any CPU
79+
{F4FE4936-40E5-4AB7-8DAD-CA0B46CCDCAF}.Debug|x64.Build.0 = Debug|Any CPU
80+
{F4FE4936-40E5-4AB7-8DAD-CA0B46CCDCAF}.Debug|x86.ActiveCfg = Debug|Any CPU
81+
{F4FE4936-40E5-4AB7-8DAD-CA0B46CCDCAF}.Debug|x86.Build.0 = Debug|Any CPU
82+
{F4FE4936-40E5-4AB7-8DAD-CA0B46CCDCAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
83+
{F4FE4936-40E5-4AB7-8DAD-CA0B46CCDCAF}.Release|Any CPU.Build.0 = Release|Any CPU
84+
{F4FE4936-40E5-4AB7-8DAD-CA0B46CCDCAF}.Release|ARM.ActiveCfg = Release|Any CPU
85+
{F4FE4936-40E5-4AB7-8DAD-CA0B46CCDCAF}.Release|ARM.Build.0 = Release|Any CPU
86+
{F4FE4936-40E5-4AB7-8DAD-CA0B46CCDCAF}.Release|x64.ActiveCfg = Release|Any CPU
87+
{F4FE4936-40E5-4AB7-8DAD-CA0B46CCDCAF}.Release|x64.Build.0 = Release|Any CPU
88+
{F4FE4936-40E5-4AB7-8DAD-CA0B46CCDCAF}.Release|x86.ActiveCfg = Release|Any CPU
89+
{F4FE4936-40E5-4AB7-8DAD-CA0B46CCDCAF}.Release|x86.Build.0 = Release|Any CPU
7290
EndGlobalSection
7391
GlobalSection(SolutionProperties) = preSolution
7492
HideSolutionNode = FALSE

SteamWebAPI2/ErrorMessages1.Designer.cs

Lines changed: 0 additions & 100 deletions
This file was deleted.

SteamWebAPI2/Interfaces/CSGOServers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public CSGOServers(string steamWebApiKey)
2424
/// <returns></returns>
2525
public async Task<ServerStatusModel> GetGameServerStatusAsync()
2626
{
27-
var gameServerStatus = await CallMethodAsync<ServerStatusResultContainer>("GetGameServersStatus", 1);
27+
var gameServerStatus = await GetAsync<ServerStatusResultContainer>("GetGameServersStatus", 1);
2828

2929
var gameServerStatusModel = AutoMapperConfiguration.Mapper.Map<ServerStatusResult, ServerStatusModel>(gameServerStatus.Result);
3030

0 commit comments

Comments
 (0)