mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 11: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
+62
@@ -0,0 +1,62 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Directories;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Directories;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.Requests.FileSystemManagement.Directories;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="GetDirectoriesRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetDirectoriesRequestTests
|
||||
{
|
||||
private readonly GetDirectoriesRequestFixture _getDirectoriesRequestFixture = new();
|
||||
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalled_ShouldReturnValidGetDirectoriesRequest()
|
||||
{
|
||||
// Act
|
||||
GetDirectoriesRequest sut = _getDirectoriesRequestFixture.Create();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(sut);
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.Path));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingGetDirectoriesRequest_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
GetDirectoriesRequest expected = _getDirectoriesRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
GetDirectoriesRequest? actual = JsonSerializer.Deserialize<GetDirectoriesRequest>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Deconstruct_WhenCalled_ShouldReturnAllProperties()
|
||||
{
|
||||
// Arrange
|
||||
GetDirectoriesRequest sut = _getDirectoriesRequestFixture.Create(path: @"C:\Media", includeHiddenElements: true);
|
||||
|
||||
// Act
|
||||
(string? path, bool includeHiddenElements) = sut;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(sut.Path, path);
|
||||
Assert.Equal(sut.IncludeHiddenElements, includeHiddenElements);
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Files;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Files;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.Requests.FileSystemManagement.Files;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="GetFilesRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetFilesRequestTests
|
||||
{
|
||||
private readonly GetFilesRequestFixture _getFilesRequestFixture = new();
|
||||
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalled_ShouldReturnValidGetFilesRequest()
|
||||
{
|
||||
// Act
|
||||
GetFilesRequest sut = _getFilesRequestFixture.Create();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(sut);
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.Path));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingGetFilesRequest_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
GetFilesRequest expected = _getFilesRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
GetFilesRequest? actual = JsonSerializer.Deserialize<GetFilesRequest>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Deconstruct_WhenCalled_ShouldReturnAllProperties()
|
||||
{
|
||||
// Arrange
|
||||
GetFilesRequest sut = _getFilesRequestFixture.Create(path: @"C:\Media", includeHiddenElements: true);
|
||||
|
||||
// Act
|
||||
(string? path, bool includeHiddenElements) = sut;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(sut.Path, path);
|
||||
Assert.Equal(sut.IncludeHiddenElements, includeHiddenElements);
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Files;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Files;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.Requests.FileSystemManagement.Files;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="GetTreeFilesRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetTreeFilesRequestTests
|
||||
{
|
||||
private readonly GetTreeFilesRequestFixture _getTreeFilesRequestFixture = new();
|
||||
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalled_ShouldReturnValidGetTreeFilesRequest()
|
||||
{
|
||||
// Act
|
||||
GetTreeFilesRequest sut = _getTreeFilesRequestFixture.Create();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(sut);
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.Path));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingGetTreeFilesRequest_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
GetTreeFilesRequest expected = _getTreeFilesRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
GetTreeFilesRequest? actual = JsonSerializer.Deserialize<GetTreeFilesRequest>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Deconstruct_WhenCalled_ShouldReturnAllProperties()
|
||||
{
|
||||
// Arrange
|
||||
GetTreeFilesRequest sut = _getTreeFilesRequestFixture.Create(path: @"C:\Media", includeHiddenElements: false);
|
||||
|
||||
// Act
|
||||
(string? path, bool includeHiddenElements) = sut;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(sut.Path, path);
|
||||
Assert.Equal(sut.IncludeHiddenElements, includeHiddenElements);
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Path;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Path;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.Requests.FileSystemManagement.Path;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="CheckPathExistsRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class CheckPathExistsRequestTests
|
||||
{
|
||||
private readonly CheckPathExistsRequestFixture _checkPathExistsRequestFixture = new();
|
||||
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalled_ShouldReturnValidCheckPathExistsRequest()
|
||||
{
|
||||
// Act
|
||||
CheckPathExistsRequest sut = _checkPathExistsRequestFixture.Create();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(sut);
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.Path));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingCheckPathExistsRequest_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
CheckPathExistsRequest expected = _checkPathExistsRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
CheckPathExistsRequest? actual = JsonSerializer.Deserialize<CheckPathExistsRequest>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Deconstruct_WhenCalled_ShouldReturnAllProperties()
|
||||
{
|
||||
// Arrange
|
||||
CheckPathExistsRequest sut = _checkPathExistsRequestFixture.Create(path: @"C:\Media\Books", includeHiddenElements: true);
|
||||
|
||||
// Act
|
||||
(string? path, bool includeHiddenElements) = sut;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(sut.Path, path);
|
||||
Assert.Equal(sut.IncludeHiddenElements, includeHiddenElements);
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Path;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Path;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.Requests.FileSystemManagement.Path;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="CombinePathRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class CombinePathRequestTests
|
||||
{
|
||||
private readonly CombinePathRequestFixture _combinePathRequestFixture = new();
|
||||
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalled_ShouldReturnValidCombinePathRequest()
|
||||
{
|
||||
// Act
|
||||
CombinePathRequest sut = _combinePathRequestFixture.Create();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(sut);
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.OriginalPath));
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.NewPath));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingCombinePathRequest_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
CombinePathRequest expected = _combinePathRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
CombinePathRequest? actual = JsonSerializer.Deserialize<CombinePathRequest>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Deconstruct_WhenCalled_ShouldReturnAllProperties()
|
||||
{
|
||||
// Arrange
|
||||
CombinePathRequest sut = _combinePathRequestFixture.Create(originalPath: @"C:\Media", newPath: "books");
|
||||
|
||||
// Act
|
||||
(string? originalPath, string? newPath) = sut;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(sut.OriginalPath, originalPath);
|
||||
Assert.Equal(sut.NewPath, newPath);
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Path;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Path;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.Requests.FileSystemManagement.Path;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="GetPathParentRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetPathParentRequestTests
|
||||
{
|
||||
private readonly GetPathParentRequestFixture _getPathParentRequestFixture = new();
|
||||
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalled_ShouldReturnValidGetPathParentRequest()
|
||||
{
|
||||
// Act
|
||||
GetPathParentRequest sut = _getPathParentRequestFixture.Create();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(sut);
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.Path));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingGetPathParentRequest_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
GetPathParentRequest expected = _getPathParentRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
GetPathParentRequest? actual = JsonSerializer.Deserialize<GetPathParentRequest>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equality_WhenTwoInstancesHaveSameValues_ShouldBeEqual()
|
||||
{
|
||||
// Arrange
|
||||
GetPathParentRequest first = _getPathParentRequestFixture.Create(path: @"C:\Media\Books");
|
||||
GetPathParentRequest second = _getPathParentRequestFixture.Create(path: @"C:\Media\Books");
|
||||
|
||||
// Act
|
||||
bool areEqual = first == second;
|
||||
|
||||
// Assert
|
||||
Assert.True(areEqual);
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Path;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Path;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.Requests.FileSystemManagement.Path;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="GetPathRootRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetPathRootRequestTests
|
||||
{
|
||||
private readonly GetPathRootRequestFixture _getPathRootRequestFixture = new();
|
||||
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalled_ShouldReturnValidGetPathRootRequest()
|
||||
{
|
||||
// Act
|
||||
GetPathRootRequest sut = _getPathRootRequestFixture.Create();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(sut);
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.Path));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingGetPathRootRequest_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
GetPathRootRequest expected = _getPathRootRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
GetPathRootRequest? actual = JsonSerializer.Deserialize<GetPathRootRequest>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equality_WhenTwoInstancesHaveSameValues_ShouldBeEqual()
|
||||
{
|
||||
// Arrange
|
||||
GetPathRootRequest first = _getPathRootRequestFixture.Create(path: @"C:\Media\Books");
|
||||
GetPathRootRequest second = _getPathRootRequestFixture.Create(path: @"C:\Media\Books");
|
||||
|
||||
// Act
|
||||
bool areEqual = first == second;
|
||||
|
||||
// Assert
|
||||
Assert.True(areEqual);
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Path;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Path;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.Requests.FileSystemManagement.Path;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="SplitPathRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class SplitPathRequestTests
|
||||
{
|
||||
private readonly SplitPathRequestFixture _splitPathRequestFixture = new();
|
||||
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalled_ShouldReturnValidSplitPathRequest()
|
||||
{
|
||||
// Act
|
||||
SplitPathRequest sut = _splitPathRequestFixture.Create();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(sut);
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.Path));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingSplitPathRequest_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
SplitPathRequest expected = _splitPathRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
SplitPathRequest? actual = JsonSerializer.Deserialize<SplitPathRequest>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equality_WhenTwoInstancesHaveSameValues_ShouldBeEqual()
|
||||
{
|
||||
// Arrange
|
||||
SplitPathRequest first = _splitPathRequestFixture.Create(path: @"C:\Media\Books");
|
||||
SplitPathRequest second = _splitPathRequestFixture.Create(path: @"C:\Media\Books");
|
||||
|
||||
// Act
|
||||
bool areEqual = first == second;
|
||||
|
||||
// Assert
|
||||
Assert.True(areEqual);
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Path;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Path;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.Requests.FileSystemManagement.Path;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="ValidatePathRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ValidatePathRequestTests
|
||||
{
|
||||
private readonly ValidatePathRequestFixture _validatePathRequestFixture = new();
|
||||
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalled_ShouldReturnValidValidatePathRequest()
|
||||
{
|
||||
// Act
|
||||
ValidatePathRequest sut = _validatePathRequestFixture.Create();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(sut);
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.Path));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingValidatePathRequest_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
ValidatePathRequest expected = _validatePathRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
ValidatePathRequest? actual = JsonSerializer.Deserialize<ValidatePathRequest>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equality_WhenTwoInstancesHaveSameValues_ShouldBeEqual()
|
||||
{
|
||||
// Arrange
|
||||
ValidatePathRequest first = _validatePathRequestFixture.Create(path: @"C:\Media\Books");
|
||||
ValidatePathRequest second = _validatePathRequestFixture.Create(path: @"C:\Media\Books");
|
||||
|
||||
// Act
|
||||
bool areEqual = first == second;
|
||||
|
||||
// Assert
|
||||
Assert.True(areEqual);
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Thumbnails;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Thumbnails;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.Requests.FileSystemManagement.Thumbnails;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="GetThumbnailRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetThumbnailRequestTests
|
||||
{
|
||||
private readonly GetThumbnailRequestFixture _getThumbnailRequestFixture = new();
|
||||
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalled_ShouldReturnValidGetThumbnailRequest()
|
||||
{
|
||||
// Act
|
||||
GetThumbnailRequest sut = _getThumbnailRequestFixture.Create();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(sut);
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.Path));
|
||||
Assert.InRange(sut.Quality, 1, 100);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingGetThumbnailRequest_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
GetThumbnailRequest expected = _getThumbnailRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
GetThumbnailRequest? actual = JsonSerializer.Deserialize<GetThumbnailRequest>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Deconstruct_WhenCalled_ShouldReturnAllProperties()
|
||||
{
|
||||
// Arrange
|
||||
GetThumbnailRequest sut = _getThumbnailRequestFixture.Create(path: @"C:\Media\cover.jpg", quality: 80);
|
||||
|
||||
// Act
|
||||
(string? path, int quality) = sut;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(sut.Path, path);
|
||||
Assert.Equal(sut.Quality, quality);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user