Skip to content

Commit bad992a

Browse files
authored
Merge pull request #26 from NightAngell/net7Update
Net7 update
2 parents 78b3175 + c786f72 commit bad992a

32 files changed

+410
-214
lines changed

Directory.Build.props

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
<!--Supported values:
66
{net5.0, netstandard2.1},
77
{net6.0, net6.0}
8+
{net7.0, net7.0}
89
It is also important to made sure that tests and example project have valid dependencies-->
9-
<TargetFrameworkForExampleAndTests>net6.0</TargetFrameworkForExampleAndTests>
10-
<TargetFrameworkForLib>net6.0</TargetFrameworkForLib>
10+
<TargetFrameworkForExampleAndTests>net7.0</TargetFrameworkForExampleAndTests>
11+
<TargetFrameworkForLib>net7.0</TargetFrameworkForLib>
1112

12-
<EntityFrameworkMinSupportedVersion>6.0.0</EntityFrameworkMinSupportedVersion>
13-
<EntityFrameworkCurrentVersion>6.0.*</EntityFrameworkCurrentVersion>
14-
<MicrosoftTestSDKVersion>17.1.0</MicrosoftTestSDKVersion>
13+
<EntityFrameworkMinSupportedVersion>7.0.0</EntityFrameworkMinSupportedVersion>
14+
<EntityFrameworkCurrentVersion>7.0.*</EntityFrameworkCurrentVersion>
15+
<MicrosoftTestSDKVersion>17.4.0</MicrosoftTestSDKVersion>
1516
</PropertyGroup>
1617

1718
<!-- Unit testing support nugets related config.
@@ -24,7 +25,7 @@
2425
<UseUnitTestingSupportNugetsInsteadOfProjects>false</UseUnitTestingSupportNugetsInsteadOfProjects>
2526

2627
<!--Used only if UseUnitTestingSupportNugetsInsteadOfProjects is set to true -->
27-
<UnitTestingSupportNugetsVersion>6.0.0</UnitTestingSupportNugetsVersion>
28+
<UnitTestingSupportNugetsVersion>7.0.0</UnitTestingSupportNugetsVersion>
2829
</PropertyGroup>
2930

3031
<!--StyleCop-->
@@ -54,10 +55,10 @@
5455
<NugetCopyright>MIT License (Mateusz Soboń)</NugetCopyright>
5556

5657
<!--Version-->
57-
<NugetVersion>6.0.0</NugetVersion>
58-
<NugetAssemblyVersion>6.0.0.0</NugetAssemblyVersion>
59-
<NugetFileVersion>6.0.0.0</NugetFileVersion>
60-
<NugetPackageReleaseNotes>Updated to net6.0. Updated dependencies.</NugetPackageReleaseNotes>
58+
<NugetVersion>7.0.0</NugetVersion>
59+
<NugetAssemblyVersion>7.0.0.0</NugetAssemblyVersion>
60+
<NugetFileVersion>7.0.0.0</NugetFileVersion>
61+
<NugetPackageReleaseNotes>Updated to net7.0. Updated dependencies.</NugetPackageReleaseNotes>
6162

6263
<!--Repo url-->
6364
<NuGetPackageProjectUrl>https://github.com/NightAngell/SignalR_UnitTestingSupport</NuGetPackageProjectUrl>

ExampleSignalRCoreProject/Hubs/ExampleHub.cs

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -37,76 +37,86 @@ public async Task AddNoteWithLoremIpsumAsContentToDb()
3737
await _db.SaveChangesAsync();
3838
}
3939

40-
public void NotifyAboutSomethingElseAllExcept()
40+
public async Task NotifyAboutSomethingElseAllExcept()
4141
{
4242
var excludedConnectionIds = new List<string> { };
43-
Clients.AllExcept(excludedConnectionIds.AsReadOnly()).NotifyAboutSomethingElse();
43+
await Clients.AllExcept(excludedConnectionIds.AsReadOnly()).NotifyAboutSomethingElse();
4444
}
4545

46-
public void NotifyCallerAboutSomethingElse()
46+
public async Task NotifyCallerAboutSomethingElse()
4747
{
48-
Clients.Caller.NotifyAboutSomethingElse();
48+
await Clients.Caller.NotifyAboutSomethingElse();
4949
}
5050

51-
public void NotifyClientAboutSomethingElse()
51+
public async Task NotifyClientAboutSomethingElse()
5252
{
53-
Clients.Client(string.Empty).NotifyAboutSomethingElse();
53+
await Clients.Client(string.Empty).NotifyAboutSomethingElse();
5454
}
5555

56-
public void NotifyClientsAboutSomethingElse()
56+
public async Task NotifyClientsAboutSomethingElse()
5757
{
5858
var excludedConnectionIds = new List<string> { };
59-
Clients.Clients(excludedConnectionIds).NotifyAboutSomethingElse();
59+
await Clients.Clients(excludedConnectionIds).NotifyAboutSomethingElse();
6060
}
6161

62-
public void NotifyGroupAboutSomethingElse()
62+
public async Task NotifyGroupAboutSomethingElse()
6363
{
64-
Clients.Group(string.Empty).NotifyAboutSomethingElse();
64+
await Clients.Group(string.Empty).NotifyAboutSomethingElse();
6565
}
6666

67-
public void NotifyGroupExceptAboutSomethingElse()
67+
public async Task NotifyGroupExceptAboutSomethingElse()
6868
{
69-
Clients.GroupExcept(string.Empty, new List<string>().AsReadOnly()).NotifyAboutSomethingElse();
69+
await Clients.GroupExcept(string.Empty, new List<string>().AsReadOnly()).NotifyAboutSomethingElse();
7070
}
7171

72-
public void NotifyGroupsAboutSomethingElse()
72+
public async Task NotifyGroupsAboutSomethingElse()
7373
{
74-
Clients.Groups(new List<string>().AsReadOnly()).NotifyAboutSomethingElse();
74+
await Clients.Groups(new List<string>().AsReadOnly()).NotifyAboutSomethingElse();
7575
}
7676

77-
public void NotifyOthersAboutSomethingElse()
77+
public async Task NotifyOthersAboutSomethingElse()
7878
{
79-
Clients.Others.NotifyAboutSomethingElse();
79+
await Clients.Others.NotifyAboutSomethingElse();
8080
}
8181

82-
public void NotifyOthersInGroupAboutSomethingElse()
82+
public async Task NotifyOthersInGroupAboutSomethingElse()
8383
{
84-
Clients.OthersInGroup(string.Empty).NotifyAboutSomethingElse();
84+
await Clients.OthersInGroup(string.Empty).NotifyAboutSomethingElse();
8585
}
8686

87-
public void NotifyUserAboutSomethingElse()
87+
public async Task NotifyUserAboutSomethingElse()
8888
{
89-
Clients.User(string.Empty).NotifyAboutSomethingElse();
89+
await Clients.User(string.Empty).NotifyAboutSomethingElse();
9090
}
9191

92-
public void NotifyUsersAboutSomethingElse()
92+
public async Task NotifyUsersAboutSomethingElse()
9393
{
94-
Clients.Users(new List<string>().AsReadOnly()).NotifyAboutSomethingElse();
94+
await Clients.Users(new List<string>().AsReadOnly()).NotifyAboutSomethingElse();
9595
}
9696

9797
public void AddLoremAsKeyAndIpsumAsValueToContextItems()
9898
{
9999
Context.Items.Add("Lorem", "Ipsum");
100100
}
101101

102-
public void AddSomebodyToGroup()
102+
public async Task AddSomebodyToGroup()
103103
{
104-
Groups.AddToGroupAsync(string.Empty, string.Empty);
104+
await Groups.AddToGroupAsync(string.Empty, string.Empty);
105105
}
106106

107-
public void RemoveSomebodyFromGroup()
107+
public async Task RemoveSomebodyFromGroup()
108108
{
109-
Groups.RemoveFromGroupAsync(string.Empty, string.Empty);
109+
await Groups.RemoveFromGroupAsync(string.Empty, string.Empty);
110+
}
111+
112+
public Task<string> GetMessageFromCaller()
113+
{
114+
return Clients.Caller.GetMessage();
115+
}
116+
117+
public Task<string> GetMessageFromClient()
118+
{
119+
return Clients.Client(string.Empty).GetMessage();
110120
}
111121
}
112122
}

ExampleSignalRCoreProject/Hubs/ExampleNonGenericHub.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace ExampleSignalRCoreProject.Hubs
77
public class ExampleNonGenericHub : Hub
88
{
99
public const string NotifyUserAboutSomethingResponse = "NotifyUserAboutSomething";
10+
public const string GetMessageInvoke = "GetMessage";
1011

1112
public async Task NotifyAllAboutSomething()
1213
{
@@ -67,5 +68,23 @@ public async Task NotifyUsersAboutSomething()
6768
{
6869
await Clients.Users(new List<string>().AsReadOnly()).SendAsync(NotifyUserAboutSomethingResponse);
6970
}
71+
72+
public async Task<string> GetMessageFromCaller()
73+
{
74+
var messageFromCaller = await Clients
75+
.Caller
76+
.InvokeAsync<string>(GetMessageInvoke, default);
77+
78+
return messageFromCaller;
79+
}
80+
81+
public async Task<string> GetMessageFromClient()
82+
{
83+
var messageFromCaller = await Clients
84+
.Client(string.Empty)
85+
.InvokeAsync<string>(GetMessageInvoke, default);
86+
87+
return messageFromCaller;
88+
}
7089
}
7190
}

ExampleSignalRCoreProject/Hubs/Interfaces/IExampleHubResponses.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ public interface IExampleHubResponses
66
{
77
Task NotifyAboutSomething(string topic, string content);
88
Task NotifyAboutSomethingElse();
9+
10+
Task<string> GetMessage();
911
}
1012
}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Microsoft.AspNetCore.SignalR;
1+
using System.Threading.Tasks;
2+
using Microsoft.AspNetCore.SignalR;
23

34
namespace ExampleSignalRCoreProject.Hubs
45
{
@@ -10,14 +11,14 @@ public void UseContextConnIdTwice()
1011
var y = Context.ConnectionId;
1112
}
1213

13-
public void AddUserToGroup()
14+
public async Task AddUserToGroup()
1415
{
15-
Groups.AddToGroupAsync(Context.ConnectionId, string.Empty);
16+
await Groups.AddToGroupAsync(Context.ConnectionId, string.Empty);
1617
}
1718

18-
public void RemoveUserFromGroupByConnIdGroup()
19+
public async Task RemoveUserFromGroupByConnIdGroup()
1920
{
20-
Groups.RemoveFromGroupAsync(Context.ConnectionId, string.Empty);
21+
await Groups.RemoveFromGroupAsync(Context.ConnectionId, string.Empty);
2122
}
2223
}
2324
}

ExampleSignalRCoreProject/Services/ServiceWhichUseIHubContext.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,15 @@ public async Task NotifyUsersAboutSomething()
5959
{
6060
await _exampleHub.Clients.Users(new List<string>().AsReadOnly()).SendAsync(NotifyUserAboutSomethingResponse);
6161
}
62+
63+
public async Task<string> GetMessageFromClient()
64+
{
65+
var messageFromCaller = await _exampleHub
66+
.Clients
67+
.Client(string.Empty)
68+
.InvokeAsync<string>(ExampleNonGenericHub.GetMessageInvoke, default);
69+
70+
return messageFromCaller;
71+
}
6272
}
6373
}
Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Generic;
2+
using System.Threading.Tasks;
23
using ExampleSignalRCoreProject.Hubs;
34
using ExampleSignalRCoreProject.Hubs.Interfaces;
45
using Microsoft.AspNetCore.SignalR;
@@ -14,51 +15,56 @@ public ServiceWhichUserGenericIHubContext(IHubContext<ExampleHub, IExampleHubRes
1415
_exampleHub = exampleHub;
1516
}
1617

17-
public void NotifyAllAboutSomethingElse()
18+
public async Task NotifyAllAboutSomethingElse()
1819
{
19-
_exampleHub.Clients.All.NotifyAboutSomethingElse();
20+
await _exampleHub.Clients.All.NotifyAboutSomethingElse();
2021
}
2122

22-
public void NotifyAboutSomethingElseAllExcept()
23+
public async Task NotifyAboutSomethingElseAllExcept()
2324
{
2425
var excludedConnectionIds = new List<string> { };
25-
_exampleHub.Clients.AllExcept(excludedConnectionIds.AsReadOnly()).NotifyAboutSomethingElse();
26+
await _exampleHub.Clients.AllExcept(excludedConnectionIds.AsReadOnly()).NotifyAboutSomethingElse();
2627
}
2728

28-
public void NotifyClientAboutSomethingElse()
29+
public async Task NotifyClientAboutSomethingElse()
2930
{
30-
_exampleHub.Clients.Client(string.Empty).NotifyAboutSomethingElse();
31+
await _exampleHub.Clients.Client(string.Empty).NotifyAboutSomethingElse();
3132
}
3233

33-
public void NotifyClientsAboutSomethingElse()
34+
public async Task NotifyClientsAboutSomethingElse()
3435
{
3536
var excludedConnectionIds = new List<string> { };
36-
_exampleHub.Clients.Clients(excludedConnectionIds).NotifyAboutSomethingElse();
37+
await _exampleHub.Clients.Clients(excludedConnectionIds).NotifyAboutSomethingElse();
3738
}
3839

39-
public void NotifyGroupAboutSomethingElse()
40+
public async Task NotifyGroupAboutSomethingElse()
4041
{
41-
_exampleHub.Clients.Group(string.Empty).NotifyAboutSomethingElse();
42+
await _exampleHub.Clients.Group(string.Empty).NotifyAboutSomethingElse();
4243
}
4344

44-
public void NotifyGroupExceptAboutSomethingElse()
45+
public async Task NotifyGroupExceptAboutSomethingElse()
4546
{
46-
_exampleHub.Clients.GroupExcept(string.Empty, new List<string>().AsReadOnly()).NotifyAboutSomethingElse();
47+
await _exampleHub.Clients.GroupExcept(string.Empty, new List<string>().AsReadOnly()).NotifyAboutSomethingElse();
4748
}
4849

49-
public void NotifyGroupsAboutSomethingElse()
50+
public async Task NotifyGroupsAboutSomethingElse()
5051
{
51-
_exampleHub.Clients.Groups(new List<string>().AsReadOnly()).NotifyAboutSomethingElse();
52+
await _exampleHub.Clients.Groups(new List<string>().AsReadOnly()).NotifyAboutSomethingElse();
5253
}
5354

54-
public void NotifyUserAboutSomethingElse()
55+
public async Task NotifyUserAboutSomethingElse()
5556
{
56-
_exampleHub.Clients.User(string.Empty).NotifyAboutSomethingElse();
57+
await _exampleHub.Clients.User(string.Empty).NotifyAboutSomethingElse();
5758
}
5859

59-
public void NotifyUsersAboutSomethingElse()
60+
public async Task NotifyUsersAboutSomethingElse()
6061
{
61-
_exampleHub.Clients.Users(new List<string>().AsReadOnly()).NotifyAboutSomethingElse();
62+
await _exampleHub.Clients.Users(new List<string>().AsReadOnly()).NotifyAboutSomethingElse();
63+
}
64+
65+
public Task<string> GetMessageFromClient()
66+
{
67+
return _exampleHub.Clients.Client(string.Empty).GetMessage();
6268
}
6369
}
6470
}

SignalR_UnitTestingSupport/SignalR_UnitTestingSupport.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@
4040
</ItemGroup>
4141

4242
<ItemGroup>
43-
<PackageReference Include="nunit" Version="3.13.2" />
43+
<PackageReference Include="nunit" Version="3.13.3" />
4444
</ItemGroup>
4545
</Project>

SignalR_UnitTestingSupportCommon/EFSupport/DbMockAndInMemoryProvider.cs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,28 +77,14 @@ public void SetUp()
7777
/// </summary>
7878
public void TearDown()
7979
{
80-
try
80+
if (_dbInMemorySqliteLazy != null && _dbInMemorySqliteLazy.IsValueCreated)
8181
{
82-
if (_dbInMemorySqliteLazy != null && _dbInMemorySqliteLazy.IsValueCreated)
83-
{
84-
DbInMemorySqlite.Dispose();
85-
}
86-
}
87-
catch (Exception)
88-
{
89-
// TODO: Add logger later
82+
DbInMemorySqlite.Dispose();
9083
}
9184

92-
try
93-
{
94-
if (_dbInMemoryInMemoryLazy != null && _dbInMemoryInMemoryLazy.IsValueCreated)
95-
{
96-
DbInMemory.Dispose();
97-
}
98-
}
99-
catch (Exception)
85+
if (_dbInMemoryInMemoryLazy != null && _dbInMemoryInMemoryLazy.IsValueCreated)
10086
{
101-
// TODO: Add logger later
87+
DbInMemory.Dispose();
10288
}
10389
}
10490

SignalR_UnitTestingSupportCommon/Hubs/HubUnitTestsSupport.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ public class HubUnitTestsSupport : HubUnitTestsBaseCommon, IHubUnitTestsBase
3131
/// <summary>
3232
/// Gets mock for Hub.Clients.Caller
3333
/// </summary>
34-
public Mock<IClientProxy> ClientsCallerMock { get; private set; }
34+
public Mock<ISingleClientProxy> ClientsCallerMock { get; private set; }
3535

3636
/// <summary>
3737
/// Gets mock which is returned when Hub.Clients.Client() is called
3838
/// </summary>
39-
public Mock<IClientProxy> ClientsClientMock { get; private set; }
39+
public Mock<ISingleClientProxy> ClientsClientMock { get; private set; }
4040

4141
/// <summary>
4242
/// Gets mock which is returned when Hub.Clients.Clients() is called
@@ -116,15 +116,15 @@ internal override void SetUpClientsAllExcept()
116116

117117
internal override void SetUpClientsCaller()
118118
{
119-
ClientsCallerMock = new Mock<IClientProxy>();
119+
ClientsCallerMock = new Mock<ISingleClientProxy>();
120120
ClientsMock
121121
.Setup(x => x.Caller)
122122
.Returns(ClientsCallerMock.Object);
123123
}
124124

125125
internal override void SetUpClientsClient()
126126
{
127-
ClientsClientMock = new Mock<IClientProxy>();
127+
ClientsClientMock = new Mock<ISingleClientProxy>();
128128
ClientsMock
129129
.Setup(x => x.Client(It.IsAny<string>()))
130130
.Returns(ClientsClientMock.Object);

0 commit comments

Comments
 (0)