2019-06-12 21:56:55 +02:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
2019-06-22 18:43:30 -04:00
|
|
|
|
using System.Threading.Tasks.Dataflow;
|
2019-06-12 21:56:55 +02:00
|
|
|
|
using Capnp.Rpc;
|
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
|
|
|
|
|
|
namespace Capnp.Net.Runtime.Tests
|
|
|
|
|
{
|
2020-04-10 18:29:06 +02:00
|
|
|
|
class ProvidedCapabilityMultiCallMock : RefCountingSkeleton
|
2019-06-12 21:56:55 +02:00
|
|
|
|
{
|
2019-11-06 14:16:20 +01:00
|
|
|
|
readonly BufferBlock<TestCallContext> _ccs = new BufferBlock<TestCallContext>();
|
2019-06-12 21:56:55 +02:00
|
|
|
|
|
|
|
|
|
public override Task<AnswerOrCounterquestion> Invoke(ulong interfaceId, ushort methodId,
|
|
|
|
|
DeserializerState args, CancellationToken cancellationToken = default(CancellationToken))
|
|
|
|
|
{
|
2019-11-06 14:16:20 +01:00
|
|
|
|
var cc = new TestCallContext(interfaceId, methodId, args, cancellationToken);
|
2019-06-12 21:56:55 +02:00
|
|
|
|
Assert.IsTrue(_ccs.Post(cc));
|
|
|
|
|
return cc.Result.Task;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-06 14:16:20 +01:00
|
|
|
|
public Task<TestCallContext> WhenCalled => _ccs.ReceiveAsync();
|
2019-06-12 21:56:55 +02:00
|
|
|
|
}
|
|
|
|
|
}
|