2019-12-23 05:43:15 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
2020-03-26 04:25:48 +00:00
|
|
|
|
using Xunit;
|
2019-12-23 05:43:15 +00:00
|
|
|
|
|
2020-03-26 04:25:48 +00:00
|
|
|
|
namespace Wabbajack.Common.Test
|
2019-12-23 05:43:15 +00:00
|
|
|
|
{
|
|
|
|
|
public class TaskExtTests
|
|
|
|
|
{
|
2020-04-20 22:27:15 +00:00
|
|
|
|
/* TODO: this is flakey
|
2020-03-26 04:25:48 +00:00
|
|
|
|
[Fact]
|
2019-12-23 05:43:15 +00:00
|
|
|
|
public async Task TimeoutButContinue_Typical()
|
|
|
|
|
{
|
|
|
|
|
bool timedOut = false;
|
|
|
|
|
await Task.Delay(100).TimeoutButContinue(TimeSpan.FromSeconds(1), () => timedOut = true);
|
2020-03-26 04:25:48 +00:00
|
|
|
|
Assert.False(timedOut);
|
2019-12-23 05:43:15 +00:00
|
|
|
|
}
|
2020-04-20 22:27:15 +00:00
|
|
|
|
*/
|
2019-12-23 05:43:15 +00:00
|
|
|
|
|
2020-03-26 04:25:48 +00:00
|
|
|
|
[Fact]
|
2019-12-23 05:43:15 +00:00
|
|
|
|
public async Task TimeoutButContinue_TimedOut()
|
|
|
|
|
{
|
|
|
|
|
bool timedOut = false;
|
2020-03-29 20:42:45 +00:00
|
|
|
|
await Task.Delay(3000).TimeoutButContinue(TimeSpan.FromMilliseconds(100), () => timedOut = true);
|
2020-03-26 04:25:48 +00:00
|
|
|
|
Assert.True(timedOut);
|
2019-12-23 05:43:15 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|