mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 10:11:10 +00:00
Hardens test assertions and adds missing test coverage.
This commit is contained in:
1 parent
6b86fd5805
commit
1189bbaf36
489 files changed
+39982
-512
No files matched your search
+56
@@ -0,0 +1,56 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Exceptions;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.UnitTests.Common.Exceptions;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="EventualConsistencyException"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class EventualConsistencyExceptionTests
|
||||
{
|
||||
[Fact]
|
||||
public void Constructor_WhenCalledWithError_ShouldSetErrorAndMessage()
|
||||
{
|
||||
// Arrange
|
||||
Error error = Error.Validation("Code", "The operation could not be completed.");
|
||||
|
||||
// Act
|
||||
EventualConsistencyException exception = new(error);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(error, exception.EventualConsistencyError);
|
||||
Assert.Equal(error.Description, exception.Message);
|
||||
Assert.Empty(exception.UnderlyingErrors);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenCalledWithUnderlyingErrors_ShouldSetUnderlyingErrors()
|
||||
{
|
||||
// Arrange
|
||||
Error primaryError = Error.Validation("Primary", "Primary error.");
|
||||
List<Error> underlyingErrors = [Error.NotFound("Underlying1", "Underlying error 1."), Error.Conflict("Underlying2", "Underlying error 2.")];
|
||||
|
||||
// Act
|
||||
EventualConsistencyException exception = new(primaryError, underlyingErrors);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(primaryError, exception.EventualConsistencyError);
|
||||
Assert.Equal(underlyingErrors, exception.UnderlyingErrors);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenUnderlyingErrorsAreNull_ShouldUseEmptyList()
|
||||
{
|
||||
// Act
|
||||
EventualConsistencyException exception = new(Error.Failure("Code", "Description"), null);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(exception.UnderlyingErrors);
|
||||
Assert.Empty(exception.UnderlyingErrors);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user