added test

This commit is contained in:
Christian Köllner 2020-04-05 22:32:57 +02:00
parent bdc8240e5b
commit be10b356aa
2 changed files with 48 additions and 5 deletions

View File

@ -958,7 +958,7 @@ namespace Capnp.Net.Runtime.Tests.GenImpls
} }
} }
class TestMoreStuffImpl3 : ITestMoreStuff class TestMoreStuffImpl3 : ITestMoreStuff, ITestCallOrder
{ {
readonly TaskCompletionSource<ITestInterface> _heldCap = new TaskCompletionSource<ITestInterface>(); readonly TaskCompletionSource<ITestInterface> _heldCap = new TaskCompletionSource<ITestInterface>();
@ -987,9 +987,18 @@ namespace Capnp.Net.Runtime.Tests.GenImpls
} }
} }
public Task<ITestCallOrder> Echo(ITestCallOrder Cap, CancellationToken cancellationToken_ = default) int _echoCounter;
public Task<ITestCallOrder> Echo(ITestCallOrder cap, CancellationToken cancellationToken_ = default)
{ {
throw new NotImplementedException(); if (_echoCounter++ < 20)
{
return Task.FromResult<ITestCallOrder>(((Proxy)cap).Cast<ITestMoreStuff>(true).Echo(cap).Eager());
}
else
{
return Task.FromResult(cap);
}
} }
public Task ExpectCancel(ITestInterface Cap, CancellationToken cancellationToken_ = default) public Task ExpectCancel(ITestInterface Cap, CancellationToken cancellationToken_ = default)
@ -997,9 +1006,12 @@ namespace Capnp.Net.Runtime.Tests.GenImpls
throw new NotImplementedException(); throw new NotImplementedException();
} }
public Task<uint> GetCallSequence(uint Expected, CancellationToken cancellationToken_ = default) uint _counter;
public Task<uint> GetCallSequence(uint expected, CancellationToken cancellationToken_ = default)
{ {
throw new NotImplementedException(); Assert.AreEqual(_counter, expected);
return Task.FromResult(_counter++);
} }
public Task<string> GetEnormousString(CancellationToken cancellationToken_ = default) public Task<string> GetEnormousString(CancellationToken cancellationToken_ = default)

View File

@ -245,5 +245,36 @@ namespace Capnp.Net.Runtime.Tests
} }
} }
} }
[TestMethod]
public void SalamiTactics()
{
using (var server = SetupServer())
{
server.Main = new TestMoreStuffImpl3();
using (var client = SetupClient())
{
client.WhenConnected.Wait();
using (var main = client.GetMain<ITestMoreStuff>())
{
var echoTask = main.Echo(Proxy.Share<ITestCallOrder>(main));
Assert.IsTrue(echoTask.Wait(MediumNonDbgTimeout));
var echo = echoTask.Result;
var list = new Task<uint>[1000];
for (uint i = 0; i < list.Length; i++)
{
list[i] = echo.GetCallSequence(i);
}
Assert.IsTrue(Task.WaitAll(list, MediumNonDbgTimeout));
for (uint i = 0; i < list.Length; i++)
{
Assert.AreEqual(i, list[i].Result);
}
}
}
}
}
} }
} }