Skip to content

Add API docs for AzureAppServices and SignalR.Specification #28963

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

Merged
merged 2 commits into from
Jan 6, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

namespace Microsoft.AspNetCore.Hosting
{
/// <summary>
/// Extension method to add Azure AppServices integration to the app.
/// </summary>
public static class AppServicesWebHostBuilderExtensions
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>ASP.NET Core integration with Azure AppServices.</Description>
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore;azure;appservices</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

namespace Microsoft.AspNetCore.SignalR.Tests
{
public class DefaultHubLifetimeManagerTests : HubLifetimeManagerTestsBase<MyHub>
public class DefaultHubLifetimeManagerTests : HubLifetimeManagerTestsBase<Hub>
{
public override HubLifetimeManager<MyHub> CreateNewHubLifetimeManager()
public override HubLifetimeManager<Hub> CreateNewHubLifetimeManager()
{
return new DefaultHubLifetimeManager<MyHub>(new Logger<DefaultHubLifetimeManager<MyHub>>(NullLoggerFactory.Instance));
return new DefaultHubLifetimeManager<Hub>(new Logger<DefaultHubLifetimeManager<Hub>>(NullLoggerFactory.Instance));
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.SignalR.Protocol;
using Microsoft.AspNetCore.SignalR.Tests;
using Xunit;

namespace Microsoft.AspNetCore.SignalR.Specification.Tests
{
/// <summary>
/// Base test class for lifetime manager implementations. Nothing specific to scale-out for these tests.
/// </summary>
/// <typeparam name="THub">The type of the <see cref="Hub"/>.</typeparam>
public abstract class HubLifetimeManagerTestsBase<THub> where THub : Hub
{
/// <summary>
/// This API is obsolete and will be removed in a future version. Use CreateNewHubLifetimeManager in tests instead.
/// </summary>
[Obsolete("This API is obsolete and will be removed in a future version. Use CreateNewHubLifetimeManager in tests instead.")]
public HubLifetimeManager<THub> Manager { get; set; }
Copy link
Member Author

@BrennanConroy BrennanConroy Dec 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically a breaking change, but no one uses this package so... 🤷

Also, it didn't do anything before.

Copy link
Contributor

@pranavkm pranavkm Jan 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep this. We could consider Obsoleting it though.


/// <summary>
/// Method to create an implementation of <see cref="HubLifetimeManager{THub}"/> for use in tests.
/// </summary>
/// <returns>The implementation of <see cref="HubLifetimeManager{THub}"/> to test against.</returns>
public abstract HubLifetimeManager<THub> CreateNewHubLifetimeManager();

/// <summary>
/// Specification test for SignalR HubLifetimeManager.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
[Fact]
public async Task SendAllAsyncWritesToAllConnectionsOutput()
{
Expand Down Expand Up @@ -41,6 +58,10 @@ public async Task SendAllAsyncWritesToAllConnectionsOutput()
}
}

/// <summary>
/// Specification test for SignalR HubLifetimeManager.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
[Fact]
public async Task SendAllAsyncDoesNotWriteToDisconnectedConnectionsOutput()
{
Expand All @@ -67,6 +88,10 @@ public async Task SendAllAsyncDoesNotWriteToDisconnectedConnectionsOutput()
}
}

/// <summary>
/// Specification test for SignalR HubLifetimeManager.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
[Fact]
public async Task SendGroupAsyncWritesToAllConnectionsInGroupOutput()
{
Expand All @@ -93,6 +118,10 @@ public async Task SendGroupAsyncWritesToAllConnectionsInGroupOutput()
}
}

/// <summary>
/// Specification test for SignalR HubLifetimeManager.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
[Fact]
public async Task SendGroupExceptAsyncDoesNotWriteToExcludedConnections()
{
Expand Down Expand Up @@ -120,6 +149,10 @@ public async Task SendGroupExceptAsyncDoesNotWriteToExcludedConnections()
}
}

/// <summary>
/// Specification test for SignalR HubLifetimeManager.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
[Fact]
public async Task SendConnectionAsyncWritesToConnectionOutput()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>Tests for users to verify their own implementations of SignalR types</Description>
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
<IsPackable>true</IsPackable>
<NoWarn>$(NoWarn);CS1591</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// 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.SignalR.Protocol;
using Microsoft.AspNetCore.SignalR.Tests;
using Xunit;

namespace Microsoft.AspNetCore.SignalR.Specification.Tests
{
public abstract class ScaleoutHubLifetimeManagerTests<TBackplane> : HubLifetimeManagerTestsBase<MyHub>
/// <summary>
/// Base test class for lifetime manager implementations that support server scale-out.
/// </summary>
/// <typeparam name="TBackplane">An in-memory implementation of the backplane that <see cref="HubLifetimeManager{THub}"/>s communicate with.</typeparam>
public abstract class ScaleoutHubLifetimeManagerTests<TBackplane> : HubLifetimeManagerTestsBase<Hub>
{
/// <summary>
/// Method to create an implementation of an in-memory backplane for use in tests.
/// </summary>
/// <returns>The backplane implementation.</returns>
public abstract TBackplane CreateBackplane();
public abstract HubLifetimeManager<MyHub> CreateNewHubLifetimeManager(TBackplane backplane);

/// <summary>
/// Method to create an implementation of <see cref="HubLifetimeManager{THub}"/> that uses the backplane from <see cref="CreateBackplane"/>.
/// </summary>
/// <param name="backplane">The backplane implementation for use in the <see cref="HubLifetimeManager{THub}"/>.</param>
/// <returns></returns>
public abstract HubLifetimeManager<Hub> CreateNewHubLifetimeManager(TBackplane backplane);

private async Task AssertMessageAsync(TestClient client)
{
Expand All @@ -23,9 +35,12 @@ private async Task AssertMessageAsync(TestClient client)
Assert.Equal("World", (string)message.Arguments[0]);
}

/// <summary>
/// Specification test for SignalR HubLifetimeManager.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
[Fact]
public async Task InvokeAllAsyncWithMultipleServersWritesToAllConnectionsOutput()

{
var backplane = CreateBackplane();
var manager1 = CreateNewHubLifetimeManager(backplane);
Expand All @@ -47,6 +62,10 @@ public async Task InvokeAllAsyncWithMultipleServersWritesToAllConnectionsOutput(
}
}

/// <summary>
/// Specification test for SignalR HubLifetimeManager.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
[Fact]
public async Task InvokeAllAsyncWithMultipleServersDoesNotWriteToDisconnectedConnectionsOutput()
{
Expand All @@ -73,6 +92,10 @@ public async Task InvokeAllAsyncWithMultipleServersDoesNotWriteToDisconnectedCon
}
}

/// <summary>
/// Specification test for SignalR HubLifetimeManager.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
[Fact]
public async Task InvokeConnectionAsyncOnServerWithoutConnectionWritesOutputToConnection()
{
Expand All @@ -93,6 +116,10 @@ public async Task InvokeConnectionAsyncOnServerWithoutConnectionWritesOutputToCo
}
}

/// <summary>
/// Specification test for SignalR HubLifetimeManager.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
[Fact]
public async Task InvokeGroupAsyncOnServerWithoutConnectionWritesOutputToGroupConnection()
{
Expand All @@ -115,6 +142,10 @@ public async Task InvokeGroupAsyncOnServerWithoutConnectionWritesOutputToGroupCo
}
}

/// <summary>
/// Specification test for SignalR HubLifetimeManager.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
[Fact]
public async Task DisconnectConnectionRemovesConnectionFromGroup()
{
Expand All @@ -137,6 +168,10 @@ public async Task DisconnectConnectionRemovesConnectionFromGroup()
}
}

/// <summary>
/// Specification test for SignalR HubLifetimeManager.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
[Fact]
public async Task RemoveGroupFromLocalConnectionNotInGroupDoesNothing()
{
Expand All @@ -153,6 +188,10 @@ public async Task RemoveGroupFromLocalConnectionNotInGroupDoesNothing()
}
}

/// <summary>
/// Specification test for SignalR HubLifetimeManager.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
[Fact]
public async Task RemoveGroupFromConnectionOnDifferentServerNotInGroupDoesNothing()
{
Expand All @@ -170,6 +209,10 @@ public async Task RemoveGroupFromConnectionOnDifferentServerNotInGroupDoesNothin
}
}

/// <summary>
/// Specification test for SignalR HubLifetimeManager.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
[Fact]
public async Task AddGroupAsyncForConnectionOnDifferentServerWorks()
{
Expand All @@ -191,6 +234,10 @@ public async Task AddGroupAsyncForConnectionOnDifferentServerWorks()
}
}

/// <summary>
/// Specification test for SignalR HubLifetimeManager.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
[Fact]
public async Task AddGroupAsyncForLocalConnectionAlreadyInGroupDoesNothing()
{
Expand All @@ -213,6 +260,10 @@ public async Task AddGroupAsyncForLocalConnectionAlreadyInGroupDoesNothing()
}
}

/// <summary>
/// Specification test for SignalR HubLifetimeManager.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
[Fact]
public async Task AddGroupAsyncForConnectionOnDifferentServerAlreadyInGroupDoesNothing()
{
Expand All @@ -236,6 +287,10 @@ public async Task AddGroupAsyncForConnectionOnDifferentServerAlreadyInGroupDoesN
}
}

/// <summary>
/// Specification test for SignalR HubLifetimeManager.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
[Fact]
public async Task RemoveGroupAsyncForConnectionOnDifferentServerWorks()
{
Expand Down Expand Up @@ -263,6 +318,10 @@ public async Task RemoveGroupAsyncForConnectionOnDifferentServerWorks()
}
}

/// <summary>
/// Specification test for SignalR HubLifetimeManager.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
[Fact]
public async Task InvokeConnectionAsyncForLocalConnectionDoesNotPublishToBackplane()
{
Expand All @@ -285,6 +344,10 @@ public async Task InvokeConnectionAsyncForLocalConnectionDoesNotPublishToBackpla
}
}

/// <summary>
/// Specification test for SignalR HubLifetimeManager.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
[Fact]
public async Task WritingToRemoteConnectionThatFailsDoesNotThrow()
{
Expand All @@ -305,6 +368,10 @@ public async Task WritingToRemoteConnectionThatFailsDoesNotThrow()
}
}

/// <summary>
/// Specification test for SignalR HubLifetimeManager.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
[Fact]
public async Task WritingToGroupWithOneConnectionFailingSecondConnectionStillReceivesMessage()
{
Expand Down Expand Up @@ -336,6 +403,10 @@ public async Task WritingToGroupWithOneConnectionFailingSecondConnectionStillRec
}
}

/// <summary>
/// Specification test for SignalR HubLifetimeManager.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
[Fact]
public async Task InvokeUserSendsToAllConnectionsForUser()
{
Expand All @@ -360,6 +431,10 @@ public async Task InvokeUserSendsToAllConnectionsForUser()
}
}

/// <summary>
/// Specification test for SignalR HubLifetimeManager.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
[Fact]
public async Task StillSubscribedToUserAfterOneOfMultipleConnectionsAssociatedWithUserDisconnects()
{
Expand Down Expand Up @@ -389,7 +464,4 @@ public async Task StillSubscribedToUserAfterOneOfMultipleConnectionsAssociatedWi
}
}
}
public class MyHub : Hub
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ public class TestObject
public string TestProperty { get; set; }
}

private RedisHubLifetimeManager<MyHub> CreateLifetimeManager(TestRedisServer server, MessagePackHubProtocolOptions messagePackOptions = null, NewtonsoftJsonHubProtocolOptions jsonOptions = null)
private RedisHubLifetimeManager<Hub> CreateLifetimeManager(TestRedisServer server, MessagePackHubProtocolOptions messagePackOptions = null, NewtonsoftJsonHubProtocolOptions jsonOptions = null)
{
var options = new RedisOptions() { ConnectionFactory = async (t) => await Task.FromResult(new TestConnectionMultiplexer(server)) };
messagePackOptions = messagePackOptions ?? new MessagePackHubProtocolOptions();
jsonOptions = jsonOptions ?? new NewtonsoftJsonHubProtocolOptions();
return new RedisHubLifetimeManager<MyHub>(
NullLogger<RedisHubLifetimeManager<MyHub>>.Instance,
return new RedisHubLifetimeManager<Hub>(
NullLogger<RedisHubLifetimeManager<Hub>>.Instance,
Options.Create(options),
new DefaultHubProtocolResolver(new IHubProtocol[]
{
Expand Down