Achievement Tests

This commit is contained in:
Garry Newman 2017-05-08 20:52:21 +01:00
parent 01cf0f4cec
commit 2ebecd1548
2 changed files with 89 additions and 0 deletions

View File

@ -0,0 +1,88 @@
using System;
using System.Text;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Facepunch.Steamworks.Test
{
[TestClass]
[DeploymentItem( "steam_api.dll" )]
[DeploymentItem( "steam_api64.dll" )]
[DeploymentItem( "steam_appid.txt" )]
public class Achievements
{
[TestMethod]
public void GetCount()
{
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
{
Assert.IsTrue( client.IsValid );
var gotStats = false;
client.Achievements.OnUpdated += () => { gotStats = true; };
while ( !gotStats )
{
client.Update();
}
Console.WriteLine( "Found " + client.Achievements.All.Length + " Achievements" );
Assert.AreNotEqual( 0, client.Achievements.All.Length );
}
}
[TestMethod]
public void GetNames()
{
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
{
Assert.IsTrue( client.IsValid );
var gotStats = false;
client.Achievements.OnUpdated += () => { gotStats = true; };
while ( !gotStats )
{
client.Update();
}
foreach( var ach in client.Achievements.All )
{
Assert.IsNotNull( ach.Id );
Console.WriteLine( " " + ach.Id );
Console.WriteLine( " - - " + ach.Name );
Console.WriteLine( " - - " + ach.Description );
Console.WriteLine( " - - " + ach.State );
Console.WriteLine( " - - " + ach.UnlockTime );
Console.WriteLine( " - - " + ach.Percentage );
Console.WriteLine( "" );
}
}
}
[TestMethod]
public void Trigger()
{
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
{
Assert.IsTrue( client.IsValid );
var gotStats = false;
client.Achievements.OnUpdated += () => { gotStats = true; };
while ( !gotStats )
{
client.Update();
}
foreach ( var ach in client.Achievements.All )
{
ach.Trigger();
}
}
}
}
}

View File

@ -92,6 +92,7 @@
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="Client\Achievements.cs" />
<Compile Include="Client\Client.cs" />
<Compile Include="Client\Leaderboard.cs" />
<Compile Include="Client\App.cs" />