2016-07-06 19:37:25 +03:00
|
|
|
|
using System;
|
2016-07-19 15:32:14 +03:00
|
|
|
|
using System.Diagnostics;
|
2016-10-07 13:07:35 +03:00
|
|
|
|
using System.IO;
|
2016-11-08 15:43:49 +03:00
|
|
|
|
using System.Linq;
|
2016-07-06 19:37:25 +03:00
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
|
|
|
|
|
|
namespace Facepunch.Steamworks.Test
|
|
|
|
|
{
|
|
|
|
|
[TestClass]
|
2016-10-25 12:29:35 +03:00
|
|
|
|
[DeploymentItem( "steam_api.dll" )]
|
|
|
|
|
[DeploymentItem( "steam_api64.dll" )]
|
2016-07-13 19:14:16 +03:00
|
|
|
|
public partial class Client
|
2016-07-06 19:37:25 +03:00
|
|
|
|
{
|
|
|
|
|
[TestMethod]
|
2016-07-07 18:55:08 +03:00
|
|
|
|
public void Init()
|
2016-07-06 19:37:25 +03:00
|
|
|
|
{
|
|
|
|
|
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
|
|
|
|
|
{
|
2016-10-05 14:44:01 +03:00
|
|
|
|
Assert.IsTrue( client.IsValid );
|
2016-07-06 19:37:25 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-07 13:07:35 +03:00
|
|
|
|
[TestMethod]
|
2016-10-25 13:16:05 +03:00
|
|
|
|
public void Init_10()
|
2016-10-07 13:07:35 +03:00
|
|
|
|
{
|
2016-10-25 13:16:05 +03:00
|
|
|
|
for ( int i = 0; i < 10; i++ )
|
2016-10-07 13:07:35 +03:00
|
|
|
|
{
|
|
|
|
|
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
|
|
|
|
|
{
|
|
|
|
|
Assert.IsTrue( client.IsValid );
|
|
|
|
|
}
|
2016-10-07 13:50:49 +03:00
|
|
|
|
|
|
|
|
|
GC.Collect();
|
2016-10-07 13:07:35 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-06 19:37:25 +03:00
|
|
|
|
[TestMethod]
|
2016-07-07 18:55:08 +03:00
|
|
|
|
public void Name()
|
2016-07-06 19:37:25 +03:00
|
|
|
|
{
|
|
|
|
|
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
|
|
|
|
|
{
|
2016-10-25 13:16:05 +03:00
|
|
|
|
Assert.IsTrue( client.IsValid );
|
|
|
|
|
|
2016-07-06 19:37:25 +03:00
|
|
|
|
var username = client.Username;
|
|
|
|
|
Console.WriteLine( username );
|
2016-07-07 15:47:47 +03:00
|
|
|
|
Assert.IsNotNull( username );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
2016-07-07 18:55:08 +03:00
|
|
|
|
public void SteamId()
|
2016-07-07 15:47:47 +03:00
|
|
|
|
{
|
|
|
|
|
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
|
|
|
|
|
{
|
2016-10-25 13:16:05 +03:00
|
|
|
|
Assert.IsTrue( client.IsValid );
|
|
|
|
|
|
2016-07-07 15:47:47 +03:00
|
|
|
|
var steamid = client.SteamId;
|
|
|
|
|
Console.WriteLine( steamid );
|
|
|
|
|
Assert.AreNotEqual( 0, steamid );
|
2016-07-06 19:37:25 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-07-07 16:04:15 +03:00
|
|
|
|
|
|
|
|
|
[TestMethod]
|
2016-07-07 18:55:08 +03:00
|
|
|
|
public void AuthSessionTicket()
|
2016-07-07 16:04:15 +03:00
|
|
|
|
{
|
|
|
|
|
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
|
|
|
|
|
{
|
2016-07-07 16:11:23 +03:00
|
|
|
|
var ticket = client.Auth.GetAuthSessionTicket();
|
2016-07-07 16:04:15 +03:00
|
|
|
|
|
|
|
|
|
Assert.IsTrue( ticket != null );
|
|
|
|
|
Assert.IsTrue( ticket.Handle != 0 );
|
|
|
|
|
Assert.IsTrue( ticket.Data.Length > 0 );
|
|
|
|
|
|
2016-07-15 19:26:06 +03:00
|
|
|
|
ticket.Cancel();
|
2016-07-07 16:04:15 +03:00
|
|
|
|
|
|
|
|
|
Assert.IsTrue( ticket.Handle == 0 );
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-07-07 16:15:09 +03:00
|
|
|
|
|
2016-07-07 16:41:28 +03:00
|
|
|
|
[TestMethod]
|
2016-07-07 18:55:08 +03:00
|
|
|
|
public void Update()
|
2016-07-07 16:41:28 +03:00
|
|
|
|
{
|
2016-11-03 15:09:35 +03:00
|
|
|
|
var sw = new Stopwatch();
|
2016-07-07 16:41:28 +03:00
|
|
|
|
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
|
|
|
|
|
{
|
2017-12-06 14:14:29 +03:00
|
|
|
|
Assert.IsTrue(client.IsValid);
|
|
|
|
|
|
2016-10-07 13:57:50 +03:00
|
|
|
|
for( int i=0; i<1024; i++ )
|
2016-07-07 16:41:28 +03:00
|
|
|
|
{
|
2016-11-03 15:09:35 +03:00
|
|
|
|
sw.Restart();
|
2016-07-07 16:41:28 +03:00
|
|
|
|
client.Update();
|
2016-11-03 15:09:35 +03:00
|
|
|
|
Console.WriteLine( $"{sw.Elapsed.TotalMilliseconds}ms" );
|
|
|
|
|
|
2016-07-07 16:41:28 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-03-13 22:58:52 +03: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}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-02 12:05:48 +03:00
|
|
|
|
[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 22:58:52 +03: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 19:37:25 +03:00
|
|
|
|
}
|
|
|
|
|
}
|