-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: cb loop csharp bindings (#587)
* fix: make benchmarks compatable with windows * double include * fix valgrind ubuntu * feat: cb loop csharp bindings * clang * address comments: basic usage and nullptr throw --------- Co-authored-by: zwd-ms <71728747+zwd-ms@users.noreply.github.com>
- Loading branch information
Showing
22 changed files
with
1,514 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
Oops, something went wrong.