Added Workshop.UserQuery Test

This commit is contained in:
Garry Newman 2016-10-12 10:20:02 +01:00
parent 029cad5514
commit b304b8ce64
3 changed files with 54 additions and 0 deletions

View File

@ -306,5 +306,38 @@ public void CreatePublish()
}
}
[TestMethod]
public void UserQuery()
{
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
{
Assert.IsTrue( client.IsValid );
var Query = client.Workshop.CreateQuery();
Query.UserId = 76561197960279927;
Query.UserQueryType = Workshop.UserQueryType.Published;
Query.Run();
// Block, wait for result
// (don't do this in realtime)
Query.Block();
Assert.IsFalse( Query.IsRunning );
Assert.IsTrue( Query.TotalResults > 0 );
Assert.IsTrue( Query.Items.Length > 0 );
Console.WriteLine( "Query.TotalResults: {0}", Query.TotalResults );
Console.WriteLine( "Query.Items.Length: {0}", Query.Items.Length );
foreach ( var item in Query.Items )
{
Console.WriteLine( "{0}", item.Title );
Assert.AreEqual<ulong>( item.OwnerId, 76561197960279927 );
}
}
}
}
}

View File

@ -38,6 +38,10 @@ public class Query : IDisposable
public int TotalResults { get; set; }
public ulong? UserId { get; set; }
public UserQueryType UserQueryType { get; set; } = UserQueryType.Published;
/// <summary>
/// Page starts at 1 !!
/// </summary>
@ -61,6 +65,11 @@ public unsafe void Run()
Handle = workshop.ugc.CreateQueryUGCDetailsRequest( (IntPtr)array, (uint)fileArray.Length );
}
}
else if ( UserId.HasValue )
{
uint accountId = (uint)( UserId.Value & 0xFFFFFFFFul );
Handle = workshop.ugc.CreateQueryUserUGCRequest( accountId, (uint) UserQueryType, (uint)QueryType, (uint)Order, UploaderAppId, AppId, (uint)Page );
}
else
{
Handle = workshop.ugc.CreateQueryAllUGCRequest( (uint)Order, (uint)QueryType, UploaderAppId, AppId, (uint)Page );

View File

@ -125,6 +125,18 @@ public enum ItemType
GameManagedItem = 15, // managed completely by the game, not the user, and not shown on the web
};
public enum UserQueryType : uint
{
Published = 0,
VotedOn,
VotedUp,
VotedDown,
WillVoteLater,
Favorited,
Subscribed,
UsedOrPlayed,
Followed,
}
}