Skip to content

Commit

Permalink
test refactoring and speedup
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaosEngine committed Nov 4, 2023
1 parent f8c249d commit 7763752
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test/InkBall.Tests/IntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static class PostRequestHelper
{
public static string ExtractAntiForgeryToken(string htmlResponseText)
{
if (htmlResponseText == null) throw new ArgumentNullException("htmlResponseText");
ArgumentNullException.ThrowIfNull(htmlResponseText);

Match match = Regex.Match(htmlResponseText, @"\<input name=""__RequestVerificationToken"" type=""hidden"" value=""([^""]+)"" \/\>");
return match.Success ? match.Groups[1].Captures[0].Value : null;
Expand Down
10 changes: 6 additions & 4 deletions test/InkBall.Tests/SignalRTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ await hub_P2.ClientToServerPoint(new InkBallPointViewModel
Status = InkBallPoint.StatusEnum.POINT_FREE_BLUE,
});
}
await Task.Delay(TimeSpan.FromSeconds(4));//wait before next action
await Task.Delay(TimeSpan.FromMicroseconds(200));//wait before next action
var pt = await hub_P1.ClientToServerPoint(new InkBallPointViewModel
{
iGameId = 1,
Expand All @@ -405,7 +405,8 @@ await hub_P2.ClientToServerPoint(new InkBallPointViewModel
});
Assert.NotNull(pt.TimeStamp);
//verify last action timestamp it not from previous action
Assert.Equal(DateTime.UtcNow, pt.TimeStamp.Value, TimeSpan.FromSeconds(2));
var utc_now = DateTime.UtcNow;
Assert.Equal(utc_now, pt.TimeStamp.Value, TimeSpan.FromSeconds(1));
pt = await hub_P2.ClientToServerPoint(new InkBallPointViewModel
{
iGameId = 1,
Expand All @@ -417,7 +418,7 @@ await hub_P2.ClientToServerPoint(new InkBallPointViewModel
Assert.NotNull(pt.TimeStamp);

//Act
await Task.Delay(TimeSpan.FromSeconds(4));//wait before next action
await Task.Delay(TimeSpan.FromMilliseconds(200));//wait before next action
var dto = await hub_P1.ClientToServerPath(new InkBallPathViewModel
{
iGameId = 1,
Expand All @@ -428,7 +429,8 @@ await hub_P2.ClientToServerPoint(new InkBallPointViewModel
//Assert
Assert.IsType<InkBallPathViewModel>(dto);
Assert.NotNull(((InkBallPathViewModel)dto).TimeStamp);
Assert.Equal(DateTime.UtcNow, ((InkBallPathViewModel)dto).TimeStamp.Value, TimeSpan.FromSeconds(2));
utc_now = DateTime.UtcNow;
Assert.Equal(utc_now, ((InkBallPathViewModel)dto).TimeStamp.Value, TimeSpan.FromSeconds(1));
}
}

Expand Down

0 comments on commit 7763752

Please sign in to comment.