mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 18:26:31 +00:00
Errors sending to UI
notifying client of AI model conversion
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
using Azaion.Common.Extensions;
|
||||
using FluentAssertions;
|
||||
using Xunit;
|
||||
|
||||
namespace Azaion.Annotator.Test;
|
||||
|
||||
public class ThrottleTest
|
||||
{
|
||||
private readonly Guid _testTaskId = Guid.NewGuid();
|
||||
|
||||
[Fact]
|
||||
public async Task TestScheduleAfterCooldown()
|
||||
{
|
||||
var calls = new List<DateTime>();
|
||||
|
||||
Console.WriteLine($"Start time: {DateTime.Now}");
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
ThrottleExt.Throttle(() =>
|
||||
{
|
||||
calls.Add(DateTime.Now);
|
||||
return Task.CompletedTask;
|
||||
}, _testTaskId, TimeSpan.FromSeconds(1), scheduleCallAfterCooldown: true);
|
||||
}
|
||||
|
||||
await Task.Delay(TimeSpan.FromSeconds(2));
|
||||
Console.WriteLine(string.Join(',', calls));
|
||||
|
||||
calls.Count.Should().Be(2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TestScheduleAfterCooldown2()
|
||||
{
|
||||
var calls = new List<DateTime>();
|
||||
|
||||
Console.WriteLine($"Start time: {DateTime.Now}");
|
||||
ThrottleExt.Throttle(() =>
|
||||
{
|
||||
calls.Add(DateTime.Now);
|
||||
return Task.CompletedTask;
|
||||
}, _testTaskId, TimeSpan.FromSeconds(1), scheduleCallAfterCooldown: true);
|
||||
await Task.Delay(TimeSpan.FromSeconds(2));
|
||||
|
||||
ThrottleExt.Throttle(() =>
|
||||
{
|
||||
calls.Add(DateTime.Now);
|
||||
return Task.CompletedTask;
|
||||
}, _testTaskId, TimeSpan.FromSeconds(1), scheduleCallAfterCooldown: true);
|
||||
|
||||
|
||||
await Task.Delay(TimeSpan.FromSeconds(2));
|
||||
Console.WriteLine(string.Join(',', calls));
|
||||
|
||||
calls.Count.Should().Be(2);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user