-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8984d22
commit 515bb98
Showing
8 changed files
with
133 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
test/Microsoft.Azure.SignalR.AspNet.Tests/ConnectionFactoryTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Microsoft.Extensions.Logging.Abstractions; | ||
|
||
using Xunit; | ||
|
||
namespace Microsoft.Azure.SignalR.AspNet.Tests; | ||
|
||
#nullable enable | ||
|
||
public class ConnectionFactoryTests | ||
{ | ||
[Fact] | ||
public void TestGetRequestHeaders() | ||
{ | ||
var nameProvider = new DefaultServerNameProvider(); | ||
|
||
var loggerFactory = NullLoggerFactory.Instance; | ||
|
||
var factory = new ConnectionFactory(nameProvider, loggerFactory); | ||
|
||
var headers = factory.GetRequestHeaders(); | ||
Assert.True(headers.TryGetValue(Constants.AsrsUserAgent, out var productInfo)); | ||
Assert.StartsWith("Microsoft.Azure.SignalR.AspNet/", productInfo); | ||
|
||
Assert.True(headers.TryGetValue(Constants.Headers.AsrsServerId, out var serverId)); | ||
Assert.Equal(nameProvider.GetName(), serverId); | ||
} | ||
|
||
[Fact] | ||
public void TestGetServerIdInRequestHeaders() | ||
{ | ||
var nameProvider1 = new DefaultServerNameProvider(); | ||
var nameProvider2 = new DefaultServerNameProvider(); | ||
|
||
var name1 = nameProvider1.GetName(); | ||
var name2 = nameProvider2.GetName(); | ||
Assert.NotEqual(name1, name2); | ||
|
||
static string GetServerId(IServerNameProvider nameProvider) | ||
{ | ||
var connectionFactory = new ConnectionFactory(nameProvider, NullLoggerFactory.Instance); | ||
var headers = connectionFactory.GetRequestHeaders(); | ||
Assert.True(headers.TryGetValue(Constants.Headers.AsrsServerId, out var serverId)); | ||
return serverId; | ||
} | ||
|
||
var serverId1 = GetServerId(nameProvider1); | ||
var serverId2 = GetServerId(nameProvider2); | ||
Assert.NotEqual(serverId1, serverId2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters