Facepunch.Steamworks/Facepunch.Steamworks.Test/Client/AchievementsTest.cs

94 lines
2.7 KiB
C#
Raw Normal View History

2017-05-08 22:52:21 +03:00
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" )]
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.GlobalUnlockedPercentage );
2017-05-09 22:41:16 +03:00
if ( ach.Icon != null )
{
Console.WriteLine( " - - " + ach.Icon.Width + " x " + ach.Icon.Height );
}
2017-05-08 22:52:21 +03:00
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();
}
}
}
}
}