Skip to content

Commit

Permalink
Update code to use new SliceService attribute (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier authored Nov 7, 2023
1 parent 7f17913 commit 5a05058
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 20 deletions.
6 changes: 4 additions & 2 deletions tests/Interop.Tests/AcmTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public async Task Idle_connection_to_IceRpc_server_remains_alive([Values] bool e
{
ConnectionOptions = new ConnectionOptions
{
Dispatcher = new IceRpc.Slice.Service(),
Dispatcher = new InlineDispatcher(
(request, cancellationToken) => new(new OutgoingResponse(request))),
EnableIceIdleCheck = enableIdleCheck,
IceIdleTimeout = TimeSpan.FromSeconds(3)
},
Expand Down Expand Up @@ -101,7 +102,8 @@ public async Task Inactive_connection_to_IceRpc_is_shutdown([Values] bool enable
{
ConnectionOptions = new ConnectionOptions
{
Dispatcher = new IceRpc.Slice.Service(),
Dispatcher = new InlineDispatcher(
(request, cancellationToken) => new(new OutgoingResponse(request))),
EnableIceIdleCheck = enableIdleCheck,
IceIdleTimeout = TimeSpan.FromSeconds(2),
InactivityTimeout = TimeSpan.FromSeconds(3)
Expand Down
5 changes: 3 additions & 2 deletions tests/Interop.Tests/RequestContextTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Interop.Tests;

[Parallelizable(scope: ParallelScope.All)]
public class RequestContextTests
public partial class RequestContextTests
{
private static IEnumerable<IDictionary<string, string>> RequestContextSource
{
Expand Down Expand Up @@ -83,7 +83,8 @@ public override string greet(string name, Current? current)
}
}

private class ChatbotTwin : Service, IGreeterService
[SliceService]
private partial class ChatbotTwin : IGreeterService
{
public IDictionary<string, string> RequestContext { get; private set; } =
ImmutableDictionary<string, string>.Empty;
Expand Down
12 changes: 5 additions & 7 deletions tests/Interop.Tests/Slice/Chatbot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@

namespace Interop.Tests.Slice;

/// <summary>A basic, reusable implementation of <see cref="GreeterDisp_" />.</summary>
public class Chatbot : GreeterDisp_
/// <summary>A basic, reusable implementation of <see cref="GreeterDisp_" /> and <see cref="IGreeterService" />.
/// </summary>
[SliceService]
public partial class Chatbot : GreeterDisp_, IGreeterService, IIceObjectService
{
public override string greet(string name, Current? current = null) => $"Hello, {name}!";
}

/// <summary>A basic, reusable implementation of <see cref="IGreeterService" />.</summary>
public class ChatbotTwin : Service, IGreeterService, IIceObjectService
{
public ValueTask<string> GreetAsync(
string name,
IFeatureCollection features,
CancellationToken cancellationToken) => new($"Hello, {name}!");
CancellationToken cancellationToken) => new(greet(name));
}
5 changes: 3 additions & 2 deletions tests/Interop.Tests/Slice/ExceptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Interop.Tests.Slice;

[Parallelizable(scope: ParallelScope.All)]
public class ExceptionTests
public partial class ExceptionTests
{
/// <summary>Throws an exception encoded with the .ice-generated code and decodes this exception with the
/// .slice-generated code.</summary>
Expand Down Expand Up @@ -139,7 +139,8 @@ private class TestEngine : EngineDisp_
internal TestEngine(UserException userException) => _userException = userException;
}

private class TestEngineTwin : Service, IEngineService
[SliceService]
private partial class TestEngineTwin : IEngineService
{
private readonly SliceException _sliceException;

Expand Down
9 changes: 5 additions & 4 deletions tests/Interop.Tests/Slice/IceObjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace Interop.Tests.Slice;

[Parallelizable(scope: ParallelScope.All)]
public class IceObjectTests
public partial class IceObjectTests
{
/// <summary>An Ice client sends ice_ping to an IceRPC service that implements Ice::Object.</summary>
[Test]
Expand Down Expand Up @@ -43,7 +43,7 @@ public async Task Ice_ping_on_Ice_object()
[Test]
public async Task Ice_isA_on_IceRPC_service()
{
await using var server = new Server(new ChatbotTwin(), new Uri("ice://127.0.0.1:0"));
await using var server = new Server(new Chatbot(), new Uri("ice://127.0.0.1:0"));
ServerAddress serverAddress = server.Listen();

using Ice.Communicator communicator = Ice.Util.initialize();
Expand Down Expand Up @@ -79,7 +79,7 @@ public async Task Ice_ids()
await using var clientConnection = new ClientConnection(adapter.GetFirstServerAddress());
var proxy1 = new IceObjectProxy(clientConnection, new Uri("ice:/hello"));

await using var server = new Server(new ChatbotTwin(), new Uri("ice://127.0.0.1:0"));
await using var server = new Server(new Chatbot(), new Uri("ice://127.0.0.1:0"));
ServerAddress serverAddress = server.Listen();
Ice.ObjectPrx proxy2 = communicator.CreateObjectPrx("hello", serverAddress);

Expand All @@ -88,7 +88,8 @@ public async Task Ice_ids()
Assert.That(async () => await proxy2.ice_idsAsync(), Is.EqualTo(ids));
}

internal class IceService : Service, IIceObjectService
[SliceService]
internal partial class IceService : IIceObjectService
{
}
}
2 changes: 1 addition & 1 deletion tests/Interop.Tests/Slice/OperationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public async Task Request_from_icerpc_client()
[Test]
public async Task Request_from_ice_client()
{
await using var server = new Server(new ChatbotTwin(), new Uri("ice://127.0.0.1:0"));
await using var server = new Server(new Chatbot(), new Uri("ice://127.0.0.1:0"));
ServerAddress serverAddress = server.Listen();

using Communicator communicator = Util.initialize();
Expand Down
5 changes: 3 additions & 2 deletions tests/Interop.Tests/Slice/TagTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace Interop.Tests.Slice;

[Parallelizable(scope: ParallelScope.All)]
public class TagTests
public partial class TagTests
{
private static IEnumerable<TestCaseData> IceClassSource
{
Expand Down Expand Up @@ -340,7 +340,8 @@ public override void opStruct(
}
}

private class TagTestServiceTwin : Service, ITagTestService
[SliceService]
private partial class TagTestServiceTwin : ITagTestService
{
internal bool? F1 { get; private set; }

Expand Down

0 comments on commit 5a05058

Please sign in to comment.