sharee.bike-App/TestShareeLib/ViewModel/TestPollingTaskManager.cs

47 lines
1.2 KiB
C#
Raw Normal View History

2022-08-30 15:42:25 +02:00
using System.Threading.Tasks;
using NUnit.Framework;
2021-07-12 21:31:46 +02:00
using TINK.Settings;
2022-08-30 15:42:25 +02:00
using TINK.ViewModel;
2021-07-12 21:31:46 +02:00
namespace UITest.Fixtures.ObjectTests
{
2022-09-06 16:08:19 +02:00
[TestFixture]
public class TestPollingTaskManager
{
[Test]
public async Task TestStopUpdatePeriodiallyRepeated()
{
var l_oManger = new PollingUpdateTaskManager(() => Task.Delay(1000));
2021-07-12 21:31:46 +02:00
2023-08-31 12:20:06 +02:00
await l_oManger.StartAsync(new PollingParameters(new System.TimeSpan(0, 0, 2), true));
2021-07-12 21:31:46 +02:00
2023-08-31 12:20:06 +02:00
l_oManger.StopAsync().Wait();
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
// Should not lead to dead lock.
2023-08-31 12:20:06 +02:00
l_oManger.StopAsync().Wait();
2022-09-06 16:08:19 +02:00
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public async Task TestStartUpdatePeriodiallyRepeated()
{
var l_oManger = new PollingUpdateTaskManager(() => Task.Delay(1000));
2021-07-12 21:31:46 +02:00
2023-08-31 12:20:06 +02:00
await l_oManger.StartAsync(new PollingParameters(new System.TimeSpan(0, 0, 2), true));
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
// Should not lead to dead lock.
2023-08-31 12:20:06 +02:00
await l_oManger.StartAsync(new PollingParameters(new System.TimeSpan(0, 0, 2), true));
2021-07-12 21:31:46 +02:00
2023-08-31 12:20:06 +02:00
l_oManger.StopAsync().Wait();
2022-09-06 16:08:19 +02:00
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public async Task TestStopUpdatePeriodiallyNoStart()
{
var l_oManger = new PollingUpdateTaskManager(() => Task.Delay(1000));
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
// Should not lead to dead lock.
2023-08-31 12:20:06 +02:00
await l_oManger.StartAsync(new PollingParameters(new System.TimeSpan(0, 0, 2), true));
2022-09-06 16:08:19 +02:00
}
}
2021-07-12 21:31:46 +02:00
}