From 5991839c278d60413c8d8d21a461644cde04b0a7 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Tue, 23 Jan 2018 12:33:49 +0000 Subject: [PATCH] Unit Test timeouts --- Facepunch.Steamworks.Test/Client/LeaderboardTest.cs | 12 ++++++++++++ Facepunch.Steamworks.Test/Client/WorkshopTest.cs | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/Facepunch.Steamworks.Test/Client/LeaderboardTest.cs b/Facepunch.Steamworks.Test/Client/LeaderboardTest.cs index 561b079..c276fe9 100644 --- a/Facepunch.Steamworks.Test/Client/LeaderboardTest.cs +++ b/Facepunch.Steamworks.Test/Client/LeaderboardTest.cs @@ -18,10 +18,16 @@ public void GetLeaderboard() { 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 ); @@ -35,10 +41,16 @@ public void GetLeaderboard() board.FetchScores( Steamworks.Leaderboard.RequestType.Global, 0, 20 ); + time = Stopwatch.StartNew(); while ( board.IsQuerying ) { Thread.Sleep( 10 ); client.Update(); + + if (time.Elapsed.TotalSeconds > 10) + { + throw new Exception("board.IsQuerying took too long"); + } } Assert.IsFalse( board.IsError ); diff --git a/Facepunch.Steamworks.Test/Client/WorkshopTest.cs b/Facepunch.Steamworks.Test/Client/WorkshopTest.cs index a96b01f..39b6b93 100644 --- a/Facepunch.Steamworks.Test/Client/WorkshopTest.cs +++ b/Facepunch.Steamworks.Test/Client/WorkshopTest.cs @@ -3,6 +3,7 @@ using System.Threading; using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Linq; +using System.Diagnostics; namespace Facepunch.Steamworks.Test { @@ -395,6 +396,7 @@ public void DownloadFile() var item = client.Workshop.GetItem( 844466101 ); + var time = Stopwatch.StartNew(); if ( !item.Installed ) { item.Download(); @@ -404,6 +406,9 @@ public void DownloadFile() Thread.Sleep( 500 ); client.Update(); Console.WriteLine( "Download Progress: {0}", item.DownloadProgress ); + + if (time.Elapsed.Seconds > 30) + throw new Exception("item.Installed Took Too Long"); } }