Unit Test timeouts

This commit is contained in:
Garry Newman 2018-01-23 12:33:49 +00:00
parent 8d202b4645
commit 5991839c27
2 changed files with 17 additions and 0 deletions

View File

@ -18,10 +18,16 @@ public void GetLeaderboard()
{ {
var board = client.GetLeaderboard( "TestLeaderboard", Steamworks.Client.LeaderboardSortMethod.Ascending, Steamworks.Client.LeaderboardDisplayType.Numeric ); var board = client.GetLeaderboard( "TestLeaderboard", Steamworks.Client.LeaderboardSortMethod.Ascending, Steamworks.Client.LeaderboardDisplayType.Numeric );
var time = Stopwatch.StartNew();
while ( !board.IsValid ) while ( !board.IsValid )
{ {
Thread.Sleep( 10 ); Thread.Sleep( 10 );
client.Update(); client.Update();
if (time.Elapsed.TotalSeconds > 10 )
{
throw new Exception("board.IsValid took too long");
}
} }
Assert.IsTrue( board.IsValid ); Assert.IsTrue( board.IsValid );
@ -35,10 +41,16 @@ public void GetLeaderboard()
board.FetchScores( Steamworks.Leaderboard.RequestType.Global, 0, 20 ); board.FetchScores( Steamworks.Leaderboard.RequestType.Global, 0, 20 );
time = Stopwatch.StartNew();
while ( board.IsQuerying ) while ( board.IsQuerying )
{ {
Thread.Sleep( 10 ); Thread.Sleep( 10 );
client.Update(); client.Update();
if (time.Elapsed.TotalSeconds > 10)
{
throw new Exception("board.IsQuerying took too long");
}
} }
Assert.IsFalse( board.IsError ); Assert.IsFalse( board.IsError );

View File

@ -3,6 +3,7 @@
using System.Threading; using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq; using System.Linq;
using System.Diagnostics;
namespace Facepunch.Steamworks.Test namespace Facepunch.Steamworks.Test
{ {
@ -395,6 +396,7 @@ public void DownloadFile()
var item = client.Workshop.GetItem( 844466101 ); var item = client.Workshop.GetItem( 844466101 );
var time = Stopwatch.StartNew();
if ( !item.Installed ) if ( !item.Installed )
{ {
item.Download(); item.Download();
@ -404,6 +406,9 @@ public void DownloadFile()
Thread.Sleep( 500 ); Thread.Sleep( 500 );
client.Update(); client.Update();
Console.WriteLine( "Download Progress: {0}", item.DownloadProgress ); Console.WriteLine( "Download Progress: {0}", item.DownloadProgress );
if (time.Elapsed.Seconds > 30)
throw new Exception("item.Installed Took Too Long");
} }
} }