mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 05:11:10 +00:00
Completes the scheduled jobs module with default jobs, a themed scheduler page and aligned recovery semantics
This commit is contained in:
1 parent
99a6159f7f
commit
4b7cfbbe11
67 files changed
+3324
-745
No files matched your search
+7
-4
@@ -32,14 +32,14 @@ public class ScheduledJobNotifierTests
|
||||
{
|
||||
_mockClient = Substitute.For<IScheduledJobsClient>();
|
||||
_mockHubClients = Substitute.For<IHubClients<IScheduledJobsClient>>();
|
||||
_mockHubClients.All.Returns(_mockClient);
|
||||
_mockHubClients.Group(ScheduledJobsHub.ADMINISTRATORS_GROUP).Returns(_mockClient);
|
||||
_mockHubContext = Substitute.For<IHubContext<ScheduledJobsHub, IScheduledJobsClient>>();
|
||||
_mockHubContext.Clients.Returns(_mockHubClients);
|
||||
_sut = new ScheduledJobNotifier(_mockHubContext);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SendScheduledJobsAsync_WhenCalled_ShouldSendTheScheduledJobsToAllClients()
|
||||
public async Task SendScheduledJobsAsync_WhenCalled_ShouldSendTheScheduledJobsToTheAdministratorGroup()
|
||||
{
|
||||
// Arrange
|
||||
IReadOnlyList<ScheduledJobResponse> scheduledJobs = _scheduledJobResponseFixture.CreateMany(2);
|
||||
@@ -49,10 +49,11 @@ public class ScheduledJobNotifierTests
|
||||
|
||||
// Assert
|
||||
await _mockClient.Received(1).ReceiveScheduledJobsAsync(scheduledJobs);
|
||||
_mockHubClients.Received(1).Group(ScheduledJobsHub.ADMINISTRATORS_GROUP);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SendScheduledJobExecutionStartedAsync_WhenCalled_ShouldSendTheExecutionToAllClients()
|
||||
public async Task SendScheduledJobExecutionStartedAsync_WhenCalled_ShouldSendTheExecutionToTheAdministratorGroup()
|
||||
{
|
||||
// Arrange
|
||||
ScheduledJobExecutionResponse execution = _scheduledJobExecutionResponseFixture.Create();
|
||||
@@ -62,10 +63,11 @@ public class ScheduledJobNotifierTests
|
||||
|
||||
// Assert
|
||||
await _mockClient.Received(1).ScheduledJobExecutionStartedAsync(execution);
|
||||
_mockHubClients.Received(1).Group(ScheduledJobsHub.ADMINISTRATORS_GROUP);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SendScheduledJobExecutionCompletedAsync_WhenCalled_ShouldSendTheExecutionToAllClients()
|
||||
public async Task SendScheduledJobExecutionCompletedAsync_WhenCalled_ShouldSendTheExecutionToTheAdministratorGroup()
|
||||
{
|
||||
// Arrange
|
||||
ScheduledJobExecutionResponse execution = _scheduledJobExecutionResponseFixture.Create();
|
||||
@@ -75,5 +77,6 @@ public class ScheduledJobNotifierTests
|
||||
|
||||
// Assert
|
||||
await _mockClient.Received(1).ScheduledJobExecutionCompletedAsync(execution);
|
||||
_mockHubClients.Received(1).Group(ScheduledJobsHub.ADMINISTRATORS_GROUP);
|
||||
}
|
||||
}
|
||||
+5
-1
@@ -84,13 +84,16 @@ public class ScheduledJobsHubTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task OnConnectedAsync_WhenUserIsAdministrator_ShouldNotAbortTheConnection()
|
||||
public async Task OnConnectedAsync_WhenUserIsAdministrator_ShouldAddTheConnectionToTheAdministratorGroup()
|
||||
{
|
||||
// Arrange
|
||||
Guid userId = Guid.NewGuid();
|
||||
ClaimsPrincipal user = new(new ClaimsIdentity([new Claim(ClaimTypes.NameIdentifier, userId.ToString())]));
|
||||
HubCallerContext context = CreateHubCallerContext(user);
|
||||
context.ConnectionId.Returns("connection-1");
|
||||
_sut.Context = context;
|
||||
IGroupManager mockGroupManager = Substitute.For<IGroupManager>();
|
||||
_sut.Groups = mockGroupManager;
|
||||
_mockAuthorizationService.IsInRoleAsync(userId, "Admin", System.Threading.CancellationToken.None).Returns(true);
|
||||
|
||||
// Act
|
||||
@@ -98,6 +101,7 @@ public class ScheduledJobsHubTests
|
||||
|
||||
// Assert
|
||||
context.DidNotReceive().Abort();
|
||||
await mockGroupManager.Received(1).AddToGroupAsync("connection-1", ScheduledJobsHub.ADMINISTRATORS_GROUP, System.Threading.CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in new issue
Block a user