188 lines
5.2 KiB
C#
Raw Normal View History

2016-07-06 17:37:25 +01:00
using System;
2016-07-19 13:32:14 +01:00
using System.Diagnostics;
2016-10-07 11:07:35 +01:00
using System.IO;
using System.Linq;
2016-07-06 17:37:25 +01:00
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Facepunch.Steamworks.Test
{
[TestClass]
2016-10-25 10:29:35 +01:00
[DeploymentItem( "steam_api.dll" )]
[DeploymentItem( "steam_api64.dll" )]
2016-07-13 17:14:16 +01:00
public partial class Client
2016-07-06 17:37:25 +01:00
{
[TestMethod]
2016-07-07 16:55:08 +01:00
public void Init()
2016-07-06 17:37:25 +01:00
{
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
{
2016-10-05 12:44:01 +01:00
Assert.IsTrue( client.IsValid );
2016-07-06 17:37:25 +01:00
}
}
2016-10-07 11:07:35 +01:00
[TestMethod]
2016-10-25 11:16:05 +01:00
public void Init_10()
2016-10-07 11:07:35 +01:00
{
2016-10-25 11:16:05 +01:00
for ( int i = 0; i < 10; i++ )
2016-10-07 11:07:35 +01:00
{
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
{
Assert.IsTrue( client.IsValid );
}
2016-10-07 11:50:49 +01:00
GC.Collect();
2016-10-07 11:07:35 +01:00
}
}
2016-07-06 17:37:25 +01:00
[TestMethod]
2016-07-07 16:55:08 +01:00
public void Name()
2016-07-06 17:37:25 +01:00
{
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
{
2016-10-25 11:16:05 +01:00
Assert.IsTrue( client.IsValid );
2016-07-06 17:37:25 +01:00
var username = client.Username;
Console.WriteLine( username );
2016-07-07 13:47:47 +01:00
Assert.IsNotNull( username );
}
}
[TestMethod]
2016-07-07 16:55:08 +01:00
public void SteamId()
2016-07-07 13:47:47 +01:00
{
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
{
2016-10-25 11:16:05 +01:00
Assert.IsTrue( client.IsValid );
2016-07-07 13:47:47 +01:00
var steamid = client.SteamId;
Console.WriteLine( steamid );
Assert.AreNotEqual( 0, steamid );
2016-07-06 17:37:25 +01:00
}
}
2016-07-07 14:04:15 +01:00
[TestMethod]
2016-07-07 16:55:08 +01:00
public void AuthSessionTicket()
2016-07-07 14:04:15 +01:00
{
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
{
2016-07-07 14:11:23 +01:00
var ticket = client.Auth.GetAuthSessionTicket();
2016-07-07 14:04:15 +01:00
Assert.IsTrue( ticket != null );
Assert.IsTrue( ticket.Handle != 0 );
Assert.IsTrue( ticket.Data.Length > 0 );
ticket.Cancel();
2016-07-07 14:04:15 +01:00
Assert.IsTrue( ticket.Handle == 0 );
}
}
2016-07-07 14:15:09 +01:00
2016-07-07 14:41:28 +01:00
[TestMethod]
2016-07-07 16:55:08 +01:00
public void Update()
2016-07-07 14:41:28 +01:00
{
2016-11-03 12:09:35 +00:00
var sw = new Stopwatch();
2016-07-07 14:41:28 +01:00
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
{
2017-12-06 11:14:29 +00:00
Assert.IsTrue(client.IsValid);
2016-10-07 11:57:50 +01:00
for( int i=0; i<1024; i++ )
2016-07-07 14:41:28 +01:00
{
2016-11-03 12:09:35 +00:00
sw.Restart();
2016-07-07 14:41:28 +01:00
client.Update();
2016-11-03 12:09:35 +00:00
Console.WriteLine( $"{sw.Elapsed.TotalMilliseconds}ms" );
2016-07-07 14:41:28 +01:00
}
}
}
2017-03-13 19:58:52 +00:00
[TestMethod]
public void Subscribed()
{
var sw = new Stopwatch();
using (var client = new Facepunch.Steamworks.Client(252490))
{
Assert.IsTrue(client.IsValid);
Assert.IsTrue(client.IsSubscribed);
}
}
[TestMethod]
public void Owner()
{
var sw = new Stopwatch();
using (var client = new Facepunch.Steamworks.Client(252490))
{
Assert.IsTrue(client.IsValid);
Assert.AreEqual(client.OwnerSteamId, client.SteamId);
}
}
[TestMethod]
public void InstallFolder()
{
var sw = new Stopwatch();
using (var client = new Facepunch.Steamworks.Client(252490))
{
Assert.IsTrue(client.IsValid);
Assert.IsTrue(client.InstallFolder.Exists);
Console.Write($"Install Folder: {client.InstallFolder}");
}
}
[TestMethod]
public void CurrentLanguage()
{
var sw = new Stopwatch();
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
{
Assert.IsTrue( client.IsValid );
Assert.IsTrue( client.CurrentLanguage != null );
Assert.IsTrue( client.CurrentLanguage.Length > 0 );
Console.Write( $"CurrentLanguage: {client.CurrentLanguage}" );
}
}
[TestMethod]
public void AvailableLanguages()
{
var sw = new Stopwatch();
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
{
Assert.IsTrue( client.IsValid );
Assert.IsTrue( client.AvailableLanguages != null );
Assert.IsTrue( client.AvailableLanguages.Length > 0 );
foreach ( var lang in client.AvailableLanguages )
{
Console.Write( $"AvailableLanguages: {lang}" );
}
}
}
2017-03-13 19:58:52 +00:00
[TestMethod]
public void Cybercafe()
{
var sw = new Stopwatch();
using (var client = new Facepunch.Steamworks.Client(252490))
{
Assert.IsTrue(client.IsValid);
Assert.IsFalse(client.IsCybercafe);
}
}
[TestMethod]
public void LowViolence()
{
var sw = new Stopwatch();
using (var client = new Facepunch.Steamworks.Client(252490))
{
Assert.IsTrue(client.IsValid);
Assert.IsFalse(client.IsLowViolence);
}
}
2016-07-06 17:37:25 +01:00
}
}