Skip to content

Commit

Permalink
move signalr and management e2e test to standalone project (#579)
Browse files Browse the repository at this point in the history
* move signalr and management e2e test to standalone project 

avoid HttpClientConnection version conflict

* remove unnecessary pkg
  • Loading branch information
wanlwanl authored Jul 8, 2019
1 parent 986be83 commit bf20f07
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
[assembly: InternalsVisibleTo("Microsoft.Azure.SignalR.Tests.Common, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.Azure.SignalR.Management, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.Azure.SignalR.Management.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.Azure.SignalR.E2ETests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
Original file line number Diff line number Diff line change
@@ -1,8 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\Microsoft.Azure.SignalR.Tests\JwtTokenHelper.cs" Link="JwtTokenHelper.cs" />
</ItemGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
<PackageReference Include="xunit" Version="$(XunitPackageVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitRunnerVisualStudioPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="$(MicrosoftAspNetCoreSignalRClientTest)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Microsoft.Azure.SignalR.Tests.Common\Microsoft.Azure.SignalR.Tests.Common.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(AzureSignalRSDKE2ETest)' != 'true' ">
<ProjectReference Include="..\..\src\Microsoft.Azure.SignalR.Management\Microsoft.Azure.SignalR.Management.csproj" />
<ProjectReference Include="..\..\src\Microsoft.Azure.SignalR.Common\Microsoft.Azure.SignalR.Common.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(AzureSignalRSDKE2ETest)' == 'true' ">
<PackageReference Include="Microsoft.Azure.SignalR.Management" Version="$(ManagementSDKPackageVersionPrefix)-*" />
</ItemGroup>
</Project>
71 changes: 71 additions & 0 deletions test/Microsoft.Azure.SignalR.E2ETests/SignalR/TestHub.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Azure.SignalR.Tests.Common;

namespace Microsoft.Azure.SignalR.Tests
{
internal class TestHub : Hub
{
private TestHubConnectionManager _testHubConnectionManager;

public TestHub(TestHubConnectionManager testHubConnectionManager)
{
_testHubConnectionManager = testHubConnectionManager;
}

public override Task OnConnectedAsync()
{
_testHubConnectionManager.AddClient(Context.ConnectionId);
_testHubConnectionManager.AddUser(Context.UserIdentifier);
return Task.CompletedTask;
}

public override Task OnDisconnectedAsync(Exception exception)
{
_testHubConnectionManager.RemoveClient(Context.ConnectionId);
_testHubConnectionManager.RemoveUser(Context.UserIdentifier);
return Task.CompletedTask;
}

public void Echo(string message)
{
Clients.Caller.SendAsync(nameof(Echo), message);
}

public void SendToClient(string message)
{
var ind = StaticRandom.Next(0, _testHubConnectionManager.ClientCount);
Clients.Client(_testHubConnectionManager.Clients[ind]).SendAsync(nameof(SendToClient), message);
}

public void SendToUser(string message)
{
var ind = StaticRandom.Next(0, _testHubConnectionManager.UserCount);
Clients.User(_testHubConnectionManager.Users[ind]).SendAsync(nameof(SendToUser), message);
}

public void Broadcast(string message)
{
Clients.All.SendAsync(nameof(Broadcast), message);
}

public Task JoinGroup(string groupName)
{
return Groups.AddToGroupAsync(Context.ConnectionId, groupName);
}

public Task LeaveGroup(string groupName)
{
return Groups.RemoveFromGroupAsync(Context.ConnectionId, groupName);
}

public void SendToGroup(string groupName, string message)
{
Clients.Group(groupName).SendAsync(nameof(SendToGroup), message);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
<PackageReference Include="xunit" Version="$(XunitPackageVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitRunnerVisualStudioPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="$(MicrosoftAspNetCoreSignalRClientTest)" />
</ItemGroup>

<ItemGroup>
Expand Down
62 changes: 0 additions & 62 deletions test/Microsoft.Azure.SignalR.Tests/Infrastructure/TestHub.cs
Original file line number Diff line number Diff line change
@@ -1,73 +1,11 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Concurrent;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Azure.SignalR.Tests.Common;

namespace Microsoft.Azure.SignalR.Tests
{
internal class TestHub : Hub
{
private TestHubConnectionManager _testHubConnectionManager;

public TestHub(TestHubConnectionManager testHubConnectionManager)
{
_testHubConnectionManager = testHubConnectionManager;
}

public override Task OnConnectedAsync()
{
_testHubConnectionManager.AddClient(Context.ConnectionId);
_testHubConnectionManager.AddUser(Context.UserIdentifier);
return Task.CompletedTask;
}

public override Task OnDisconnectedAsync(Exception exception)
{
_testHubConnectionManager.RemoveClient(Context.ConnectionId);
_testHubConnectionManager.RemoveUser(Context.UserIdentifier);
return Task.CompletedTask;
}

public void Echo(string message)
{
Clients.Caller.SendAsync(nameof(Echo), message);
}

public void SendToClient(string message)
{
var ind = StaticRandom.Next(0, _testHubConnectionManager.ClientCount);
Clients.Client(_testHubConnectionManager.Clients[ind]).SendAsync(nameof(SendToClient), message);
}

public void SendToUser(string message)
{
var ind = StaticRandom.Next(0, _testHubConnectionManager.UserCount);
Clients.User(_testHubConnectionManager.Users[ind]).SendAsync(nameof(SendToUser), message);
}

public void Broadcast(string message)
{
Clients.All.SendAsync(nameof(Broadcast), message);
}

public Task JoinGroup(string groupName)
{
return Groups.AddToGroupAsync(Context.ConnectionId, groupName);
}

public Task LeaveGroup(string groupName)
{
return Groups.RemoveFromGroupAsync(Context.ConnectionId, groupName);
}

public void SendToGroup(string groupName, string message)
{
Clients.Group(groupName).SendAsync(nameof(SendToGroup), message);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<PackageReference Include="Moq" Version="$(MoqPackageVersion)" />
<PackageReference Include="xunit" Version="$(XunitPackageVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitRunnerVisualStudioPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="$(MicrosoftAspNetCoreSignalRClientTest)" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="$(MicrosoftAspNetCoreSignalRProtocolsMessagePackTestPackageVersion)" />
</ItemGroup>

Expand Down

0 comments on commit bf20f07

Please sign in to comment.