117 lines
2.4 KiB
C#
Raw Permalink Normal View History

2017-03-13 20:05:32 +00:00
using System;
2019-04-12 21:30:13 +01:00
using System.Linq;
2017-03-13 20:05:32 +00:00
using System.Text;
using System.Threading;
2019-04-12 22:53:46 +01:00
using System.Threading.Tasks;
2017-03-13 20:05:32 +00:00
using Microsoft.VisualStudio.TestTools.UnitTesting;
2019-04-12 21:30:13 +01:00
namespace Steamworks
2017-03-13 20:05:32 +00:00
{
[TestClass]
[DeploymentItem( "steam_api64.dll" )]
2019-06-25 12:36:46 +01:00
[DeploymentItem( "steam_api.dll" )]
2019-04-12 21:30:13 +01:00
public class AppTest
2017-03-13 20:05:32 +00:00
{
2019-04-12 21:30:13 +01:00
[AssemblyInitialize]
public static void AssemblyInit( TestContext context )
{
Steamworks.Dispatch.OnDebugCallback = ( type, str, server ) =>
{
Console.WriteLine( $"[Callback {type} {(server ? "server" : "client")}]" );
Console.WriteLine( str );
Console.WriteLine( $"" );
};
2020-02-28 12:10:53 +00:00
Steamworks.Dispatch.OnException = ( e ) =>
2019-05-03 14:11:05 +01:00
{
Console.Error.WriteLine( e.Message );
Console.Error.WriteLine( e.StackTrace );
Assert.Fail( e.Message );
};
2019-04-15 21:18:03 +01:00
//
// Init Client
//
Steamworks.SteamClient.Init( 252490 );
2019-04-15 21:18:03 +01:00
//
// Init Server
//
var serverInit = new SteamServerInit( "rust", "Rusty Mode" )
2019-04-15 21:18:03 +01:00
{
GamePort = 28015,
Secure = true,
QueryPort = 28016
};
Steamworks.SteamServer.Init( 252490, serverInit );
2019-04-15 21:18:03 +01:00
2019-04-16 14:21:48 +01:00
SteamServer.LogOnAnonymous();
2019-04-15 21:18:03 +01:00
2019-04-12 21:30:13 +01:00
}
[TestMethod]
public void GameLangauge()
2017-03-13 20:05:32 +00:00
{
2019-04-16 14:21:48 +01:00
var gl = SteamApps.GameLanguage;
2019-04-12 21:30:13 +01:00
Assert.IsNotNull( gl );
Assert.IsTrue( gl.Length > 3 );
2017-03-13 20:05:32 +00:00
2019-04-12 21:30:13 +01:00
Console.WriteLine( $"{gl}" );
}
2017-03-13 20:05:32 +00:00
2019-04-12 21:47:02 +01:00
[TestMethod]
public void AppInstallDir()
{
var str = SteamApps.AppInstallDir();
2019-04-12 21:47:02 +01:00
Assert.IsNotNull( str );
Assert.IsTrue( str.Length > 3 );
Console.WriteLine( $"{str}" );
}
[TestMethod]
public void AppOwner()
{
2019-04-16 14:21:48 +01:00
var steamid = SteamApps.AppOwner;
2019-04-12 21:47:02 +01:00
Assert.IsTrue( steamid.Value > 70561197960279927 );
Assert.IsTrue( steamid.Value < 80561197960279927 );
Console.WriteLine( $"{steamid.Value}" );
}
2019-04-12 21:30:13 +01:00
[TestMethod]
public void InstalledDepots()
{
var depots = SteamApps.InstalledDepots().ToArray();
2017-03-13 20:05:32 +00:00
2019-04-12 21:30:13 +01:00
Assert.IsNotNull( depots );
Assert.IsTrue( depots.Length > 0 );
2017-03-13 20:05:32 +00:00
2019-04-12 21:30:13 +01:00
foreach ( var depot in depots )
{
Console.WriteLine( $"{depot.Value}" );
}
}
2019-04-12 22:53:46 +01:00
[TestMethod]
public async Task GetFileDetails()
{
2020-02-22 20:29:37 +00:00
var fileinfo = await SteamApps.GetFileDetailsAsync( "RustClient.exe" );
2019-04-13 18:47:36 +01:00
2019-04-16 21:57:55 +01:00
Console.WriteLine( $"fileinfo.SizeInBytes: {fileinfo?.SizeInBytes}" );
Console.WriteLine( $"fileinfo.Sha1: {fileinfo?.Sha1}" );
Console.WriteLine( $"fileinfo.Flags: {fileinfo?.Flags}" );
2019-04-12 22:53:46 +01:00
}
2019-04-13 21:26:10 +01:00
[TestMethod]
2019-04-15 11:06:32 +01:00
public void CommandLine()
2019-04-13 21:26:10 +01:00
{
2019-04-16 14:21:48 +01:00
var cl = SteamApps.CommandLine;
2019-04-13 21:26:10 +01:00
Console.WriteLine( $"CommandLine: {cl}" );
}
2019-04-12 21:30:13 +01:00
}
2017-03-13 20:05:32 +00:00
}