sharee.bike-App/SharedBusinessLogic.Tests/ViewModel/TestPollingTaskManager.cs
2024-04-09 12:53:23 +02:00

46 lines
1.2 KiB
C#

using System.Threading.Tasks;
using NUnit.Framework;
using ShareeBike.Settings;
using ShareeBike.ViewModel;
namespace UITest.Fixtures.ObjectTests
{
[TestFixture]
public class TestPollingTaskManager
{
[Test]
public async Task TestStopUpdatePeriodiallyRepeated()
{
var l_oManger = new PollingUpdateTaskManager(() => Task.Delay(1000));
await l_oManger.StartAsync(new PollingParameters(new System.TimeSpan(0, 0, 2), true));
l_oManger.StopAsync().Wait();
// Should not lead to dead lock.
l_oManger.StopAsync().Wait();
}
[Test]
public async Task TestStartUpdatePeriodiallyRepeated()
{
var l_oManger = new PollingUpdateTaskManager(() => Task.Delay(1000));
await l_oManger.StartAsync(new PollingParameters(new System.TimeSpan(0, 0, 2), true));
// Should not lead to dead lock.
await l_oManger.StartAsync(new PollingParameters(new System.TimeSpan(0, 0, 2), true));
l_oManger.StopAsync().Wait();
}
[Test]
public async Task TestStopUpdatePeriodiallyNoStart()
{
var l_oManger = new PollingUpdateTaskManager(() => Task.Delay(1000));
// Should not lead to dead lock.
await l_oManger.StartAsync(new PollingParameters(new System.TimeSpan(0, 0, 2), true));
}
}
}