Facepunch.Steamworks/Facepunch.Steamworks.Test/Client/Workshop.cs

67 lines
1.9 KiB
C#
Raw Normal View History

2016-10-05 18:27:21 +03:00
using System;
using System.Text;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
namespace Facepunch.Steamworks.Test
{
[TestClass]
[DeploymentItem( Config.LibraryName + ".dll" )]
[DeploymentItem( "steam_appid.txt" )]
public class WorkshopTest
{
[TestMethod]
public void Query()
{
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
{
Assert.IsTrue( client.IsValid );
var Query = client.Workshop.CreateQuery();
Query.Run();
// Block, wait for result
// (don't do this in realtime)
Query.Block();
Assert.IsFalse( Query.IsRunning );
2016-10-05 18:52:41 +03:00
Assert.IsTrue( Query.TotalResults > 0 );
Assert.IsTrue( Query.Items.Length > 0 );
2016-10-05 18:27:21 +03:00
// results
Console.WriteLine( "Searching" );
2016-10-05 18:52:41 +03:00
Query.Order = Workshop.Order.RankedByTextSearch;
Query.QueryType = Workshop.QueryType.Items_Mtx;
2016-10-06 14:13:15 +03:00
Query.SearchText = "shit";
2016-10-05 18:27:21 +03:00
Query.Run();
// Block, wait for result
// (don't do this in realtime)
Query.Block();
2016-10-06 14:13:15 +03:00
Console.WriteLine( "Query.TotalResults: {0}", Query.TotalResults );
Console.WriteLine( "Query.Items.Length: {0}", Query.Items.Length );
2016-10-05 18:52:41 +03:00
Assert.IsTrue( Query.TotalResults > 0 );
Assert.IsTrue( Query.Items.Length > 0 );
foreach ( var item in Query.Items )
{
Console.WriteLine( "{0}", item.Title );
}
2016-10-05 18:27:21 +03:00
for ( int i=0; i<100; i++ )
{
client.Update();
Thread.Sleep( 10 );
}
}
}
}
}