mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-02-03 09:10:41 +03:00
Achievement Tests
This commit is contained in:
parent
01cf0f4cec
commit
2ebecd1548
88
Facepunch.Steamworks.Test/Client/Achievements.cs
Normal file
88
Facepunch.Steamworks.Test/Client/Achievements.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -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" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user