added more test timeouts

This commit is contained in:
Garry Newman 2018-01-31 11:28:47 +00:00
parent 5991839c27
commit 650d221baf
2 changed files with 44 additions and 7 deletions

View File

@ -122,12 +122,17 @@ namespace Facepunch.Steamworks.Test
client.Inventory.Refresh(); client.Inventory.Refresh();
var stopwatch = Stopwatch.StartNew();
// //
// Block until we have the items // Block until we have the items
// //
while ( client.Inventory.SerializedItems == null ) while ( client.Inventory.SerializedItems == null )
{ {
client.Update(); client.Update();
if (stopwatch.Elapsed.Seconds > 10)
throw new System.Exception("Getting SerializedItems took too long");
} }
Assert.IsNotNull( client.Inventory.SerializedItems ); Assert.IsNotNull( client.Inventory.SerializedItems );
@ -140,7 +145,15 @@ namespace Facepunch.Steamworks.Test
var result = server.Inventory.Deserialize( client.Inventory.SerializedItems ); var result = server.Inventory.Deserialize( client.Inventory.SerializedItems );
server.UpdateWhile( () => result.IsPending ); stopwatch = Stopwatch.StartNew();
while (result.IsPending)
{
server.Update();
if (stopwatch.Elapsed.Seconds > 10)
throw new System.Exception("result took too long");
}
Assert.IsFalse( result.IsPending ); Assert.IsFalse( result.IsPending );
Assert.IsNotNull( result.Items ); Assert.IsNotNull( result.Items );

View File

@ -73,10 +73,16 @@ namespace Facepunch.Steamworks.Test
{ {
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 );
@ -115,10 +121,16 @@ namespace Facepunch.Steamworks.Test
{ {
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 );
while ( !board.IsValid ) var time = Stopwatch.StartNew();
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 );
@ -153,10 +165,16 @@ namespace Facepunch.Steamworks.Test
{ {
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 );
while ( !board.IsValid ) var time = Stopwatch.StartNew();
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 );
@ -189,10 +207,16 @@ namespace Facepunch.Steamworks.Test
{ {
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 );
while ( !board.IsValid ) var time = Stopwatch.StartNew();
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 );