diff --git a/Facepunch.Steamworks.Test/Client/InventoryTest.cs b/Facepunch.Steamworks.Test/Client/InventoryTest.cs index d4adef4..91471cb 100644 --- a/Facepunch.Steamworks.Test/Client/InventoryTest.cs +++ b/Facepunch.Steamworks.Test/Client/InventoryTest.cs @@ -122,12 +122,17 @@ public void Deserialize() client.Inventory.Refresh(); + var stopwatch = Stopwatch.StartNew(); + // // Block until we have the items // while ( client.Inventory.SerializedItems == null ) { client.Update(); + + if (stopwatch.Elapsed.Seconds > 10) + throw new System.Exception("Getting SerializedItems took too long"); } Assert.IsNotNull( client.Inventory.SerializedItems ); @@ -140,7 +145,15 @@ public void Deserialize() 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.IsNotNull( result.Items ); diff --git a/Facepunch.Steamworks.Test/Client/LeaderboardTest.cs b/Facepunch.Steamworks.Test/Client/LeaderboardTest.cs index c276fe9..cc1986a 100644 --- a/Facepunch.Steamworks.Test/Client/LeaderboardTest.cs +++ b/Facepunch.Steamworks.Test/Client/LeaderboardTest.cs @@ -73,10 +73,16 @@ public void GetLeaderboardCallback() { var board = client.GetLeaderboard( "TestLeaderboard", Steamworks.Client.LeaderboardSortMethod.Ascending, Steamworks.Client.LeaderboardDisplayType.Numeric ); + var time = Stopwatch.StartNew(); while ( !board.IsValid ) { Thread.Sleep( 10 ); client.Update(); + + if (time.Elapsed.TotalSeconds > 10) + { + throw new Exception("board.IsValid took too long"); + } } Assert.IsTrue( board.IsValid ); @@ -115,10 +121,16 @@ public void AddScores() { 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(); + + if (time.Elapsed.TotalSeconds > 10) + { + throw new Exception("board.IsValid took too long"); + } } Assert.IsTrue( board.IsValid ); @@ -153,10 +165,16 @@ public void AddScoresCallback() { 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(); + + if (time.Elapsed.TotalSeconds > 10) + { + throw new Exception("board.IsValid took too long"); + } } Assert.IsTrue( board.IsValid ); @@ -189,10 +207,16 @@ public void AddFileAttachment() { 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(); + + if (time.Elapsed.TotalSeconds > 10) + { + throw new Exception("board.IsValid took too long"); + } } Assert.IsTrue( board.IsValid );