2019-04-15 13:06:32 +03:00
|
|
|
|
using System;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
|
|
|
|
|
|
namespace Steamworks
|
|
|
|
|
{
|
|
|
|
|
[TestClass]
|
|
|
|
|
[DeploymentItem( "steam_api64.dll" )]
|
2020-02-22 23:29:37 +03:00
|
|
|
|
[DeploymentItem( "steam_api.dll" )]
|
|
|
|
|
public class UserTest
|
2019-04-15 13:06:32 +03:00
|
|
|
|
{
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void GetVoice()
|
|
|
|
|
{
|
|
|
|
|
using ( var stream = new MemoryStream() )
|
|
|
|
|
{
|
|
|
|
|
int compressed = 0;
|
|
|
|
|
|
2019-04-16 16:21:48 +03:00
|
|
|
|
SteamUser.VoiceRecord = true;
|
2019-04-15 13:06:32 +03:00
|
|
|
|
|
|
|
|
|
var sw = Stopwatch.StartNew();
|
|
|
|
|
|
|
|
|
|
while ( sw.Elapsed.TotalSeconds < 3 )
|
|
|
|
|
{
|
|
|
|
|
System.Threading.Thread.Sleep( 10 );
|
2019-04-16 16:21:48 +03:00
|
|
|
|
compressed += SteamUser.ReadVoiceData( stream );
|
2019-04-15 13:06:32 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual( compressed, stream.Length );
|
|
|
|
|
Console.WriteLine( $"compressed: {compressed}", compressed );
|
|
|
|
|
Console.WriteLine( $"stream.Length: {stream.Length}", stream.Length );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void OptimalSampleRate()
|
|
|
|
|
{
|
2019-04-16 16:21:48 +03:00
|
|
|
|
var rate = SteamUser.OptimalSampleRate;
|
2019-04-15 13:06:32 +03:00
|
|
|
|
Assert.AreNotEqual( rate, 0 );
|
2019-04-16 16:21:48 +03:00
|
|
|
|
Console.WriteLine( $"User.OptimalSampleRate: {SteamUser.OptimalSampleRate}" );
|
2019-04-15 13:06:32 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void IsLoggedOn()
|
|
|
|
|
{
|
2019-04-16 16:26:42 +03:00
|
|
|
|
Assert.AreNotEqual( false, SteamClient.IsLoggedOn );
|
|
|
|
|
Console.WriteLine( $"User.IsLoggedOn: {SteamClient.IsLoggedOn}" );
|
2019-04-15 13:06:32 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void SteamID()
|
|
|
|
|
{
|
2019-04-16 16:26:42 +03:00
|
|
|
|
Assert.AreNotEqual( 0, SteamClient.SteamId.Value );
|
|
|
|
|
Console.WriteLine( $"User.SteamID: {SteamClient.SteamId.Value}" );
|
2019-04-15 13:06:32 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void AuthSession()
|
|
|
|
|
{
|
2019-04-16 16:21:48 +03:00
|
|
|
|
var ticket = SteamUser.GetAuthSessionTicket();
|
2019-04-15 13:06:32 +03:00
|
|
|
|
|
|
|
|
|
Assert.AreNotEqual( 0, ticket.Handle );
|
|
|
|
|
Assert.AreNotEqual( 0, ticket.Data.Length );
|
|
|
|
|
Console.WriteLine( $"ticket.Handle: {ticket.Handle}" );
|
|
|
|
|
Console.WriteLine( $"ticket.Data: { string.Join( "", ticket.Data.Select( x => x.ToString( "x" ) ) ) }" );
|
|
|
|
|
|
2019-04-16 16:26:42 +03:00
|
|
|
|
var result = SteamUser.BeginAuthSession( ticket.Data, SteamClient.SteamId );
|
2019-04-15 13:06:32 +03:00
|
|
|
|
Console.WriteLine( $"result: { result }" );
|
2019-04-16 14:17:24 +03:00
|
|
|
|
Assert.AreEqual( result, BeginAuthResult.OK );
|
2019-04-15 13:06:32 +03:00
|
|
|
|
|
2019-04-16 16:26:42 +03:00
|
|
|
|
SteamUser.EndAuthSession( SteamClient.SteamId );
|
2019-04-15 13:06:32 +03:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-21 22:39:56 +03:00
|
|
|
|
[TestMethod]
|
|
|
|
|
public async Task AuthSessionAsync()
|
|
|
|
|
{
|
|
|
|
|
var ticket = await SteamUser.GetAuthSessionTicketAsync( 5.0 );
|
|
|
|
|
|
|
|
|
|
Assert.AreNotEqual( 0, ticket.Handle );
|
|
|
|
|
Assert.AreNotEqual( 0, ticket.Data.Length );
|
|
|
|
|
Console.WriteLine( $"ticket.Handle: {ticket.Handle}" );
|
|
|
|
|
Console.WriteLine( $"ticket.Data: { string.Join( "", ticket.Data.Select( x => x.ToString( "x" ) ) ) }" );
|
|
|
|
|
}
|
2019-04-15 13:06:32 +03:00
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void SteamLevel()
|
|
|
|
|
{
|
2019-04-16 16:21:48 +03:00
|
|
|
|
Assert.AreNotEqual( 0, SteamUser.SteamLevel );
|
|
|
|
|
Console.WriteLine( $"User.SteamLevel: {SteamUser.SteamLevel}" );
|
2019-04-15 13:06:32 +03:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-02 15:52:04 +03:00
|
|
|
|
[TestMethod]
|
|
|
|
|
public void Name()
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine( $"SteamClient.Name: {SteamClient.Name}" );
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-15 13:06:32 +03:00
|
|
|
|
[TestMethod]
|
|
|
|
|
public async Task GetStoreAuthUrlAsync()
|
|
|
|
|
{
|
2019-04-16 16:21:48 +03:00
|
|
|
|
var rustskins = await SteamUser.GetStoreAuthUrlAsync( "https://store.steampowered.com/itemstore/252490/" );
|
2019-04-15 13:06:32 +03:00
|
|
|
|
|
|
|
|
|
Assert.IsNotNull( rustskins );
|
|
|
|
|
Console.WriteLine( $"rustskins: {rustskins}" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void IsPhoneVerified()
|
|
|
|
|
{
|
2019-04-16 16:21:48 +03:00
|
|
|
|
Console.WriteLine( $"User.IsPhoneVerified: {SteamUser.IsPhoneVerified}" );
|
2019-04-15 13:06:32 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void IsTwoFactorEnabled()
|
|
|
|
|
{
|
2019-04-16 16:21:48 +03:00
|
|
|
|
Console.WriteLine( $"User.IsTwoFactorEnabled: {SteamUser.IsTwoFactorEnabled}" );
|
2019-04-15 13:06:32 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void IsPhoneIdentifying()
|
|
|
|
|
{
|
2019-04-16 16:21:48 +03:00
|
|
|
|
Console.WriteLine( $"User.IsPhoneIdentifying: {SteamUser.IsPhoneIdentifying}" );
|
2019-04-15 13:06:32 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void IsPhoneRequiringVerification()
|
|
|
|
|
{
|
2019-04-16 16:21:48 +03:00
|
|
|
|
Console.WriteLine( $"User.IsPhoneRequiringVerification: {SteamUser.IsPhoneRequiringVerification}" );
|
2019-04-15 13:06:32 +03:00
|
|
|
|
}
|
2019-05-07 22:21:06 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public async Task RequestEncryptedAppTicketAsyncWithData()
|
|
|
|
|
{
|
2020-02-25 16:29:15 +03:00
|
|
|
|
for ( int i=0; i<10; i++ )
|
|
|
|
|
{
|
|
|
|
|
var data = await SteamUser.RequestEncryptedAppTicketAsync( new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 } );
|
|
|
|
|
|
|
|
|
|
if ( data == null )
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine( $"Attempt {i}: Returned null.. waiting 1 seconds" );
|
|
|
|
|
await Task.Delay( 10000 );
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Console.WriteLine( $"data: {string.Join( "", data.Select( x => x.ToString( "x" ) ) )}" );
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-05-07 22:21:06 +03:00
|
|
|
|
|
2020-02-25 16:29:15 +03:00
|
|
|
|
Assert.Fail();
|
2019-05-07 22:21:06 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public async Task RequestEncryptedAppTicketAsync()
|
|
|
|
|
{
|
2020-02-25 16:29:15 +03:00
|
|
|
|
for ( int i = 0; i < 6; i++ )
|
|
|
|
|
{
|
|
|
|
|
var data = await SteamUser.RequestEncryptedAppTicketAsync();
|
|
|
|
|
|
|
|
|
|
if ( data == null )
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine( $"Attempt {i}: Returned null.. waiting 1 seconds" );
|
|
|
|
|
await Task.Delay( 10000 );
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Console.WriteLine( $"data: {string.Join( "", data.Select( x => x.ToString( "x" ) ) )}" );
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-05-07 22:21:06 +03:00
|
|
|
|
|
2020-02-25 16:29:15 +03:00
|
|
|
|
Assert.Fail();
|
2019-05-07 22:21:06 +03:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-15 13:06:32 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|