Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running RpcTests on all supported channels #78

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CoreRemoting.Tests/AsyncTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class AsyncTests : IClassFixture<ServerFixture>
public AsyncTests(ServerFixture serverFixture)
{
_serverFixture = serverFixture;
_serverFixture.Start();
}

[Fact]
Expand Down
1 change: 1 addition & 0 deletions CoreRemoting.Tests/CallContextTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class CallContextTests : IClassFixture<ServerFixture>
public CallContextTests(ServerFixture serverFixture)
{
_serverFixture = serverFixture;
_serverFixture.Start();
}

[Fact]
Expand Down
1 change: 1 addition & 0 deletions CoreRemoting.Tests/LinqExpressionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class LinqExpressionTests : IClassFixture<ServerFixture>
public LinqExpressionTests(ServerFixture serverFixture)
{
_serverFixture = serverFixture;
_serverFixture.Start();
}

[Fact]
Expand Down
7 changes: 6 additions & 1 deletion CoreRemoting.Tests/RemotingConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
namespace CoreRemoting.Tests
{
public class RemotingConfigurationTests : IClassFixture<ServerFixture>
{
{
public RemotingConfigurationTests(ServerFixture serverFixture)
{
serverFixture.Start();
}

[Fact]
public void RegisterWellKnownServiceType_should_register_type_resolved_at_runtime()
{
Expand Down
1 change: 1 addition & 0 deletions CoreRemoting.Tests/ReturnAsProxyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public ReturnAsProxyTests(ServerFixture serverFixture, ITestOutputHelper testOut
{
_serverFixture = serverFixture;
_testOutputHelper = testOutputHelper;
_serverFixture.Start();
}

[Fact]
Expand Down
26 changes: 24 additions & 2 deletions CoreRemoting.Tests/RpcTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using CoreRemoting.Channels;
using CoreRemoting.Serialization;
using CoreRemoting.Tests.ExternalTypes;
using CoreRemoting.Tests.Tools;
Expand All @@ -18,6 +19,10 @@ public class RpcTests : IClassFixture<ServerFixture>
private readonly ITestOutputHelper _testOutputHelper;
private bool _remoteServiceCalled;

protected virtual IServerChannel ServerChannel => null;

protected virtual IClientChannel ClientChannel => null;

public RpcTests(ServerFixture serverFixture, ITestOutputHelper testOutputHelper)
{
_serverFixture = serverFixture;
Expand All @@ -28,6 +33,8 @@ public RpcTests(ServerFixture serverFixture, ITestOutputHelper testOutputHelper)
_remoteServiceCalled = true;
return arg;
};

_serverFixture.Start(ServerChannel);
}

[Fact]
Expand All @@ -44,7 +51,8 @@ void ClientAction()
{
ConnectionTimeout = 0,
MessageEncryption = false,
ServerPort = _serverFixture.Server.Config.NetworkPort
Channel = ClientChannel,
ServerPort = _serverFixture.Server.Config.NetworkPort,
});

stopWatch.Stop();
Expand Down Expand Up @@ -115,8 +123,9 @@ void ClientAction()
using var client = new RemotingClient(new ClientConfig()
{
ConnectionTimeout = 0,
Channel = ClientChannel,
ServerPort = _serverFixture.Server.Config.NetworkPort,
MessageEncryption = true
MessageEncryption = true,
});

stopWatch.Stop();
Expand Down Expand Up @@ -183,6 +192,7 @@ void ClientAction()
new ClientConfig()
{
ConnectionTimeout = 0,
Channel = ClientChannel,
MessageEncryption = false,
ServerPort = _serverFixture.Server.Config.NetworkPort,
});
Expand Down Expand Up @@ -218,6 +228,7 @@ public void Events_should_work_remotely()
{
ConnectionTimeout = 0,
SendTimeout = 0,
Channel = ClientChannel,
MessageEncryption = false,
ServerPort = _serverFixture.Server.Config.NetworkPort,
});
Expand Down Expand Up @@ -270,6 +281,7 @@ void ClientAction()
using var client = new RemotingClient(new ClientConfig()
{
ConnectionTimeout = 0,
Channel = ClientChannel,
MessageEncryption = false,
ServerPort = _serverFixture.Server.Config.NetworkPort,
});
Expand Down Expand Up @@ -302,6 +314,7 @@ public void Generic_methods_should_be_called_correctly()
using var client = new RemotingClient(new ClientConfig()
{
ConnectionTimeout = 0,
Channel = ClientChannel,
MessageEncryption = false,
ServerPort = _serverFixture.Server.Config.NetworkPort,
});
Expand All @@ -320,6 +333,7 @@ public void Inherited_methods_should_be_called_correctly()
using var client = new RemotingClient(new ClientConfig()
{
ConnectionTimeout = 0,
Channel = ClientChannel,
MessageEncryption = false,
ServerPort = _serverFixture.Server.Config.NetworkPort,
});
Expand All @@ -338,6 +352,7 @@ public void Enum_arguments_should_be_passed_correctly()
using var client = new RemotingClient(new ClientConfig()
{
ConnectionTimeout = 0,
Channel = ClientChannel,
MessageEncryption = false,
ServerPort = _serverFixture.Server.Config.NetworkPort
});
Expand All @@ -360,6 +375,7 @@ public void Missing_method_throws_RemoteInvocationException()
ConnectionTimeout = 0,
InvocationTimeout = 0,
SendTimeout = 0,
Channel = ClientChannel,
MessageEncryption = false,
ServerPort = _serverFixture.Server.Config.NetworkPort
});
Expand Down Expand Up @@ -395,6 +411,7 @@ public void Missing_service_throws_RemoteInvocationException()
ConnectionTimeout = 0,
InvocationTimeout = 0,
SendTimeout = 0,
Channel = ClientChannel,
MessageEncryption = false,
ServerPort = _serverFixture.Server.Config.NetworkPort
});
Expand All @@ -419,6 +436,7 @@ public void Error_method_throws_Exception()
ConnectionTimeout = 5,
InvocationTimeout = 5,
SendTimeout = 5,
Channel = ClientChannel,
MessageEncryption = false,
ServerPort = _serverFixture.Server.Config.NetworkPort
});
Expand Down Expand Up @@ -450,6 +468,7 @@ public async Task ErrorAsync_method_throws_Exception()
ConnectionTimeout = 5,
InvocationTimeout = 5,
SendTimeout = 5,
Channel = ClientChannel,
MessageEncryption = false,
ServerPort = _serverFixture.Server.Config.NetworkPort
});
Expand Down Expand Up @@ -481,6 +500,7 @@ public void NonSerializableError_method_throws_Exception()
ConnectionTimeout = 5,
InvocationTimeout = 5,
SendTimeout = 5,
Channel = ClientChannel,
MessageEncryption = false,
ServerPort = _serverFixture.Server.Config.NetworkPort
});
Expand Down Expand Up @@ -523,6 +543,7 @@ async Task Roundtrip(bool encryption)
{
RemotingClient CreateClient() => new RemotingClient(new ClientConfig()
{
Channel = ClientChannel,
ServerPort = _serverFixture.Server.Config.NetworkPort,
MessageEncryption = encryption,
});
Expand Down Expand Up @@ -570,6 +591,7 @@ public void DataTable_roundtrip_works_issue60()
ConnectionTimeout = 0,
InvocationTimeout = 0,
SendTimeout = 0,
Channel = ClientChannel,
MessageEncryption = false,
ServerPort = _serverFixture.Server.Config.NetworkPort,
});
Expand Down
18 changes: 18 additions & 0 deletions CoreRemoting.Tests/RpcTests_WatsonTcp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using CoreRemoting.Channels;
using CoreRemoting.Channels.Tcp;
using Xunit;
using Xunit.Abstractions;

namespace CoreRemoting.Tests
{
public class RpcTests_WatsonTcp : RpcTests
{
protected override IServerChannel ServerChannel => new TcpServerChannel();

protected override IClientChannel ClientChannel => new TcpClientChannel();

public RpcTests_WatsonTcp(ServerFixture s, ITestOutputHelper h) : base(s, h)
{
}
}
}
18 changes: 18 additions & 0 deletions CoreRemoting.Tests/RpcTests_Websockets.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using CoreRemoting.Channels;
using CoreRemoting.Channels.Websocket;
using Xunit;
using Xunit.Abstractions;

namespace CoreRemoting.Tests
{
public class RpcTests_Websockets : RpcTests
{
protected override IServerChannel ServerChannel => new WebsocketServerChannel();

protected override IClientChannel ClientChannel => new WebsocketClientChannel();

public RpcTests_Websockets(ServerFixture fixture, ITestOutputHelper helper) : base(fixture, helper)
{
}
}
}
30 changes: 21 additions & 9 deletions CoreRemoting.Tests/ServerFixture.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Threading;
using CoreRemoting.Channels;
using CoreRemoting.DependencyInjection;
using CoreRemoting.Tests.Tools;
using Xunit;
Expand All @@ -14,7 +15,7 @@ public ServerFixture()
{
TestService = new TestService();

var serverConfig =
ServerConfig =
new ServerConfig()
{
UniqueServerInstanceName = "DefaultServer",
Expand Down Expand Up @@ -49,20 +50,31 @@ public ServerFixture()
lifetime: ServiceLifetime.Singleton);
}
};

Server = new RemotingServer(serverConfig);

Server.Error += (_ , _) =>
}

public void Start(IServerChannel channel = null)
{
if (Server != null)
return;

if (channel != null)
ServerConfig.Channel = channel;

Server = new RemotingServer(ServerConfig);
Server.Error += (_, _) =>
{
ServerErrorCount++;
};

Server.Start();
}

public RemotingServer Server { get; }

public RemotingServer Server { get; private set; }

public ServerConfig ServerConfig { get; set; }

public TestService TestService { get; }

public void Dispose()
{
if (Server != null)
Expand Down
1 change: 1 addition & 0 deletions CoreRemoting.Tests/SessionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class SessionTests : IClassFixture<ServerFixture>
public SessionTests(ServerFixture serverFixture)
{
_serverFixture = serverFixture;
_serverFixture.Start();
}

[Fact]
Expand Down
Loading