Renames project paths from Lumina to Nemera

This commit is contained in:
BinaryAlley committed 2026-11-27 15:34:43 +02:00
1 parent ce6fddb4c9
commit 0f659a4877
6450 files changed

No files matched your search

@@ -0,0 +1,70 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.UnitTests.Core.BoundedContexts.SchedulingBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
/// <summary>
/// Contains unit tests for the <see cref="UserId"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class UserIdTests
{
private readonly UserIdFixture _userIdFixture = new();
[Fact]
public void CreateUnique_WhenCalled_ShouldReturnIdWithNonEmptyValue()
{
// Act
UserId userId = UserId.CreateUnique();
// Assert
Assert.NotNull(userId);
Assert.NotEqual(default, userId.Value);
}
[Fact]
public void Create_WhenCalledWithValue_ShouldReturnIdWithThatValue()
{
// Arrange
Guid value = Guid.NewGuid();
// Act
UserId userId = UserId.Create(value);
// Assert
Assert.Equal(value, userId.Value);
}
[Fact]
public void Equals_WithSameValue_ShouldReturnTrue()
{
// Arrange
Guid value = Guid.NewGuid();
UserId firstId = _userIdFixture.Create(value);
UserId secondId = _userIdFixture.Create(value);
// Act
bool result = firstId.Equals(secondId);
// Assert
Assert.True(result);
}
[Fact]
public void Equals_WithDifferentValue_ShouldReturnFalse()
{
// Arrange
UserId firstId = _userIdFixture.Create();
UserId secondId = _userIdFixture.Create();
// Act
bool result = firstId.Equals(secondId);
// Assert
Assert.False(result);
}
}
@@ -0,0 +1,39 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Events;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.UnitTests.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
/// <summary>
/// Contains unit tests for the <see cref="ScheduledJobAddedDomainEvent"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class ScheduledJobAddedDomainEventTests
{
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
private readonly ScheduledJobAddedDomainEventFixture _scheduledJobAddedDomainEventFixture = new();
[Fact]
public void Constructor_WhenCalled_ShouldSetAllProperties()
{
// Arrange
Guid id = Guid.NewGuid();
ScheduledJobId scheduledJobId = _scheduledJobIdFixture.Create();
DateTime occurredOnUtc = DateTime.UtcNow;
// Act
ScheduledJobAddedDomainEvent domainEvent = _scheduledJobAddedDomainEventFixture.Create(id, scheduledJobId, occurredOnUtc);
// Assert
Assert.Equal(id, domainEvent.Id);
Assert.Equal(scheduledJobId, domainEvent.ScheduledJobId);
Assert.Equal(occurredOnUtc, domainEvent.OccurredOnUtc);
Assert.IsType<IDomainEvent>(domainEvent, exactMatch: false);
}
}
@@ -0,0 +1,39 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Events;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.UnitTests.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
/// <summary>
/// Contains unit tests for the <see cref="ScheduledJobCycleStartedDomainEvent"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class ScheduledJobCycleStartedDomainEventTests
{
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
private readonly ScheduledJobCycleStartedDomainEventFixture _scheduledJobCycleStartedDomainEventFixture = new();
[Fact]
public void Constructor_WhenCalled_ShouldSetAllProperties()
{
// Arrange
Guid id = Guid.NewGuid();
ScheduledJobId scheduledJobId = _scheduledJobIdFixture.Create();
DateTime occurredOnUtc = DateTime.UtcNow;
// Act
ScheduledJobCycleStartedDomainEvent domainEvent = _scheduledJobCycleStartedDomainEventFixture.Create(id, scheduledJobId, occurredOnUtc);
// Assert
Assert.Equal(id, domainEvent.Id);
Assert.Equal(scheduledJobId, domainEvent.ScheduledJobId);
Assert.Equal(occurredOnUtc, domainEvent.OccurredOnUtc);
Assert.IsType<IDomainEvent>(domainEvent, exactMatch: false);
}
}
@@ -0,0 +1,39 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Events;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.UnitTests.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
/// <summary>
/// Contains unit tests for the <see cref="ScheduledJobCycleStoppedDomainEvent"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class ScheduledJobCycleStoppedDomainEventTests
{
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
private readonly ScheduledJobCycleStoppedDomainEventFixture _scheduledJobCycleStoppedDomainEventFixture = new();
[Fact]
public void Constructor_WhenCalled_ShouldSetAllProperties()
{
// Arrange
Guid id = Guid.NewGuid();
ScheduledJobId scheduledJobId = _scheduledJobIdFixture.Create();
DateTime occurredOnUtc = DateTime.UtcNow;
// Act
ScheduledJobCycleStoppedDomainEvent domainEvent = _scheduledJobCycleStoppedDomainEventFixture.Create(id, scheduledJobId, occurredOnUtc);
// Assert
Assert.Equal(id, domainEvent.Id);
Assert.Equal(scheduledJobId, domainEvent.ScheduledJobId);
Assert.Equal(occurredOnUtc, domainEvent.OccurredOnUtc);
Assert.IsType<IDomainEvent>(domainEvent, exactMatch: false);
}
}
@@ -0,0 +1,47 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Events;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.UnitTests.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
/// <summary>
/// Contains unit tests for the <see cref="ScheduledJobExecutionCompletedDomainEvent"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class ScheduledJobExecutionCompletedDomainEventTests
{
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
private readonly ScheduledJobExecutionCompletedDomainEventFixture _scheduledJobExecutionCompletedDomainEventFixture = new();
[Fact]
public void Constructor_WhenCalled_ShouldSetAllProperties()
{
// Arrange
Guid id = Guid.NewGuid();
ScheduledJobId scheduledJobId = _scheduledJobIdFixture.Create();
Guid runId = Guid.NewGuid();
ScheduledTaskType taskType = ScheduledTaskType.CleanTemporaryFiles;
bool isCycleRun = false;
DateTime completedOnUtc = DateTime.UtcNow;
// Act
ScheduledJobExecutionCompletedDomainEvent domainEvent = _scheduledJobExecutionCompletedDomainEventFixture.Create(id, scheduledJobId, runId, taskType, isCycleRun, completedOnUtc);
// Assert
Assert.Equal(id, domainEvent.Id);
Assert.Equal(scheduledJobId, domainEvent.ScheduledJobId);
Assert.Equal(runId, domainEvent.RunId);
Assert.Equal(taskType, domainEvent.TaskType);
Assert.Equal(isCycleRun, domainEvent.IsCycleRun);
Assert.Equal(completedOnUtc, domainEvent.CompletedOnUtc);
Assert.Equal(completedOnUtc, domainEvent.OccurredOnUtc);
Assert.IsType<IDomainEvent>(domainEvent, exactMatch: false);
}
}
@@ -0,0 +1,47 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Events;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.UnitTests.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
/// <summary>
/// Contains unit tests for the <see cref="ScheduledJobExecutionStartedDomainEvent"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class ScheduledJobExecutionStartedDomainEventTests
{
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
private readonly ScheduledJobExecutionStartedDomainEventFixture _scheduledJobExecutionStartedDomainEventFixture = new();
[Fact]
public void Constructor_WhenCalled_ShouldSetAllProperties()
{
// Arrange
Guid id = Guid.NewGuid();
ScheduledJobId scheduledJobId = _scheduledJobIdFixture.Create();
Guid runId = Guid.NewGuid();
ScheduledTaskType taskType = ScheduledTaskType.ScanMediaLibraries;
bool isCycleRun = true;
DateTime startedOnUtc = DateTime.UtcNow;
// Act
ScheduledJobExecutionStartedDomainEvent domainEvent = _scheduledJobExecutionStartedDomainEventFixture.Create(id, scheduledJobId, runId, taskType, isCycleRun, startedOnUtc);
// Assert
Assert.Equal(id, domainEvent.Id);
Assert.Equal(scheduledJobId, domainEvent.ScheduledJobId);
Assert.Equal(runId, domainEvent.RunId);
Assert.Equal(taskType, domainEvent.TaskType);
Assert.Equal(isCycleRun, domainEvent.IsCycleRun);
Assert.Equal(startedOnUtc, domainEvent.StartedOnUtc);
Assert.Equal(startedOnUtc, domainEvent.OccurredOnUtc);
Assert.IsType<IDomainEvent>(domainEvent, exactMatch: false);
}
}
@@ -0,0 +1,39 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Events;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.UnitTests.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
/// <summary>
/// Contains unit tests for the <see cref="ScheduledJobExecutionStoppedDomainEvent"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class ScheduledJobExecutionStoppedDomainEventTests
{
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
private readonly ScheduledJobExecutionStoppedDomainEventFixture _scheduledJobExecutionStoppedDomainEventFixture = new();
[Fact]
public void Constructor_WhenCalled_ShouldSetAllProperties()
{
// Arrange
Guid id = Guid.NewGuid();
ScheduledJobId scheduledJobId = _scheduledJobIdFixture.Create();
DateTime occurredOnUtc = DateTime.UtcNow;
// Act
ScheduledJobExecutionStoppedDomainEvent domainEvent = _scheduledJobExecutionStoppedDomainEventFixture.Create(id, scheduledJobId, occurredOnUtc);
// Assert
Assert.Equal(id, domainEvent.Id);
Assert.Equal(scheduledJobId, domainEvent.ScheduledJobId);
Assert.Equal(occurredOnUtc, domainEvent.OccurredOnUtc);
Assert.IsType<IDomainEvent>(domainEvent, exactMatch: false);
}
}
@@ -0,0 +1,39 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Events;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.UnitTests.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
/// <summary>
/// Contains unit tests for the <see cref="ScheduledJobFiredDomainEvent"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class ScheduledJobFiredDomainEventTests
{
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
private readonly ScheduledJobFiredDomainEventFixture _scheduledJobFiredDomainEventFixture = new();
[Fact]
public void Constructor_WhenCalled_ShouldSetAllProperties()
{
// Arrange
Guid id = Guid.NewGuid();
ScheduledJobId scheduledJobId = _scheduledJobIdFixture.Create();
DateTime occurredOnUtc = DateTime.UtcNow;
// Act
ScheduledJobFiredDomainEvent domainEvent = _scheduledJobFiredDomainEventFixture.Create(id, scheduledJobId, occurredOnUtc);
// Assert
Assert.Equal(id, domainEvent.Id);
Assert.Equal(scheduledJobId, domainEvent.ScheduledJobId);
Assert.Equal(occurredOnUtc, domainEvent.OccurredOnUtc);
Assert.IsType<IDomainEvent>(domainEvent, exactMatch: false);
}
}
@@ -0,0 +1,39 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Events;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.UnitTests.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
/// <summary>
/// Contains unit tests for the <see cref="ScheduledJobRemovedDomainEvent"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class ScheduledJobRemovedDomainEventTests
{
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
private readonly ScheduledJobRemovedDomainEventFixture _scheduledJobRemovedDomainEventFixture = new();
[Fact]
public void Constructor_WhenCalled_ShouldSetAllProperties()
{
// Arrange
Guid id = Guid.NewGuid();
ScheduledJobId scheduledJobId = _scheduledJobIdFixture.Create();
DateTime occurredOnUtc = DateTime.UtcNow;
// Act
ScheduledJobRemovedDomainEvent domainEvent = _scheduledJobRemovedDomainEventFixture.Create(id, scheduledJobId, occurredOnUtc);
// Assert
Assert.Equal(id, domainEvent.Id);
Assert.Equal(scheduledJobId, domainEvent.ScheduledJobId);
Assert.Equal(occurredOnUtc, domainEvent.OccurredOnUtc);
Assert.IsType<IDomainEvent>(domainEvent, exactMatch: false);
}
}
@@ -0,0 +1,406 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.UnitTests.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate;
/// <summary>
/// Contains unit tests for the <see cref="ScheduledJob"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class ScheduledJobTests
{
private readonly ScheduledJobFixture _scheduledJobFixture = new();
private readonly IntervalScheduleFixture _intervalScheduleFixture = new();
private readonly DailyScheduleFixture _dailyScheduleFixture = new();
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
private readonly UserIdFixture _userIdFixture = new();
[Fact]
public void Create_WhenCalledWithValidData_ShouldCreateAddedScheduledJobWithAllPropertiesSet()
{
// Arrange
string name = "Scan libraries every hour";
ScheduledTaskType taskType = ScheduledTaskType.ScanMediaLibraries;
IntervalSchedule schedule = _intervalScheduleFixture.Create(intervalMinutes: 60);
UserId ownerUserId = _userIdFixture.Create();
// Act
Result<ScheduledJob> result = ScheduledJob.Create(name, taskType, schedule, ownerUserId);
// Assert
Assert.False(result.IsFailure);
Assert.Equal(name, result.Value.Name);
Assert.Equal(taskType, result.Value.TaskType);
Assert.Equal(schedule, result.Value.Schedule);
Assert.Equal(ownerUserId, result.Value.OwnerUserId);
Assert.Equal(ScheduledJobStatus.Added, result.Value.Status);
Assert.False(result.Value.LastStartedOnUtc.HasValue);
Assert.False(result.Value.LastCompletedOnUtc.HasValue);
Assert.Empty(result.Value.GetDomainEvents());
}
[Fact]
public void Create_WhenCalledTwice_ShouldGenerateDistinctIds()
{
// Act
Result<ScheduledJob> firstResult = ScheduledJob.Create("Job 1", ScheduledTaskType.ScanMediaLibraries, _intervalScheduleFixture.Create(), _userIdFixture.Create());
Result<ScheduledJob> secondResult = ScheduledJob.Create("Job 2", ScheduledTaskType.ScanMediaLibraries, _intervalScheduleFixture.Create(), _userIdFixture.Create());
// Assert
Assert.False(firstResult.IsFailure);
Assert.False(secondResult.IsFailure);
Assert.NotEqual(firstResult.Value.Id.Value, secondResult.Value.Id.Value);
}
[Theory]
[InlineData(null)] // Null name.
[InlineData("")] // Empty name.
[InlineData(" ")] // Whitespace name.
public void Create_WhenNameIsEmptyOrWhitespace_ShouldReturnError(string? name)
{
// Act
Result<ScheduledJob> result = ScheduledJob.Create(name!, ScheduledTaskType.ScanMediaLibraries, _intervalScheduleFixture.Create(), _userIdFixture.Create());
// Assert
Assert.True(result.IsFailure);
Assert.Equal(Errors.Scheduling.ScheduledJobNameCannotBeEmpty, result.FirstError);
}
[Fact]
public void Create_WhenCalledWithPreExistingIdAndData_ShouldCreateScheduledJobWithThatIdAndState()
{
// Arrange
Guid id = Guid.NewGuid();
DateTime lastStartedOnUtc = DateTime.UtcNow.AddHours(-1);
DateTime lastCompletedOnUtc = DateTime.UtcNow.AddMinutes(-30);
// Act
Result<ScheduledJob> result = ScheduledJob.Create(
_scheduledJobIdFixture.Create(id),
"Daily cleanup",
ScheduledTaskType.CleanTemporaryFiles,
_dailyScheduleFixture.Create(hour: 3, minute: 0),
_userIdFixture.Create(),
ScheduledJobStatus.Active,
Optional<DateTime>.Some(lastStartedOnUtc),
Optional<DateTime>.Some(lastCompletedOnUtc));
// Assert
Assert.False(result.IsFailure);
Assert.Equal(id, result.Value.Id.Value);
Assert.Equal(ScheduledJobStatus.Active, result.Value.Status);
Assert.Equal(lastStartedOnUtc, result.Value.LastStartedOnUtc.Value);
Assert.Equal(lastCompletedOnUtc, result.Value.LastCompletedOnUtc.Value);
}
[Fact]
public void Add_WhenStatusIsAdded_ShouldSucceedAndRaiseAddedEvent()
{
// Arrange
ScheduledJob scheduledJob = _scheduledJobFixture.Create();
// Act
Result<Success> result = scheduledJob.Add();
// Assert
Assert.False(result.IsFailure);
Assert.Equal(Result.Success, result.Value);
Assert.Equal(ScheduledJobStatus.Added, scheduledJob.Status);
ScheduledJobAddedDomainEvent addedEvent = Assert.IsType<ScheduledJobAddedDomainEvent>(Assert.Single(scheduledJob.GetDomainEvents()));
Assert.Equal(scheduledJob.Id, addedEvent.ScheduledJobId);
Assert.NotEqual(default, addedEvent.OccurredOnUtc);
}
[Theory]
[InlineData(ScheduledJobStatus.Active)] // Cannot add an already active scheduled job.
[InlineData(ScheduledJobStatus.Running)] // Cannot add a running scheduled job.
[InlineData(ScheduledJobStatus.Completed)] // Cannot add a completed scheduled job.
public void Add_WhenStatusIsNotAdded_ShouldReturnError(ScheduledJobStatus status)
{
// Arrange
ScheduledJob scheduledJob = _scheduledJobFixture.Create(status: status);
// Act
Result<Success> result = scheduledJob.Add();
// Assert
Assert.True(result.IsFailure);
Assert.Equal(Errors.Scheduling.ScheduledJobCycleAlreadyStarted, result.FirstError);
Assert.Empty(scheduledJob.GetDomainEvents());
}
[Fact]
public void StartCycle_WhenStatusIsAdded_ShouldTransitionToActiveAndRaiseCycleStartedEvent()
{
// Arrange
ScheduledJob scheduledJob = _scheduledJobFixture.Create();
// Act
Result<Success> result = scheduledJob.StartCycle();
// Assert
Assert.False(result.IsFailure);
Assert.Equal(Result.Success, result.Value);
Assert.Equal(ScheduledJobStatus.Active, scheduledJob.Status);
ScheduledJobCycleStartedDomainEvent cycleStartedEvent = Assert.IsType<ScheduledJobCycleStartedDomainEvent>(Assert.Single(scheduledJob.GetDomainEvents()));
Assert.Equal(scheduledJob.Id, cycleStartedEvent.ScheduledJobId);
}
[Theory]
[InlineData(ScheduledJobStatus.Active)] // Cannot start an already active execution cycle.
[InlineData(ScheduledJobStatus.Running)] // Cannot start a running execution cycle.
public void StartCycle_WhenCycleAlreadyStarted_ShouldReturnError(ScheduledJobStatus status)
{
// Arrange
ScheduledJob scheduledJob = _scheduledJobFixture.Create(status: status);
// Act
Result<Success> result = scheduledJob.StartCycle();
// Assert
Assert.True(result.IsFailure);
Assert.Equal(Errors.Scheduling.ScheduledJobCycleAlreadyStarted, result.FirstError);
Assert.Equal(status, scheduledJob.Status);
Assert.Empty(scheduledJob.GetDomainEvents());
}
[Fact]
public void StopCycle_WhenStatusIsActive_ShouldTransitionToAddedAndRaiseCycleStoppedEvent()
{
// Arrange
ScheduledJob scheduledJob = _scheduledJobFixture.Create();
scheduledJob.StartCycle();
scheduledJob.GetDomainEvents();
// Act
Result<Success> result = scheduledJob.StopCycle();
// Assert
Assert.False(result.IsFailure);
Assert.Equal(Result.Success, result.Value);
Assert.Equal(ScheduledJobStatus.Added, scheduledJob.Status);
ScheduledJobCycleStoppedDomainEvent cycleStoppedEvent = Assert.IsType<ScheduledJobCycleStoppedDomainEvent>(Assert.Single(scheduledJob.GetDomainEvents()));
Assert.Equal(scheduledJob.Id, cycleStoppedEvent.ScheduledJobId);
}
[Fact]
public void StopCycle_WhenStatusIsRunning_ShouldTransitionToAddedAndRaiseExecutionStoppedEvent()
{
// Arrange
ScheduledJob scheduledJob = _scheduledJobFixture.Create();
scheduledJob.StartCycle();
scheduledJob.MarkExecutionStarted(isCycleRun: true);
scheduledJob.GetDomainEvents();
// Act
Result<Success> result = scheduledJob.StopCycle();
// Assert
Assert.False(result.IsFailure);
Assert.Equal(Result.Success, result.Value);
Assert.Equal(ScheduledJobStatus.Added, scheduledJob.Status);
Assert.True(scheduledJob.LastCompletedOnUtc.HasValue);
ScheduledJobExecutionStoppedDomainEvent executionStoppedEvent = Assert.IsType<ScheduledJobExecutionStoppedDomainEvent>(Assert.Single(scheduledJob.GetDomainEvents()));
Assert.Equal(scheduledJob.Id, executionStoppedEvent.ScheduledJobId);
}
[Theory]
[InlineData(ScheduledJobStatus.Added)] // Cannot stop a cycle that was never started.
[InlineData(ScheduledJobStatus.Completed)] // Cannot stop a finished one time execution.
public void StopCycle_WhenCycleWasNeverStarted_ShouldReturnError(ScheduledJobStatus status)
{
// Arrange
ScheduledJob scheduledJob = _scheduledJobFixture.Create(status: status);
// Act
Result<Success> result = scheduledJob.StopCycle();
// Assert
Assert.True(result.IsFailure);
Assert.Equal(Errors.Scheduling.ScheduledJobNotStarted, result.FirstError);
Assert.Equal(status, scheduledJob.Status);
Assert.Empty(scheduledJob.GetDomainEvents());
}
[Fact]
public void Fire_WhenStatusIsNotRunning_ShouldSucceedAndRaiseFiredEvent()
{
// Arrange
ScheduledJob scheduledJob = _scheduledJobFixture.Create();
// Act
Result<Success> result = scheduledJob.Fire();
// Assert
Assert.False(result.IsFailure);
Assert.Equal(Result.Success, result.Value);
ScheduledJobFiredDomainEvent firedEvent = Assert.IsType<ScheduledJobFiredDomainEvent>(Assert.Single(scheduledJob.GetDomainEvents()));
Assert.Equal(scheduledJob.Id, firedEvent.ScheduledJobId);
}
[Fact]
public void Fire_WhenStatusIsRunning_ShouldReturnError()
{
// Arrange
ScheduledJob scheduledJob = _scheduledJobFixture.Create();
scheduledJob.StartCycle();
scheduledJob.MarkExecutionStarted(isCycleRun: true);
scheduledJob.GetDomainEvents();
// Act
Result<Success> result = scheduledJob.Fire();
// Assert
Assert.True(result.IsFailure);
Assert.Equal(Errors.Scheduling.ScheduledJobAlreadyRunning, result.FirstError);
Assert.Empty(scheduledJob.GetDomainEvents());
}
[Fact]
public void Remove_WhenCalled_ShouldSucceedAndRaiseRemovedEvent()
{
// Arrange
ScheduledJob scheduledJob = _scheduledJobFixture.Create();
// Act
Result<Success> result = scheduledJob.Remove();
// Assert
Assert.False(result.IsFailure);
Assert.Equal(Result.Success, result.Value);
ScheduledJobRemovedDomainEvent removedEvent = Assert.IsType<ScheduledJobRemovedDomainEvent>(Assert.Single(scheduledJob.GetDomainEvents()));
Assert.Equal(scheduledJob.Id, removedEvent.ScheduledJobId);
}
[Theory]
[InlineData(true)] // Cycle run.
[InlineData(false)] // One time run.
public void MarkExecutionStarted_WhenStatusIsNotRunning_ShouldTransitionToRunningAndRaiseExecutionStartedEvent(bool isCycleRun)
{
// Arrange
ScheduledJob scheduledJob = _scheduledJobFixture.Create();
// Act
Result<Success> result = scheduledJob.MarkExecutionStarted(isCycleRun);
// Assert
Assert.False(result.IsFailure);
Assert.Equal(Result.Success, result.Value);
Assert.Equal(ScheduledJobStatus.Running, scheduledJob.Status);
Assert.True(scheduledJob.LastStartedOnUtc.HasValue);
ScheduledJobExecutionStartedDomainEvent startedEvent = Assert.IsType<ScheduledJobExecutionStartedDomainEvent>(Assert.Single(scheduledJob.GetDomainEvents()));
Assert.Equal(scheduledJob.Id, startedEvent.ScheduledJobId);
Assert.Equal(scheduledJob.TaskType, startedEvent.TaskType);
Assert.Equal(isCycleRun, startedEvent.IsCycleRun);
Assert.NotEqual(Guid.Empty, startedEvent.RunId);
}
[Fact]
public void MarkExecutionStarted_WhenStatusIsRunning_ShouldReturnError()
{
// Arrange
ScheduledJob scheduledJob = _scheduledJobFixture.Create();
scheduledJob.StartCycle();
scheduledJob.MarkExecutionStarted(isCycleRun: true);
scheduledJob.GetDomainEvents();
// Act
Result<Success> result = scheduledJob.MarkExecutionStarted(isCycleRun: true);
// Assert
Assert.True(result.IsFailure);
Assert.Equal(Errors.Scheduling.ScheduledJobAlreadyRunning, result.FirstError);
Assert.Empty(scheduledJob.GetDomainEvents());
}
[Theory]
[InlineData(true)] // A cycle run returns the scheduled job to its active status.
[InlineData(false)] // A one time execution completes the scheduled job.
public void MarkExecutionCompleted_WhenStatusIsRunning_ShouldTransitionStatusAndRaiseExecutionCompletedEvent(bool isCycleRun)
{
// Arrange
ScheduledJob scheduledJob = _scheduledJobFixture.Create();
scheduledJob.StartCycle();
scheduledJob.MarkExecutionStarted(isCycleRun);
scheduledJob.GetDomainEvents();
// Act
Result<Success> result = scheduledJob.MarkExecutionCompleted(isCycleRun);
// Assert
Assert.False(result.IsFailure);
Assert.Equal(Result.Success, result.Value);
Assert.Equal(isCycleRun ? ScheduledJobStatus.Active : ScheduledJobStatus.Completed, scheduledJob.Status);
Assert.True(scheduledJob.LastCompletedOnUtc.HasValue);
ScheduledJobExecutionCompletedDomainEvent completedEvent = Assert.IsType<ScheduledJobExecutionCompletedDomainEvent>(Assert.Single(scheduledJob.GetDomainEvents()));
Assert.Equal(scheduledJob.Id, completedEvent.ScheduledJobId);
Assert.Equal(scheduledJob.TaskType, completedEvent.TaskType);
Assert.Equal(isCycleRun, completedEvent.IsCycleRun);
Assert.NotEqual(Guid.Empty, completedEvent.RunId);
}
[Theory]
[InlineData(ScheduledJobStatus.Added)] // Cannot complete an execution that never started.
[InlineData(ScheduledJobStatus.Active)] // Cannot complete an execution that never started.
[InlineData(ScheduledJobStatus.Completed)] // Cannot complete an already completed execution.
public void MarkExecutionCompleted_WhenStatusIsNotRunning_ShouldReturnError(ScheduledJobStatus status)
{
// Arrange
ScheduledJob scheduledJob = _scheduledJobFixture.Create(status: status);
// Act
Result<Success> result = scheduledJob.MarkExecutionCompleted(isCycleRun: true);
// Assert
Assert.True(result.IsFailure);
Assert.Equal(Errors.Scheduling.CanOnlyCompleteRunningScheduledJob, result.FirstError);
Assert.Empty(scheduledJob.GetDomainEvents());
}
[Fact]
public void MarkExecutionCompleted_WhenLoadedFromStorageWithoutActiveRunId_ShouldReturnError()
{
// Arrange
// A scheduled job loaded from the storage medium with a running status has no active run id tracked by the aggregate.
ScheduledJob scheduledJob = _scheduledJobFixture.Create(
id: Guid.NewGuid(),
status: ScheduledJobStatus.Running,
lastStartedOnUtc: DateTime.UtcNow.AddMinutes(-5));
// Act
Result<Success> result = scheduledJob.MarkExecutionCompleted(isCycleRun: true);
// Assert
Assert.True(result.IsFailure);
Assert.Equal(Errors.Scheduling.CanOnlyCompleteRunningScheduledJob, result.FirstError);
Assert.Empty(scheduledJob.GetDomainEvents());
}
[Fact]
public void MarkExecutionCompleted_WhenCycleRunAfterExecutionStarted_ShouldAllowTheNextCycleRunToStart()
{
// Arrange
ScheduledJob scheduledJob = _scheduledJobFixture.Create();
scheduledJob.StartCycle();
scheduledJob.MarkExecutionStarted(isCycleRun: true);
scheduledJob.MarkExecutionCompleted(isCycleRun: true);
// Act
Result<Success> startNextExecutionResult = scheduledJob.MarkExecutionStarted(isCycleRun: true);
// Assert
Assert.False(startNextExecutionResult.IsFailure);
Assert.Equal(ScheduledJobStatus.Running, scheduledJob.Status);
}
}
@@ -0,0 +1,155 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.UnitTests.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
/// <summary>
/// Contains unit tests for the <see cref="DailySchedule"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class DailyScheduleTests
{
[Fact]
public void Create_WhenCalledWithValidHourAndMinute_ShouldCreateDailyScheduleWithAllPropertiesSet()
{
// Act
Result<DailySchedule> result = DailySchedule.Create(8, 30);
// Assert
Assert.False(result.IsFailure);
Assert.Equal(8, result.Value.Hour);
Assert.Equal(30, result.Value.Minute);
Assert.Equal(ScheduleType.DailyAtHourAndMinute, result.Value.ScheduleType);
}
[Theory]
[InlineData(-1)] // Hour below the allowed range.
[InlineData(24)] // Hour above the allowed range.
public void Create_WhenHourIsOutOfRange_ShouldReturnError(int hour)
{
// Act
Result<DailySchedule> result = DailySchedule.Create(hour, 0);
// Assert
Assert.True(result.IsFailure);
Assert.Equal(Errors.Scheduling.HourMustBeBetweenZeroAndTwentyThree, result.FirstError);
}
[Theory]
[InlineData(-1)] // Minute below the allowed range.
[InlineData(60)] // Minute above the allowed range.
public void Create_WhenMinuteIsOutOfRange_ShouldReturnError(int minute)
{
// Act
Result<DailySchedule> result = DailySchedule.Create(8, minute);
// Assert
Assert.True(result.IsFailure);
Assert.Equal(Errors.Scheduling.MinuteMustBeBetweenZeroAndFiftyNine, result.FirstError);
}
[Fact]
public void Create_WhenCalledWithLowerBoundaryValues_ShouldCreateDailySchedule()
{
// Act
Result<DailySchedule> result = DailySchedule.Create(0, 0);
// Assert
Assert.False(result.IsFailure);
Assert.Equal(0, result.Value.Hour);
Assert.Equal(0, result.Value.Minute);
}
[Fact]
public void Create_WhenCalledWithUpperBoundaryValues_ShouldCreateDailySchedule()
{
// Act
Result<DailySchedule> result = DailySchedule.Create(23, 59);
// Assert
Assert.False(result.IsFailure);
Assert.Equal(23, result.Value.Hour);
Assert.Equal(59, result.Value.Minute);
}
[Fact]
public void GetDelayUntilNextExecution_WhenNextRunIsLaterToday_ShouldReturnDelayUntilNextRun()
{
// Arrange
DailySchedule schedule = DailySchedule.Create(12, 30).Value;
DateTime utcNow = new(2026, 1, 1, 10, 0, 0, DateTimeKind.Utc);
// Act
TimeSpan delay = schedule.GetDelayUntilNextExecution(utcNow, TimeZoneInfo.Utc);
// Assert
Assert.Equal(TimeSpan.FromHours(2.5), delay);
}
[Fact]
public void GetDelayUntilNextExecution_WhenNextRunAlreadyPassedToday_ShouldReturnDelayUntilTomorrow()
{
// Arrange
DailySchedule schedule = DailySchedule.Create(8, 0).Value;
DateTime utcNow = new(2026, 1, 1, 10, 0, 0, DateTimeKind.Utc);
// Act
TimeSpan delay = schedule.GetDelayUntilNextExecution(utcNow, TimeZoneInfo.Utc);
// Assert
Assert.Equal(TimeSpan.FromHours(22), delay);
}
[Fact]
public void GetDelayUntilNextExecution_WhenNextRunEqualsNow_ShouldReturnDelayUntilTomorrow()
{
// Arrange
DailySchedule schedule = DailySchedule.Create(10, 0).Value;
DateTime utcNow = new(2026, 1, 1, 10, 0, 0, DateTimeKind.Utc);
// Act
TimeSpan delay = schedule.GetDelayUntilNextExecution(utcNow, TimeZoneInfo.Utc);
// Assert
Assert.Equal(TimeSpan.FromDays(1), delay);
}
[Fact]
public void Equals_WhenHourAndMinuteAreEqual_ShouldReturnTrue()
{
// Act
bool areEqual = DailySchedule.Create(8, 30).Value.Equals(DailySchedule.Create(8, 30).Value);
// Assert
Assert.True(areEqual);
}
[Theory]
[InlineData(9, 30)] // Different hour.
[InlineData(8, 31)] // Different minute.
public void Equals_WhenHourOrMinuteDiffer_ShouldReturnFalse(int hour, int minute)
{
// Act
bool areEqual = DailySchedule.Create(8, 30).Value.Equals(DailySchedule.Create(hour, minute).Value);
// Assert
Assert.False(areEqual);
}
[Fact]
public void GetHashCode_WhenHourAndMinuteAreEqual_ShouldReturnEqualHashCodes()
{
// Act
int firstHashCode = DailySchedule.Create(8, 30).Value.GetHashCode();
int secondHashCode = DailySchedule.Create(8, 30).Value.GetHashCode();
// Assert
Assert.Equal(firstHashCode, secondHashCode);
}
}
@@ -0,0 +1,88 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.UnitTests.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
/// <summary>
/// Contains unit tests for the <see cref="IntervalSchedule"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class IntervalScheduleTests
{
[Fact]
public void Create_WhenCalledWithValidInterval_ShouldCreateIntervalScheduleWithAllPropertiesSet()
{
// Act
Result<IntervalSchedule> result = IntervalSchedule.Create(60);
// Assert
Assert.False(result.IsFailure);
Assert.Equal(60, result.Value.IntervalMinutes);
Assert.Equal(ScheduleType.WithIntervalInMinutes, result.Value.ScheduleType);
}
[Theory]
[InlineData(0)] // Interval of zero.
[InlineData(-1)] // Negative interval.
[InlineData(-100)] // Negative interval far from zero.
public void Create_WhenIntervalIsNotPositive_ShouldReturnError(int intervalMinutes)
{
// Act
Result<IntervalSchedule> result = IntervalSchedule.Create(intervalMinutes);
// Assert
Assert.True(result.IsFailure);
Assert.Equal(Errors.Scheduling.IntervalMinutesMustBePositive, result.FirstError);
}
[Fact]
public void Create_WhenCalledWithOneMinuteInterval_ShouldCreateIntervalSchedule()
{
// Act
Result<IntervalSchedule> result = IntervalSchedule.Create(1);
// Assert
Assert.False(result.IsFailure);
Assert.Equal(1, result.Value.IntervalMinutes);
}
[Fact]
public void GetDelayUntilNextExecution_WhenCalled_ShouldReturnTheIntervalInMinutes()
{
// Arrange
IntervalSchedule schedule = IntervalSchedule.Create(45).Value;
DateTime utcNow = new(2026, 1, 1, 10, 0, 0, DateTimeKind.Utc);
// Act
TimeSpan delay = schedule.GetDelayUntilNextExecution(utcNow, TimeZoneInfo.Utc);
// Assert
Assert.Equal(TimeSpan.FromMinutes(45), delay);
}
[Fact]
public void Equals_WhenIntervalsAreEqual_ShouldReturnTrue()
{
// Act
bool areEqual = IntervalSchedule.Create(60).Value.Equals(IntervalSchedule.Create(60).Value);
// Assert
Assert.True(areEqual);
}
[Fact]
public void Equals_WhenIntervalsDiffer_ShouldReturnFalse()
{
// Act
bool areEqual = IntervalSchedule.Create(60).Value.Equals(IntervalSchedule.Create(120).Value);
// Assert
Assert.False(areEqual);
}
}
@@ -0,0 +1,52 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.UnitTests.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
/// <summary>
/// Contains unit tests for the <see cref="OnceAtStartupSchedule"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class OnceAtStartupScheduleTests
{
private readonly OnceAtStartupScheduleFixture _onceAtStartupScheduleFixture = new();
[Fact]
public void Create_WhenCalled_ShouldCreateOnceAtStartupSchedule()
{
// Act
OnceAtStartupSchedule schedule = _onceAtStartupScheduleFixture.Create();
// Assert
Assert.Equal(ScheduleType.OnceAtStartup, schedule.ScheduleType);
}
[Fact]
public void GetDelayUntilNextExecution_WhenCalled_ShouldReturnTheMaximumDelay()
{
// Arrange
OnceAtStartupSchedule schedule = _onceAtStartupScheduleFixture.Create();
DateTime utcNow = new(2026, 1, 1, 10, 0, 0, DateTimeKind.Utc);
// Act
TimeSpan delay = schedule.GetDelayUntilNextExecution(utcNow, TimeZoneInfo.Utc);
// Assert
Assert.Equal(TimeSpan.MaxValue, delay);
}
[Fact]
public void Equals_WhenBothAreOnceAtStartupSchedules_ShouldReturnTrue()
{
// Act
bool areEqual = _onceAtStartupScheduleFixture.Create().Equals(_onceAtStartupScheduleFixture.Create());
// Assert
Assert.True(areEqual);
}
}
@@ -0,0 +1,70 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.UnitTests.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
/// <summary>
/// Contains unit tests for the <see cref="ScheduledJobId"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class ScheduledJobIdTests
{
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
[Fact]
public void CreateUnique_WhenCalled_ShouldReturnIdWithNonEmptyValue()
{
// Act
ScheduledJobId scheduledJobId = ScheduledJobId.CreateUnique();
// Assert
Assert.NotNull(scheduledJobId);
Assert.NotEqual(default, scheduledJobId.Value);
}
[Fact]
public void Create_WhenCalledWithValue_ShouldReturnIdWithThatValue()
{
// Arrange
Guid value = Guid.NewGuid();
// Act
ScheduledJobId scheduledJobId = ScheduledJobId.Create(value);
// Assert
Assert.Equal(value, scheduledJobId.Value);
}
[Fact]
public void Equals_WithSameValue_ShouldReturnTrue()
{
// Arrange
Guid value = Guid.NewGuid();
ScheduledJobId firstId = _scheduledJobIdFixture.Create(value);
ScheduledJobId secondId = _scheduledJobIdFixture.Create(value);
// Act
bool result = firstId.Equals(secondId);
// Assert
Assert.True(result);
}
[Fact]
public void Equals_WithDifferentValue_ShouldReturnFalse()
{
// Arrange
ScheduledJobId firstId = _scheduledJobIdFixture.Create();
ScheduledJobId secondId = _scheduledJobIdFixture.Create();
// Act
bool result = firstId.Equals(secondId);
// Assert
Assert.False(result);
}
}