Facepunch.Steamworks/Facepunch.Steamworks.Test/Client/AchievementsTest.cs
2017-12-06 10:50:11 +00:00

95 lines
2.7 KiB
C#

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 );
if ( ach.Icon != null )
{
Console.WriteLine( " - - " + ach.Icon.Width + " x " + ach.Icon.Height );
}
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();
}
}
}
}
}