Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cb loop csharp bindings #587

Merged
merged 11 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bindings/cs/rl.net.cli.test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
set (RL_NET_CLI_TEST_SOURCES
CleanupContainer.cs
MockSender.cs
ReplayStepProviderTest.cs
SenderExtensibilityTest.cs
SenderExtensibilityCBLoopTest.cs
TempFileDisposable.cs
TestBase.cs
UnicodeTest.cs
Expand Down
70 changes: 70 additions & 0 deletions bindings/cs/rl.net.cli.test/MockSender.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Rl.Net;
using Rl.Net.Native;

namespace Rl.Net.Cli.Test
{
using SenderFactory = Func<IReadOnlyConfiguration, ErrorCallback, ISender>;
using BackgroundErrorCallback = Action<ApiStatus>;

internal class MockSender : ISender
{
public Action<ApiStatus> Init
{
get;
set;
}

public Action<SharedBuffer, ApiStatus> Send
{
get;
set;
}

void ISender.Init(ApiStatus status)
{
if (this.Init != null)
{
this.Init(status);
}
}

void ISender.Send(SharedBuffer buffer, ApiStatus status)
{
if (this.Send != null)
{
this.Send(buffer, status);
}
}
}


internal class MockAsyncSender : AsyncSender
{
public MockAsyncSender(ErrorCallback callback) : base(callback)
{
}

public new Func<SharedBuffer, BackgroundErrorCallback, Task> Send
{
get;
set;
}

protected override Task SendAsync(SharedBuffer buffer)
{
if (this.Send != null)
{
return this.Send(buffer, this.RaiseBackgroundError);
}

return Task.CompletedTask;
}
}
}
Loading
Loading