Errors sending to UI

notifying client of AI model conversion
This commit is contained in:
dzaitsev
2025-05-07 17:32:29 +03:00
committed by Alex Bezdieniezhnykh
42 changed files with 630 additions and 363 deletions
+57
View File
@@ -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);
}
}