libs.capnproto-dotnetcore_R.../Capnp.Net.Runtime.Tests/ProvidedCapabilityMultiCallMock.cs

24 lines
818 B
C#
Raw Normal View History

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
{
class ProvidedCapabilityMultiCallMock : Skeleton
{
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
}
}