diff --git a/build/dependencies.props b/build/dependencies.props index d450b2ee3b..391acc51c1 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -72,6 +72,8 @@ 4.6.0-preview1-26605-01 4.6.0-preview1-26605-01 2.3.1 + 2.3.1 + 2.3.1 2.4.0-beta.1.build3945 diff --git a/src/Microsoft.AspNetCore.SignalR.Specification.Tests/Microsoft.AspNetCore.SignalR.Specification.Tests.csproj b/src/Microsoft.AspNetCore.SignalR.Specification.Tests/Microsoft.AspNetCore.SignalR.Specification.Tests.csproj index ed87ce05dd..a0af3cedf3 100644 --- a/src/Microsoft.AspNetCore.SignalR.Specification.Tests/Microsoft.AspNetCore.SignalR.Specification.Tests.csproj +++ b/src/Microsoft.AspNetCore.SignalR.Specification.Tests/Microsoft.AspNetCore.SignalR.Specification.Tests.csproj @@ -2,16 +2,7 @@ Tests for users to verify their own implementations of SignalR types - - false - netcoreapp2.2 - $(DeveloperBuildTestTfms) - $(StandardTestTfms);net461 - win7-x86 - - - - $(StandardTestTfms) + netcoreapp2.2;net461 @@ -28,11 +19,8 @@ - - - - - + + diff --git a/src/Microsoft.AspNetCore.SignalR.Specification.Tests/ScaleoutHubLifetimeManagerTests.cs b/src/Microsoft.AspNetCore.SignalR.Specification.Tests/ScaleoutHubLifetimeManagerTests.cs index a8fbb1fc45..e8783b79fa 100644 --- a/src/Microsoft.AspNetCore.SignalR.Specification.Tests/ScaleoutHubLifetimeManagerTests.cs +++ b/src/Microsoft.AspNetCore.SignalR.Specification.Tests/ScaleoutHubLifetimeManagerTests.cs @@ -6,7 +6,6 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.SignalR.Protocol; using Microsoft.AspNetCore.SignalR.Tests; -using Moq; using Xunit; namespace Microsoft.AspNetCore.SignalR.Specification.Tests @@ -297,14 +296,12 @@ namespace Microsoft.AspNetCore.SignalR.Specification.Tests { // Force an exception when writing to connection var connectionMock = HubConnectionContextUtils.CreateMock(client.Connection); - connectionMock.Setup(m => m.WriteAsync(It.IsAny(), It.IsAny())).Throws(new Exception()); - var connection = connectionMock.Object; - await manager2.OnConnectedAsync(connection).OrTimeout(); + await manager2.OnConnectedAsync(connectionMock).OrTimeout(); // This doesn't throw because there is no connection.ConnectionId on this server so it has to publish to the backplane. // And once that happens there is no way to know if the invocation was successful or not. - await manager1.SendConnectionAsync(connection.ConnectionId, "Hello", new object[] { "World" }).OrTimeout(); + await manager1.SendConnectionAsync(connectionMock.ConnectionId, "Hello", new object[] { "World" }).OrTimeout(); } } @@ -319,9 +316,8 @@ namespace Microsoft.AspNetCore.SignalR.Specification.Tests { // Force an exception when writing to connection var connectionMock = HubConnectionContextUtils.CreateMock(client1.Connection); - connectionMock.Setup(m => m.WriteAsync(It.IsAny(), It.IsAny())).Throws(new Exception()); - var connection1 = connectionMock.Object; + var connection1 = connectionMock; var connection2 = HubConnectionContextUtils.Create(client2.Connection); await manager.OnConnectedAsync(connection1).OrTimeout(); diff --git a/test/Microsoft.AspNetCore.SignalR.Tests.Utils/HubConnectionContextUtils.cs b/test/Microsoft.AspNetCore.SignalR.Tests.Utils/HubConnectionContextUtils.cs index 6cb265fe74..bbbfb1db96 100644 --- a/test/Microsoft.AspNetCore.SignalR.Tests.Utils/HubConnectionContextUtils.cs +++ b/test/Microsoft.AspNetCore.SignalR.Tests.Utils/HubConnectionContextUtils.cs @@ -2,10 +2,12 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Threading; +using System.Threading.Tasks; using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.SignalR.Protocol; +using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; -using Moq; namespace Microsoft.AspNetCore.SignalR.Tests { @@ -25,13 +27,24 @@ namespace Microsoft.AspNetCore.SignalR.Tests }; } - public static Mock CreateMock(ConnectionContext connection) + public static MockHubConnectionContext CreateMock(ConnectionContext connection) { - var mock = new Mock(connection, TimeSpan.FromSeconds(15), NullLoggerFactory.Instance, TimeSpan.FromSeconds(15)) { CallBase = true }; - var protocol = new JsonHubProtocol(); - mock.SetupGet(m => m.Protocol).Returns(protocol); - return mock; + return new MockHubConnectionContext(connection, TimeSpan.FromSeconds(15), NullLoggerFactory.Instance, TimeSpan.FromSeconds(15)); + } + public class MockHubConnectionContext : HubConnectionContext + { + public MockHubConnectionContext(ConnectionContext connectionContext, TimeSpan keepAliveInterval, ILoggerFactory loggerFactory, TimeSpan clientTimeoutInterval) + : base(connectionContext, keepAliveInterval, loggerFactory, clientTimeoutInterval) + { + + } + + public override ValueTask WriteAsync(HubMessage message, CancellationToken cancellationToken = default) + { + throw new Exception(); + } } } + }