Facepunch.Steamworks/Facepunch.Steamworks.Test/UgcQuery.cs

105 lines
2.3 KiB
C#
Raw Normal View History

2019-04-17 18:41:06 +03:00
using System;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Steamworks.Data;
namespace Steamworks
{
[TestClass]
[DeploymentItem( "steam_api64.dll" )]
2019-04-26 15:46:12 +03:00
public class UgcQueryTests
2019-04-17 18:41:06 +03:00
{
[TestMethod]
public async Task QueryAll()
{
2019-04-26 15:46:12 +03:00
var q = Ugc.Query.All;
2019-04-17 18:41:06 +03:00
var result = await q.GetPageAsync( 1 );
Assert.IsNotNull( result );
Console.WriteLine( $"ResultCount: {result?.ResultCount}" );
Console.WriteLine( $"TotalCount: {result?.TotalCount}" );
}
2019-04-26 14:22:27 +03:00
[TestMethod]
public async Task QueryWithTags()
{
2019-04-26 15:46:12 +03:00
var q = Ugc.Query.All
2019-04-26 14:22:27 +03:00
.WithTag( "Fun" )
.WithTag( "Movie" )
.MatchAllTags();
var result = await q.GetPageAsync( 1 );
Assert.IsNotNull( result );
Console.WriteLine( $"ResultCount: {result?.ResultCount}" );
Console.WriteLine( $"TotalCount: {result?.TotalCount}" );
foreach ( var entry in result.Value.Entries )
{
Assert.IsTrue( entry.HasTag( "Fun" ) );
Assert.IsTrue( entry.HasTag( "Movie" ) );
}
}
2019-04-17 18:41:06 +03:00
[TestMethod]
public async Task QueryAllFromFriends()
{
2019-04-26 15:46:12 +03:00
var q = Ugc.Query.All
2019-04-17 18:41:06 +03:00
.CreatedByFriends();
var result = await q.GetPageAsync( 1 );
Assert.IsNotNull( result );
Console.WriteLine( $"ResultCount: {result?.ResultCount}" );
Console.WriteLine( $"TotalCount: {result?.TotalCount}" );
foreach ( var entry in result.Value.Entries )
{
Console.WriteLine( $" {entry.Title}" );
}
}
2019-04-26 15:46:12 +03:00
[TestMethod]
public async Task QueryUserOwn()
{
var q = Ugc.UserQuery.All
.FromSelf();
var result = await q.GetPageAsync( 1 );
Assert.IsNotNull( result );
Console.WriteLine( $"ResultCount: {result?.ResultCount}" );
Console.WriteLine( $"TotalCount: {result?.TotalCount}" );
foreach ( var entry in result.Value.Entries )
{
Console.WriteLine( $" {entry.Title}" );
}
}
[TestMethod]
public async Task QueryFoohy()
{
var q = Ugc.UserQuery.All
.FromUser( 76561197997689747 );
var result = await q.GetPageAsync( 1 );
Assert.IsNotNull( result );
Console.WriteLine( $"ResultCount: {result?.ResultCount}" );
Console.WriteLine( $"TotalCount: {result?.TotalCount}" );
foreach ( var entry in result.Value.Entries )
{
Console.WriteLine( $" {entry.Title}" );
}
}
2019-04-17 18:41:06 +03:00
}
}