mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 09:11:10 +00:00
Returns the unit of work save changes result
This commit is contained in:
1 parent
f3e465255e
commit
64ef3a1e22
141 files changed
+1388
-1151
No files matched your search
+1
@@ -49,6 +49,7 @@ public class AddScheduledJobCommandHandlerTests
|
||||
public AddScheduledJobCommandHandlerTests()
|
||||
{
|
||||
_mockUnitOfWork = Substitute.For<IUnitOfWork>();
|
||||
_mockUnitOfWork.SaveChangesAsync(Arg.Any<CancellationToken>()).Returns(Result.Success);
|
||||
_mockCurrentUserService = Substitute.For<ICurrentUserService>();
|
||||
_mockAuthorizationService = Substitute.For<IAuthorizationService>();
|
||||
_mockDomainEventsQueue = Substitute.For<IDomainEventsQueue>();
|
||||
|
||||
+9
-8
@@ -48,6 +48,7 @@ public class FireScheduledJobCommandHandlerTests
|
||||
public FireScheduledJobCommandHandlerTests()
|
||||
{
|
||||
_mockUnitOfWork = Substitute.For<IUnitOfWork>();
|
||||
_mockUnitOfWork.SaveChangesAsync(Arg.Any<CancellationToken>()).Returns(Result.Success);
|
||||
_mockCurrentUserService = Substitute.For<ICurrentUserService>();
|
||||
_mockAuthorizationService = Substitute.For<IAuthorizationService>();
|
||||
_mockDomainEventsQueue = Substitute.For<IDomainEventsQueue>();
|
||||
@@ -72,7 +73,7 @@ public class FireScheduledJobCommandHandlerTests
|
||||
id: command.ScheduledJobId,
|
||||
scheduleType: ScheduleType.WithIntervalInMinutes,
|
||||
status: ScheduledJobStatus.Active);
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(scheduledJob));
|
||||
|
||||
// Act
|
||||
@@ -98,7 +99,7 @@ public class FireScheduledJobCommandHandlerTests
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(DomainErrors.Scheduling.ScheduledJobNotFound, result.FirstError);
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), cancellationToken: Arg.Any<CancellationToken>());
|
||||
_mockDomainEventsQueue.DidNotReceive().Enqueue(Arg.Any<IDomainEvent>());
|
||||
}
|
||||
|
||||
@@ -115,7 +116,7 @@ public class FireScheduledJobCommandHandlerTests
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(ApplicationErrors.Authorization.NotAuthorized, result.FirstError);
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), cancellationToken: Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -131,7 +132,7 @@ public class FireScheduledJobCommandHandlerTests
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(ApplicationErrors.Authorization.NotAuthorized, result.FirstError);
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), cancellationToken: Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -140,7 +141,7 @@ public class FireScheduledJobCommandHandlerTests
|
||||
// Arrange
|
||||
FireScheduledJobCommand command = _fireScheduledJobCommandFixture.Create();
|
||||
Error error = Error.Failure("Database.Error", "Failed to get the scheduled job");
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>()).Returns(error);
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, cancellationToken: Arg.Any<CancellationToken>()).Returns(error);
|
||||
|
||||
// Act
|
||||
Result<ScheduledJobResponse> result = await _sut.HandleAsync(command, CancellationToken.None);
|
||||
@@ -156,7 +157,7 @@ public class FireScheduledJobCommandHandlerTests
|
||||
{
|
||||
// Arrange
|
||||
FireScheduledJobCommand command = _fireScheduledJobCommandFixture.Create();
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(null));
|
||||
|
||||
// Act
|
||||
@@ -179,7 +180,7 @@ public class FireScheduledJobCommandHandlerTests
|
||||
scheduleType: ScheduleType.DailyAtHourAndMinute,
|
||||
hour: 99,
|
||||
minute: 0);
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(scheduledJob));
|
||||
|
||||
// Act
|
||||
@@ -199,7 +200,7 @@ public class FireScheduledJobCommandHandlerTests
|
||||
id: command.ScheduledJobId,
|
||||
scheduleType: ScheduleType.WithIntervalInMinutes,
|
||||
status: ScheduledJobStatus.Running);
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(scheduledJob));
|
||||
|
||||
// Act
|
||||
|
||||
+10
-9
@@ -51,6 +51,7 @@ public class RemoveScheduledJobCommandHandlerTests
|
||||
public RemoveScheduledJobCommandHandlerTests()
|
||||
{
|
||||
_mockUnitOfWork = Substitute.For<IUnitOfWork>();
|
||||
_mockUnitOfWork.SaveChangesAsync(Arg.Any<CancellationToken>()).Returns(Result.Success);
|
||||
_mockCurrentUserService = Substitute.For<ICurrentUserService>();
|
||||
_mockAuthorizationService = Substitute.For<IAuthorizationService>();
|
||||
_mockDomainEventsQueue = Substitute.For<IDomainEventsQueue>();
|
||||
@@ -78,7 +79,7 @@ public class RemoveScheduledJobCommandHandlerTests
|
||||
id: command.ScheduledJobId,
|
||||
scheduleType: ScheduleType.WithIntervalInMinutes,
|
||||
status: ScheduledJobStatus.Active);
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(scheduledJob));
|
||||
_mockScheduledJobExecutionRepository.DeleteByScheduledJobIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.Success);
|
||||
@@ -113,7 +114,7 @@ public class RemoveScheduledJobCommandHandlerTests
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(DomainErrors.Scheduling.ScheduledJobNotFound, result.FirstError);
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), cancellationToken: Arg.Any<CancellationToken>());
|
||||
await _mockScheduledJobRepository.DidNotReceive().DeleteByIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
@@ -130,7 +131,7 @@ public class RemoveScheduledJobCommandHandlerTests
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(ApplicationErrors.Authorization.NotAuthorized, result.FirstError);
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), cancellationToken: Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -146,7 +147,7 @@ public class RemoveScheduledJobCommandHandlerTests
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(ApplicationErrors.Authorization.NotAuthorized, result.FirstError);
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), cancellationToken: Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -154,7 +155,7 @@ public class RemoveScheduledJobCommandHandlerTests
|
||||
{
|
||||
// Arrange
|
||||
RemoveScheduledJobCommand command = _removeScheduledJobCommandFixture.Create();
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(null));
|
||||
|
||||
// Act
|
||||
@@ -175,7 +176,7 @@ public class RemoveScheduledJobCommandHandlerTests
|
||||
id: command.ScheduledJobId,
|
||||
scheduleType: ScheduleType.WithIntervalInMinutes,
|
||||
status: ScheduledJobStatus.Active);
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(scheduledJob));
|
||||
Error error = Error.Failure("Database.Error", "Failed to delete the executions");
|
||||
_mockScheduledJobExecutionRepository.DeleteByScheduledJobIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
@@ -200,7 +201,7 @@ public class RemoveScheduledJobCommandHandlerTests
|
||||
id: command.ScheduledJobId,
|
||||
scheduleType: ScheduleType.WithIntervalInMinutes,
|
||||
status: ScheduledJobStatus.Active);
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(scheduledJob));
|
||||
_mockScheduledJobExecutionRepository.DeleteByScheduledJobIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.Success);
|
||||
@@ -223,7 +224,7 @@ public class RemoveScheduledJobCommandHandlerTests
|
||||
// Arrange
|
||||
RemoveScheduledJobCommand command = _removeScheduledJobCommandFixture.Create();
|
||||
Error repositoryError = DomainErrors.Scheduling.ScheduledJobNotFound;
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(repositoryError);
|
||||
|
||||
// Act
|
||||
@@ -247,7 +248,7 @@ public class RemoveScheduledJobCommandHandlerTests
|
||||
scheduleType: ScheduleType.WithIntervalInMinutes,
|
||||
intervalMinutes: 0,
|
||||
status: ScheduledJobStatus.Active);
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(invalidScheduledJob));
|
||||
|
||||
// Act
|
||||
|
||||
+10
-9
@@ -48,6 +48,7 @@ public class StartScheduledJobCommandHandlerTests
|
||||
public StartScheduledJobCommandHandlerTests()
|
||||
{
|
||||
_mockUnitOfWork = Substitute.For<IUnitOfWork>();
|
||||
_mockUnitOfWork.SaveChangesAsync(Arg.Any<CancellationToken>()).Returns(Result.Success);
|
||||
_mockCurrentUserService = Substitute.For<ICurrentUserService>();
|
||||
_mockAuthorizationService = Substitute.For<IAuthorizationService>();
|
||||
_mockDomainEventsQueue = Substitute.For<IDomainEventsQueue>();
|
||||
@@ -72,7 +73,7 @@ public class StartScheduledJobCommandHandlerTests
|
||||
id: command.ScheduledJobId,
|
||||
scheduleType: ScheduleType.WithIntervalInMinutes,
|
||||
status: ScheduledJobStatus.Added);
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(scheduledJob));
|
||||
_mockScheduledJobRepository.UpdateAsync(Arg.Any<ScheduledJobEntity>(), Arg.Any<CancellationToken>()).Returns(Result.Updated);
|
||||
|
||||
@@ -102,7 +103,7 @@ public class StartScheduledJobCommandHandlerTests
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(DomainErrors.Scheduling.ScheduledJobNotFound, result.FirstError);
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), cancellationToken: Arg.Any<CancellationToken>());
|
||||
await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
@@ -119,7 +120,7 @@ public class StartScheduledJobCommandHandlerTests
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(ApplicationErrors.Authorization.NotAuthorized, result.FirstError);
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), cancellationToken: Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -135,7 +136,7 @@ public class StartScheduledJobCommandHandlerTests
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(ApplicationErrors.Authorization.NotAuthorized, result.FirstError);
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), cancellationToken: Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -143,7 +144,7 @@ public class StartScheduledJobCommandHandlerTests
|
||||
{
|
||||
// Arrange
|
||||
StartScheduledJobCommand command = _startScheduledJobCommandFixture.Create();
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(null));
|
||||
|
||||
// Act
|
||||
@@ -164,7 +165,7 @@ public class StartScheduledJobCommandHandlerTests
|
||||
id: command.ScheduledJobId,
|
||||
scheduleType: ScheduleType.WithIntervalInMinutes,
|
||||
status: ScheduledJobStatus.Active);
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(scheduledJob));
|
||||
|
||||
// Act
|
||||
@@ -186,7 +187,7 @@ public class StartScheduledJobCommandHandlerTests
|
||||
id: command.ScheduledJobId,
|
||||
scheduleType: ScheduleType.WithIntervalInMinutes,
|
||||
status: ScheduledJobStatus.Added);
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(scheduledJob));
|
||||
_mockScheduledJobRepository.UpdateAsync(Arg.Any<ScheduledJobEntity>(), Arg.Any<CancellationToken>())
|
||||
.Returns(DomainErrors.Scheduling.ScheduledJobNotFound);
|
||||
@@ -207,7 +208,7 @@ public class StartScheduledJobCommandHandlerTests
|
||||
// Arrange
|
||||
StartScheduledJobCommand command = _startScheduledJobCommandFixture.Create();
|
||||
Error repositoryError = DomainErrors.Scheduling.ScheduledJobNotFound;
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(repositoryError);
|
||||
|
||||
// Act
|
||||
@@ -230,7 +231,7 @@ public class StartScheduledJobCommandHandlerTests
|
||||
scheduleType: ScheduleType.WithIntervalInMinutes,
|
||||
intervalMinutes: 0,
|
||||
status: ScheduledJobStatus.Added);
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(invalidScheduledJob));
|
||||
|
||||
// Act
|
||||
|
||||
+11
-10
@@ -50,6 +50,7 @@ public class StopScheduledJobCommandHandlerTests
|
||||
public StopScheduledJobCommandHandlerTests()
|
||||
{
|
||||
_mockUnitOfWork = Substitute.For<IUnitOfWork>();
|
||||
_mockUnitOfWork.SaveChangesAsync(Arg.Any<CancellationToken>()).Returns(Result.Success);
|
||||
_mockCurrentUserService = Substitute.For<ICurrentUserService>();
|
||||
_mockAuthorizationService = Substitute.For<IAuthorizationService>();
|
||||
_mockDomainEventsQueue = Substitute.For<IDomainEventsQueue>();
|
||||
@@ -75,7 +76,7 @@ public class StopScheduledJobCommandHandlerTests
|
||||
id: command.ScheduledJobId,
|
||||
scheduleType: ScheduleType.WithIntervalInMinutes,
|
||||
status: ScheduledJobStatus.Active);
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(scheduledJob));
|
||||
_mockScheduledJobRepository.UpdateAsync(Arg.Any<ScheduledJobEntity>(), Arg.Any<CancellationToken>()).Returns(Result.Updated);
|
||||
|
||||
@@ -105,7 +106,7 @@ public class StopScheduledJobCommandHandlerTests
|
||||
scheduleType: ScheduleType.WithIntervalInMinutes,
|
||||
status: ScheduledJobStatus.Running,
|
||||
lastStartedOnUtc: DateTime.UtcNow.AddMinutes(-10));
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(scheduledJob));
|
||||
_mockScheduledJobRepository.UpdateAsync(Arg.Any<ScheduledJobEntity>(), Arg.Any<CancellationToken>()).Returns(Result.Updated);
|
||||
|
||||
@@ -132,7 +133,7 @@ public class StopScheduledJobCommandHandlerTests
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(DomainErrors.Scheduling.ScheduledJobNotFound, result.FirstError);
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), cancellationToken: Arg.Any<CancellationToken>());
|
||||
await _mockScheduledJobScheduler.DidNotReceive().StopCycleAsync(Arg.Any<Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects.ScheduledJobId>(), Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
@@ -149,7 +150,7 @@ public class StopScheduledJobCommandHandlerTests
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(ApplicationErrors.Authorization.NotAuthorized, result.FirstError);
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), cancellationToken: Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -165,7 +166,7 @@ public class StopScheduledJobCommandHandlerTests
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(ApplicationErrors.Authorization.NotAuthorized, result.FirstError);
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), cancellationToken: Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -173,7 +174,7 @@ public class StopScheduledJobCommandHandlerTests
|
||||
{
|
||||
// Arrange
|
||||
StopScheduledJobCommand command = _stopScheduledJobCommandFixture.Create();
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(null));
|
||||
|
||||
// Act
|
||||
@@ -194,7 +195,7 @@ public class StopScheduledJobCommandHandlerTests
|
||||
id: command.ScheduledJobId,
|
||||
scheduleType: ScheduleType.WithIntervalInMinutes,
|
||||
status: ScheduledJobStatus.Added);
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(scheduledJob));
|
||||
|
||||
// Act
|
||||
@@ -216,7 +217,7 @@ public class StopScheduledJobCommandHandlerTests
|
||||
id: command.ScheduledJobId,
|
||||
scheduleType: ScheduleType.WithIntervalInMinutes,
|
||||
status: ScheduledJobStatus.Active);
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(scheduledJob));
|
||||
_mockScheduledJobRepository.UpdateAsync(Arg.Any<ScheduledJobEntity>(), Arg.Any<CancellationToken>())
|
||||
.Returns(DomainErrors.Scheduling.ScheduledJobNotFound);
|
||||
@@ -237,7 +238,7 @@ public class StopScheduledJobCommandHandlerTests
|
||||
// Arrange
|
||||
StopScheduledJobCommand command = _stopScheduledJobCommandFixture.Create();
|
||||
Error repositoryError = DomainErrors.Scheduling.ScheduledJobNotFound;
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(repositoryError);
|
||||
|
||||
// Act
|
||||
@@ -260,7 +261,7 @@ public class StopScheduledJobCommandHandlerTests
|
||||
scheduleType: ScheduleType.WithIntervalInMinutes,
|
||||
intervalMinutes: 0,
|
||||
status: ScheduledJobStatus.Active);
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(command.ScheduledJobId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(invalidScheduledJob));
|
||||
|
||||
// Act
|
||||
|
||||
+1
@@ -41,6 +41,7 @@ public class UpdateSchedulerDisplayPreferencesCommandHandlerTests
|
||||
public UpdateSchedulerDisplayPreferencesCommandHandlerTests()
|
||||
{
|
||||
_mockUnitOfWork = Substitute.For<IUnitOfWork>();
|
||||
_mockUnitOfWork.SaveChangesAsync(Arg.Any<CancellationToken>()).Returns(Result.Success);
|
||||
_mockCurrentUserService = Substitute.For<ICurrentUserService>();
|
||||
_mockAuthorizationService = Substitute.For<IAuthorizationService>();
|
||||
_mockSchedulerDisplayPreferencesRepository = Substitute.For<ISchedulerDisplayPreferencesRepository>();
|
||||
|
||||
+6
-3
@@ -2,6 +2,8 @@
|
||||
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Scheduling;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Core.Scheduling.Events;
|
||||
using Lumina.Application.Core.Scheduling.Notifications;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Scheduling;
|
||||
@@ -40,11 +42,12 @@ public class ScheduledJobAddedDomainEventHandlerTests
|
||||
public ScheduledJobAddedDomainEventHandlerTests()
|
||||
{
|
||||
_mockUnitOfWork = Substitute.For<IUnitOfWork>();
|
||||
_mockUnitOfWork.SaveChangesAsync(Arg.Any<CancellationToken>()).Returns(Result.Success);
|
||||
_mockScheduledJobNotifier = Substitute.For<IScheduledJobNotifier>();
|
||||
_mockScheduledJobRepository = Substitute.For<IScheduledJobRepository>();
|
||||
|
||||
_mockUnitOfWork.ScheduledJobRepository.Returns(_mockScheduledJobRepository);
|
||||
_mockScheduledJobRepository.GetAllAsync(Arg.Any<CancellationToken>()).Returns(Result.From<IEnumerable<ScheduledJobEntity>>([]));
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
|
||||
_sut = new ScheduledJobAddedDomainEventHandler(_mockScheduledJobNotifier, _mockUnitOfWork);
|
||||
}
|
||||
@@ -56,7 +59,7 @@ public class ScheduledJobAddedDomainEventHandlerTests
|
||||
ScheduledJobAddedDomainEvent domainEvent = _scheduledJobAddedDomainEventFixture.Create();
|
||||
ScheduledJobEntity scheduledJob1 = _scheduledJobEntityFixture.Create(name: "Job 1");
|
||||
ScheduledJobEntity scheduledJob2 = _scheduledJobEntityFixture.Create(name: "Job 2");
|
||||
_mockScheduledJobRepository.GetAllAsync(Arg.Any<CancellationToken>()).Returns(Result.From<IEnumerable<ScheduledJobEntity>>([scheduledJob1, scheduledJob2]));
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity> { Data = [scheduledJob1, scheduledJob2], CurrentPage = 1, PerPage = 2, Count = 2, NumberOfPages = 1 }));
|
||||
|
||||
// Act
|
||||
await _sut.HandleAsync(domainEvent, CancellationToken.None);
|
||||
@@ -73,7 +76,7 @@ public class ScheduledJobAddedDomainEventHandlerTests
|
||||
// Arrange
|
||||
ScheduledJobAddedDomainEvent domainEvent = _scheduledJobAddedDomainEventFixture.Create();
|
||||
Error error = Error.Failure("Database.Error", "Failed to get the scheduled jobs");
|
||||
_mockScheduledJobRepository.GetAllAsync(Arg.Any<CancellationToken>()).Returns(error);
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(error);
|
||||
|
||||
// Act
|
||||
EventualConsistencyException exception = await Assert.ThrowsAsync<EventualConsistencyException>(
|
||||
|
||||
+5
-2
@@ -2,6 +2,8 @@
|
||||
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Scheduling;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Common.Infrastructure.Scheduling;
|
||||
using Lumina.Application.Core.Scheduling.Events;
|
||||
using Lumina.Application.Core.Scheduling.Notifications;
|
||||
@@ -39,12 +41,13 @@ public class ScheduledJobCycleStartedDomainEventHandlerTests
|
||||
public ScheduledJobCycleStartedDomainEventHandlerTests()
|
||||
{
|
||||
_mockUnitOfWork = Substitute.For<IUnitOfWork>();
|
||||
_mockUnitOfWork.SaveChangesAsync(Arg.Any<CancellationToken>()).Returns(Result.Success);
|
||||
_mockScheduledJobNotifier = Substitute.For<IScheduledJobNotifier>();
|
||||
_mockScheduledJobScheduler = Substitute.For<IScheduledJobScheduler>();
|
||||
_mockScheduledJobRepository = Substitute.For<IScheduledJobRepository>();
|
||||
|
||||
_mockUnitOfWork.ScheduledJobRepository.Returns(_mockScheduledJobRepository);
|
||||
_mockScheduledJobRepository.GetAllAsync(Arg.Any<CancellationToken>()).Returns(Result.From<IEnumerable<ScheduledJobEntity>>([]));
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
|
||||
_sut = new ScheduledJobCycleStartedDomainEventHandler(_mockScheduledJobNotifier, _mockScheduledJobScheduler, _mockUnitOfWork);
|
||||
}
|
||||
@@ -69,7 +72,7 @@ public class ScheduledJobCycleStartedDomainEventHandlerTests
|
||||
// Arrange
|
||||
ScheduledJobCycleStartedDomainEvent domainEvent = _scheduledJobCycleStartedDomainEventFixture.Create();
|
||||
Error error = Error.Failure("Database.Error", "Failed to get the scheduled jobs");
|
||||
_mockScheduledJobRepository.GetAllAsync(Arg.Any<CancellationToken>()).Returns(error);
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(error);
|
||||
|
||||
// Act
|
||||
EventualConsistencyException exception = await Assert.ThrowsAsync<EventualConsistencyException>(
|
||||
|
||||
+6
-3
@@ -2,6 +2,8 @@
|
||||
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Scheduling;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Core.Scheduling.Events;
|
||||
using Lumina.Application.Core.Scheduling.Notifications;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Scheduling;
|
||||
@@ -39,11 +41,12 @@ public class ScheduledJobCycleStoppedDomainEventHandlerTests
|
||||
public ScheduledJobCycleStoppedDomainEventHandlerTests()
|
||||
{
|
||||
_mockUnitOfWork = Substitute.For<IUnitOfWork>();
|
||||
_mockUnitOfWork.SaveChangesAsync(Arg.Any<CancellationToken>()).Returns(Result.Success);
|
||||
_mockScheduledJobNotifier = Substitute.For<IScheduledJobNotifier>();
|
||||
_mockScheduledJobRepository = Substitute.For<IScheduledJobRepository>();
|
||||
|
||||
_mockUnitOfWork.ScheduledJobRepository.Returns(_mockScheduledJobRepository);
|
||||
_mockScheduledJobRepository.GetAllAsync(Arg.Any<CancellationToken>()).Returns(Result.From<IEnumerable<ScheduledJobEntity>>([]));
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
|
||||
_sut = new ScheduledJobCycleStoppedDomainEventHandler(_mockScheduledJobNotifier, _mockUnitOfWork);
|
||||
}
|
||||
@@ -54,7 +57,7 @@ public class ScheduledJobCycleStoppedDomainEventHandlerTests
|
||||
// Arrange
|
||||
ScheduledJobCycleStoppedDomainEvent domainEvent = _scheduledJobCycleStoppedDomainEventFixture.Create();
|
||||
ScheduledJobEntity stoppedJob = _scheduledJobEntityFixture.Create(name: "Stopped job", status: Lumina.Domain.SharedKernel.Common.Enums.Scheduling.ScheduledJobStatus.Added);
|
||||
_mockScheduledJobRepository.GetAllAsync(Arg.Any<CancellationToken>()).Returns(Result.From<IEnumerable<ScheduledJobEntity>>([stoppedJob]));
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity> { Data = [stoppedJob], CurrentPage = 1, PerPage = 1, Count = 1, NumberOfPages = 1 }));
|
||||
|
||||
// Act
|
||||
await _sut.HandleAsync(domainEvent, CancellationToken.None);
|
||||
@@ -71,7 +74,7 @@ public class ScheduledJobCycleStoppedDomainEventHandlerTests
|
||||
// Arrange
|
||||
ScheduledJobCycleStoppedDomainEvent domainEvent = _scheduledJobCycleStoppedDomainEventFixture.Create();
|
||||
Error error = Error.Failure("Database.Error", "Failed to get the scheduled jobs");
|
||||
_mockScheduledJobRepository.GetAllAsync(Arg.Any<CancellationToken>()).Returns(error);
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(error);
|
||||
|
||||
// Act
|
||||
EventualConsistencyException exception = await Assert.ThrowsAsync<EventualConsistencyException>(
|
||||
|
||||
+17
-14
@@ -2,6 +2,8 @@
|
||||
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Scheduling;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Core.Scheduling.Events;
|
||||
using Lumina.Application.Core.Scheduling.Notifications;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Scheduling;
|
||||
@@ -43,6 +45,7 @@ public class ScheduledJobExecutionCompletedDomainEventHandlerTests
|
||||
public ScheduledJobExecutionCompletedDomainEventHandlerTests()
|
||||
{
|
||||
_mockUnitOfWork = Substitute.For<IUnitOfWork>();
|
||||
_mockUnitOfWork.SaveChangesAsync(Arg.Any<CancellationToken>()).Returns(Result.Success);
|
||||
_mockScheduledJobNotifier = Substitute.For<IScheduledJobNotifier>();
|
||||
_mockScheduledJobRepository = Substitute.For<IScheduledJobRepository>();
|
||||
_mockScheduledJobExecutionRepository = Substitute.For<IScheduledJobExecutionRepository>();
|
||||
@@ -51,7 +54,7 @@ public class ScheduledJobExecutionCompletedDomainEventHandlerTests
|
||||
_mockUnitOfWork.ScheduledJobExecutionRepository.Returns(_mockScheduledJobExecutionRepository);
|
||||
_mockScheduledJobRepository.UpdateAsync(Arg.Any<ScheduledJobEntity>(), Arg.Any<CancellationToken>()).Returns(Result.Updated);
|
||||
_mockScheduledJobExecutionRepository.UpdateAsync(Arg.Any<ScheduledJobExecutionEntity>(), Arg.Any<CancellationToken>()).Returns(Result.Updated);
|
||||
_mockScheduledJobRepository.GetAllAsync(Arg.Any<CancellationToken>()).Returns(Result.From<IEnumerable<ScheduledJobEntity>>([]));
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
|
||||
_sut = new ScheduledJobExecutionCompletedDomainEventHandler(_mockScheduledJobNotifier, _mockUnitOfWork);
|
||||
}
|
||||
@@ -68,14 +71,14 @@ public class ScheduledJobExecutionCompletedDomainEventHandlerTests
|
||||
id: domainEvent.ScheduledJobId.Value,
|
||||
status: ScheduledJobStatus.Running,
|
||||
lastStartedOnUtc: completedOnUtc.AddMinutes(-5));
|
||||
_mockScheduledJobRepository.GetByIdAsync(domainEvent.ScheduledJobId.Value, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(domainEvent.ScheduledJobId.Value, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(scheduledJob));
|
||||
ScheduledJobExecutionEntity execution = _scheduledJobExecutionEntityFixture.Create(
|
||||
id: domainEvent.RunId,
|
||||
scheduledJobId: scheduledJob.Id,
|
||||
isCycleRun: isCycleRun,
|
||||
completedOnUtc: null);
|
||||
_mockScheduledJobExecutionRepository.GetByIdAsync(domainEvent.RunId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobExecutionRepository.GetByIdAsync(domainEvent.RunId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobExecutionEntity?>(execution));
|
||||
|
||||
// Act
|
||||
@@ -100,7 +103,7 @@ public class ScheduledJobExecutionCompletedDomainEventHandlerTests
|
||||
{
|
||||
// Arrange
|
||||
ScheduledJobExecutionCompletedDomainEvent domainEvent = _scheduledJobExecutionCompletedDomainEventFixture.Create(isCycleRun: true);
|
||||
_mockScheduledJobRepository.GetByIdAsync(domainEvent.ScheduledJobId.Value, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(domainEvent.ScheduledJobId.Value, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(null));
|
||||
|
||||
// Act
|
||||
@@ -109,7 +112,7 @@ public class ScheduledJobExecutionCompletedDomainEventHandlerTests
|
||||
|
||||
// Assert
|
||||
Assert.Equal(Errors.Scheduling.ScheduledJobNotFound, exception.EventualConsistencyError);
|
||||
await _mockScheduledJobExecutionRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
await _mockScheduledJobExecutionRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), cancellationToken: Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -118,7 +121,7 @@ public class ScheduledJobExecutionCompletedDomainEventHandlerTests
|
||||
// Arrange
|
||||
ScheduledJobExecutionCompletedDomainEvent domainEvent = _scheduledJobExecutionCompletedDomainEventFixture.Create(isCycleRun: true);
|
||||
ScheduledJobEntity scheduledJob = _scheduledJobEntityFixture.Create(id: domainEvent.ScheduledJobId.Value, status: ScheduledJobStatus.Running);
|
||||
_mockScheduledJobRepository.GetByIdAsync(domainEvent.ScheduledJobId.Value, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(domainEvent.ScheduledJobId.Value, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(scheduledJob));
|
||||
Error error = Error.Failure("Database.Error", "Failed to update the scheduled job");
|
||||
_mockScheduledJobRepository.UpdateAsync(Arg.Any<ScheduledJobEntity>(), Arg.Any<CancellationToken>()).Returns(error);
|
||||
@@ -129,7 +132,7 @@ public class ScheduledJobExecutionCompletedDomainEventHandlerTests
|
||||
|
||||
// Assert
|
||||
Assert.Equal(error, exception.EventualConsistencyError);
|
||||
await _mockScheduledJobExecutionRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
await _mockScheduledJobExecutionRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), cancellationToken: Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -138,9 +141,9 @@ public class ScheduledJobExecutionCompletedDomainEventHandlerTests
|
||||
// Arrange
|
||||
ScheduledJobExecutionCompletedDomainEvent domainEvent = _scheduledJobExecutionCompletedDomainEventFixture.Create(isCycleRun: true);
|
||||
ScheduledJobEntity scheduledJob = _scheduledJobEntityFixture.Create(id: domainEvent.ScheduledJobId.Value, status: ScheduledJobStatus.Running);
|
||||
_mockScheduledJobRepository.GetByIdAsync(domainEvent.ScheduledJobId.Value, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(domainEvent.ScheduledJobId.Value, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(scheduledJob));
|
||||
_mockScheduledJobExecutionRepository.GetByIdAsync(domainEvent.RunId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobExecutionRepository.GetByIdAsync(domainEvent.RunId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobExecutionEntity?>(null));
|
||||
|
||||
// Act
|
||||
@@ -158,10 +161,10 @@ public class ScheduledJobExecutionCompletedDomainEventHandlerTests
|
||||
// Arrange
|
||||
ScheduledJobExecutionCompletedDomainEvent domainEvent = _scheduledJobExecutionCompletedDomainEventFixture.Create(isCycleRun: true);
|
||||
ScheduledJobEntity scheduledJob = _scheduledJobEntityFixture.Create(id: domainEvent.ScheduledJobId.Value, status: ScheduledJobStatus.Running);
|
||||
_mockScheduledJobRepository.GetByIdAsync(domainEvent.ScheduledJobId.Value, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(domainEvent.ScheduledJobId.Value, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(scheduledJob));
|
||||
ScheduledJobExecutionEntity execution = _scheduledJobExecutionEntityFixture.Create(id: domainEvent.RunId);
|
||||
_mockScheduledJobExecutionRepository.GetByIdAsync(domainEvent.RunId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobExecutionRepository.GetByIdAsync(domainEvent.RunId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobExecutionEntity?>(execution));
|
||||
Error error = Error.Failure("Database.Error", "Failed to update the execution");
|
||||
_mockScheduledJobExecutionRepository.UpdateAsync(Arg.Any<ScheduledJobExecutionEntity>(), Arg.Any<CancellationToken>()).Returns(error);
|
||||
@@ -181,13 +184,13 @@ public class ScheduledJobExecutionCompletedDomainEventHandlerTests
|
||||
// Arrange
|
||||
ScheduledJobExecutionCompletedDomainEvent domainEvent = _scheduledJobExecutionCompletedDomainEventFixture.Create(isCycleRun: true);
|
||||
ScheduledJobEntity scheduledJob = _scheduledJobEntityFixture.Create(id: domainEvent.ScheduledJobId.Value, status: ScheduledJobStatus.Running);
|
||||
_mockScheduledJobRepository.GetByIdAsync(domainEvent.ScheduledJobId.Value, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(domainEvent.ScheduledJobId.Value, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(scheduledJob));
|
||||
ScheduledJobExecutionEntity execution = _scheduledJobExecutionEntityFixture.Create(id: domainEvent.RunId);
|
||||
_mockScheduledJobExecutionRepository.GetByIdAsync(domainEvent.RunId, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobExecutionRepository.GetByIdAsync(domainEvent.RunId, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobExecutionEntity?>(execution));
|
||||
Error error = Error.Failure("Database.Error", "Failed to get the scheduled jobs");
|
||||
_mockScheduledJobRepository.GetAllAsync(Arg.Any<CancellationToken>()).Returns(error);
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(error);
|
||||
|
||||
// Act
|
||||
EventualConsistencyException exception = await Assert.ThrowsAsync<EventualConsistencyException>(
|
||||
|
||||
+11
-8
@@ -2,6 +2,8 @@
|
||||
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Scheduling;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Core.Scheduling.Events;
|
||||
using Lumina.Application.Core.Scheduling.Notifications;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Scheduling;
|
||||
@@ -44,6 +46,7 @@ public class ScheduledJobExecutionStartedDomainEventHandlerTests
|
||||
public ScheduledJobExecutionStartedDomainEventHandlerTests()
|
||||
{
|
||||
_mockUnitOfWork = Substitute.For<IUnitOfWork>();
|
||||
_mockUnitOfWork.SaveChangesAsync(Arg.Any<CancellationToken>()).Returns(Result.Success);
|
||||
_mockScheduledJobNotifier = Substitute.For<IScheduledJobNotifier>();
|
||||
_mockScheduledJobRepository = Substitute.For<IScheduledJobRepository>();
|
||||
_mockScheduledJobExecutionRepository = Substitute.For<IScheduledJobExecutionRepository>();
|
||||
@@ -52,7 +55,7 @@ public class ScheduledJobExecutionStartedDomainEventHandlerTests
|
||||
_mockUnitOfWork.ScheduledJobExecutionRepository.Returns(_mockScheduledJobExecutionRepository);
|
||||
_mockScheduledJobRepository.UpdateAsync(Arg.Any<ScheduledJobEntity>(), Arg.Any<CancellationToken>()).Returns(Result.Updated);
|
||||
_mockScheduledJobExecutionRepository.InsertAsync(Arg.Any<ScheduledJobExecutionEntity>(), Arg.Any<CancellationToken>()).Returns(Result.Created);
|
||||
_mockScheduledJobRepository.GetAllAsync(Arg.Any<CancellationToken>()).Returns(Result.From<IEnumerable<ScheduledJobEntity>>([]));
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
|
||||
_sut = new ScheduledJobExecutionStartedDomainEventHandler(_mockScheduledJobNotifier, _mockUnitOfWork);
|
||||
}
|
||||
@@ -68,7 +71,7 @@ public class ScheduledJobExecutionStartedDomainEventHandlerTests
|
||||
taskType: domainEvent.TaskType,
|
||||
scheduleType: ScheduleType.WithIntervalInMinutes,
|
||||
status: ScheduledJobStatus.Active);
|
||||
_mockScheduledJobRepository.GetByIdAsync(domainEvent.ScheduledJobId.Value, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(domainEvent.ScheduledJobId.Value, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(scheduledJob));
|
||||
|
||||
// Act
|
||||
@@ -100,7 +103,7 @@ public class ScheduledJobExecutionStartedDomainEventHandlerTests
|
||||
// Arrange
|
||||
ScheduledJobExecutionStartedDomainEvent domainEvent = _scheduledJobExecutionStartedDomainEventFixture.Create();
|
||||
Error error = Error.Failure("Database.Error", "Failed to get the scheduled job");
|
||||
_mockScheduledJobRepository.GetByIdAsync(domainEvent.ScheduledJobId.Value, Arg.Any<CancellationToken>()).Returns(error);
|
||||
_mockScheduledJobRepository.GetByIdAsync(domainEvent.ScheduledJobId.Value, cancellationToken: Arg.Any<CancellationToken>()).Returns(error);
|
||||
|
||||
// Act
|
||||
EventualConsistencyException exception = await Assert.ThrowsAsync<EventualConsistencyException>(
|
||||
@@ -116,7 +119,7 @@ public class ScheduledJobExecutionStartedDomainEventHandlerTests
|
||||
{
|
||||
// Arrange
|
||||
ScheduledJobExecutionStartedDomainEvent domainEvent = _scheduledJobExecutionStartedDomainEventFixture.Create();
|
||||
_mockScheduledJobRepository.GetByIdAsync(domainEvent.ScheduledJobId.Value, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(domainEvent.ScheduledJobId.Value, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(null));
|
||||
|
||||
// Act
|
||||
@@ -135,7 +138,7 @@ public class ScheduledJobExecutionStartedDomainEventHandlerTests
|
||||
ScheduledJobEntity scheduledJob = _scheduledJobEntityFixture.Create(
|
||||
id: domainEvent.ScheduledJobId.Value,
|
||||
status: ScheduledJobStatus.Active);
|
||||
_mockScheduledJobRepository.GetByIdAsync(domainEvent.ScheduledJobId.Value, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(domainEvent.ScheduledJobId.Value, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(scheduledJob));
|
||||
Error error = Error.Failure("Database.Error", "Failed to update the scheduled job");
|
||||
_mockScheduledJobRepository.UpdateAsync(Arg.Any<ScheduledJobEntity>(), Arg.Any<CancellationToken>()).Returns(error);
|
||||
@@ -155,7 +158,7 @@ public class ScheduledJobExecutionStartedDomainEventHandlerTests
|
||||
// Arrange
|
||||
ScheduledJobExecutionStartedDomainEvent domainEvent = _scheduledJobExecutionStartedDomainEventFixture.Create();
|
||||
ScheduledJobEntity scheduledJob = _scheduledJobEntityFixture.Create(id: domainEvent.ScheduledJobId.Value);
|
||||
_mockScheduledJobRepository.GetByIdAsync(domainEvent.ScheduledJobId.Value, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(domainEvent.ScheduledJobId.Value, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(scheduledJob));
|
||||
Error error = Error.Failure("Database.Error", "Failed to insert the execution");
|
||||
_mockScheduledJobExecutionRepository.InsertAsync(Arg.Any<ScheduledJobExecutionEntity>(), Arg.Any<CancellationToken>()).Returns(error);
|
||||
@@ -175,10 +178,10 @@ public class ScheduledJobExecutionStartedDomainEventHandlerTests
|
||||
// Arrange
|
||||
ScheduledJobExecutionStartedDomainEvent domainEvent = _scheduledJobExecutionStartedDomainEventFixture.Create();
|
||||
ScheduledJobEntity scheduledJob = _scheduledJobEntityFixture.Create(id: domainEvent.ScheduledJobId.Value);
|
||||
_mockScheduledJobRepository.GetByIdAsync(domainEvent.ScheduledJobId.Value, Arg.Any<CancellationToken>())
|
||||
_mockScheduledJobRepository.GetByIdAsync(domainEvent.ScheduledJobId.Value, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobEntity?>(scheduledJob));
|
||||
Error error = Error.Failure("Database.Error", "Failed to get the scheduled jobs");
|
||||
_mockScheduledJobRepository.GetAllAsync(Arg.Any<CancellationToken>()).Returns(error);
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(error);
|
||||
|
||||
// Act
|
||||
EventualConsistencyException exception = await Assert.ThrowsAsync<EventualConsistencyException>(
|
||||
|
||||
+5
-2
@@ -2,6 +2,8 @@
|
||||
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Scheduling;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Core.Scheduling.Events;
|
||||
using Lumina.Application.Core.Scheduling.Notifications;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Scheduling;
|
||||
@@ -40,6 +42,7 @@ public class ScheduledJobExecutionStoppedDomainEventHandlerTests
|
||||
public ScheduledJobExecutionStoppedDomainEventHandlerTests()
|
||||
{
|
||||
_mockUnitOfWork = Substitute.For<IUnitOfWork>();
|
||||
_mockUnitOfWork.SaveChangesAsync(Arg.Any<CancellationToken>()).Returns(Result.Success);
|
||||
_mockScheduledJobNotifier = Substitute.For<IScheduledJobNotifier>();
|
||||
_mockScheduledJobRepository = Substitute.For<IScheduledJobRepository>();
|
||||
_mockScheduledJobExecutionRepository = Substitute.For<IScheduledJobExecutionRepository>();
|
||||
@@ -47,7 +50,7 @@ public class ScheduledJobExecutionStoppedDomainEventHandlerTests
|
||||
_mockUnitOfWork.ScheduledJobRepository.Returns(_mockScheduledJobRepository);
|
||||
_mockUnitOfWork.ScheduledJobExecutionRepository.Returns(_mockScheduledJobExecutionRepository);
|
||||
_mockScheduledJobExecutionRepository.UpdateAsync(Arg.Any<ScheduledJobExecutionEntity>(), Arg.Any<CancellationToken>()).Returns(Result.Updated);
|
||||
_mockScheduledJobRepository.GetAllAsync(Arg.Any<CancellationToken>()).Returns(Result.From<IEnumerable<ScheduledJobEntity>>([]));
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
|
||||
_sut = new ScheduledJobExecutionStoppedDomainEventHandler(_mockScheduledJobNotifier, _mockUnitOfWork);
|
||||
}
|
||||
@@ -140,7 +143,7 @@ public class ScheduledJobExecutionStoppedDomainEventHandlerTests
|
||||
_mockScheduledJobExecutionRepository.GetOpenByScheduledJobIdAsync(domainEvent.ScheduledJobId.Value, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ScheduledJobExecutionEntity?>(null));
|
||||
Error error = Error.Failure("Database.Error", "Failed to get the scheduled jobs");
|
||||
_mockScheduledJobRepository.GetAllAsync(Arg.Any<CancellationToken>()).Returns(error);
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(error);
|
||||
|
||||
// Act
|
||||
EventualConsistencyException exception = await Assert.ThrowsAsync<EventualConsistencyException>(
|
||||
|
||||
+6
-3
@@ -2,6 +2,8 @@
|
||||
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Scheduling;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Core.Scheduling.Events;
|
||||
using Lumina.Application.Core.Scheduling.Notifications;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Scheduling;
|
||||
@@ -39,11 +41,12 @@ public class ScheduledJobRemovedDomainEventHandlerTests
|
||||
public ScheduledJobRemovedDomainEventHandlerTests()
|
||||
{
|
||||
_mockUnitOfWork = Substitute.For<IUnitOfWork>();
|
||||
_mockUnitOfWork.SaveChangesAsync(Arg.Any<CancellationToken>()).Returns(Result.Success);
|
||||
_mockScheduledJobNotifier = Substitute.For<IScheduledJobNotifier>();
|
||||
_mockScheduledJobRepository = Substitute.For<IScheduledJobRepository>();
|
||||
|
||||
_mockUnitOfWork.ScheduledJobRepository.Returns(_mockScheduledJobRepository);
|
||||
_mockScheduledJobRepository.GetAllAsync(Arg.Any<CancellationToken>()).Returns(Result.From<IEnumerable<ScheduledJobEntity>>([]));
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
|
||||
_sut = new ScheduledJobRemovedDomainEventHandler(_mockScheduledJobNotifier, _mockUnitOfWork);
|
||||
}
|
||||
@@ -54,7 +57,7 @@ public class ScheduledJobRemovedDomainEventHandlerTests
|
||||
// Arrange
|
||||
ScheduledJobRemovedDomainEvent domainEvent = _scheduledJobRemovedDomainEventFixture.Create();
|
||||
ScheduledJobEntity remainingJob = _scheduledJobEntityFixture.Create(name: "Remaining job");
|
||||
_mockScheduledJobRepository.GetAllAsync(Arg.Any<CancellationToken>()).Returns(Result.From<IEnumerable<ScheduledJobEntity>>([remainingJob]));
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity> { Data = [remainingJob], CurrentPage = 1, PerPage = 1, Count = 1, NumberOfPages = 1 }));
|
||||
|
||||
// Act
|
||||
await _sut.HandleAsync(domainEvent, CancellationToken.None);
|
||||
@@ -71,7 +74,7 @@ public class ScheduledJobRemovedDomainEventHandlerTests
|
||||
// Arrange
|
||||
ScheduledJobRemovedDomainEvent domainEvent = _scheduledJobRemovedDomainEventFixture.Create();
|
||||
Error error = Error.Failure("Database.Error", "Failed to get the scheduled jobs");
|
||||
_mockScheduledJobRepository.GetAllAsync(Arg.Any<CancellationToken>()).Returns(error);
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(error);
|
||||
|
||||
// Act
|
||||
EventualConsistencyException exception = await Assert.ThrowsAsync<EventualConsistencyException>(
|
||||
|
||||
+1
@@ -42,6 +42,7 @@ public class GetScheduledJobHistoryQueryHandlerTests
|
||||
public GetScheduledJobHistoryQueryHandlerTests()
|
||||
{
|
||||
_mockUnitOfWork = Substitute.For<IUnitOfWork>();
|
||||
_mockUnitOfWork.SaveChangesAsync(Arg.Any<CancellationToken>()).Returns(Result.Success);
|
||||
_mockCurrentUserService = Substitute.For<ICurrentUserService>();
|
||||
_mockAuthorizationService = Substitute.For<IAuthorizationService>();
|
||||
_mockScheduledJobExecutionRepository = Substitute.For<IScheduledJobExecutionRepository>();
|
||||
|
||||
+10
-7
@@ -2,6 +2,8 @@
|
||||
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Scheduling;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Core.Scheduling.Queries.GetScheduledJobs;
|
||||
@@ -40,6 +42,7 @@ public class GetScheduledJobsQueryHandlerTests
|
||||
public GetScheduledJobsQueryHandlerTests()
|
||||
{
|
||||
_mockUnitOfWork = Substitute.For<IUnitOfWork>();
|
||||
_mockUnitOfWork.SaveChangesAsync(Arg.Any<CancellationToken>()).Returns(Result.Success);
|
||||
_mockCurrentUserService = Substitute.For<ICurrentUserService>();
|
||||
_mockAuthorizationService = Substitute.For<IAuthorizationService>();
|
||||
_mockScheduledJobRepository = Substitute.For<IScheduledJobRepository>();
|
||||
@@ -57,8 +60,8 @@ public class GetScheduledJobsQueryHandlerTests
|
||||
// Arrange
|
||||
ScheduledJobEntity scheduledJob1 = _scheduledJobEntityFixture.Create(name: "Job 1");
|
||||
ScheduledJobEntity scheduledJob2 = _scheduledJobEntityFixture.Create(name: "Job 2");
|
||||
_mockScheduledJobRepository.GetAllAsync(Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<IEnumerable<ScheduledJobEntity>>([scheduledJob1, scheduledJob2]));
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity> { Data = [scheduledJob1, scheduledJob2], CurrentPage = 1, PerPage = 2, Count = 2, NumberOfPages = 1 }));
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<ScheduledJobResponse>> result = await _sut.HandleAsync(new GetScheduledJobsQuery(), CancellationToken.None);
|
||||
@@ -74,8 +77,8 @@ public class GetScheduledJobsQueryHandlerTests
|
||||
public async Task HandleAsync_WhenNoScheduledJobsExist_ShouldReturnEmptyCollection()
|
||||
{
|
||||
// Arrange
|
||||
_mockScheduledJobRepository.GetAllAsync(Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<IEnumerable<ScheduledJobEntity>>([]));
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<ScheduledJobResponse>> result = await _sut.HandleAsync(new GetScheduledJobsQuery(), CancellationToken.None);
|
||||
@@ -97,7 +100,7 @@ public class GetScheduledJobsQueryHandlerTests
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(ApplicationErrors.Authorization.NotAuthorized, result.FirstError);
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetAllAsync(Arg.Any<CancellationToken>());
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -112,7 +115,7 @@ public class GetScheduledJobsQueryHandlerTests
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(ApplicationErrors.Authorization.NotAuthorized, result.FirstError);
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetAllAsync(Arg.Any<CancellationToken>());
|
||||
await _mockScheduledJobRepository.DidNotReceive().GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -120,7 +123,7 @@ public class GetScheduledJobsQueryHandlerTests
|
||||
{
|
||||
// Arrange
|
||||
Error error = Error.Failure("Database.Error", "Failed to get the scheduled jobs");
|
||||
_mockScheduledJobRepository.GetAllAsync(Arg.Any<CancellationToken>()).Returns(error);
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(error);
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<ScheduledJobResponse>> result = await _sut.HandleAsync(new GetScheduledJobsQuery(), CancellationToken.None);
|
||||
|
||||
+1
@@ -42,6 +42,7 @@ public class GetSchedulerDisplayPreferencesQueryHandlerTests
|
||||
public GetSchedulerDisplayPreferencesQueryHandlerTests()
|
||||
{
|
||||
_mockUnitOfWork = Substitute.For<IUnitOfWork>();
|
||||
_mockUnitOfWork.SaveChangesAsync(Arg.Any<CancellationToken>()).Returns(Result.Success);
|
||||
_mockCurrentUserService = Substitute.For<ICurrentUserService>();
|
||||
_mockAuthorizationService = Substitute.For<IAuthorizationService>();
|
||||
_mockSchedulerDisplayPreferencesRepository = Substitute.For<ISchedulerDisplayPreferencesRepository>();
|
||||
|
||||
Reference in new issue
Block a user