mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 05:11:10 +00:00
Centralizes and standardizes test fixtures.
This commit is contained in:
1 parent
dfc513da4f
commit
b648e2f054
294 files changed
+3807
-4437
No files matched your search
+7
-6
@@ -1,8 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
|
||||
using Lumina.Domain.UnitTests.Core.Aggregates.BookLibraryAggregate.Fixtures;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
@@ -15,11 +14,13 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.BookLibraryAggregate;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookTests
|
||||
{
|
||||
private readonly BookFixture _bookFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalledWithValidData_ShouldCreateBookWithPendingMetadataStatus()
|
||||
{
|
||||
// Act
|
||||
Book book = BookFixture.CreateValidBook();
|
||||
Book book = _bookFixture.Create();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(book);
|
||||
@@ -32,7 +33,7 @@ public class BookTests
|
||||
public void MarkMetadataAsEnriched_WhenCalled_ShouldUpdateStatusAndProvider()
|
||||
{
|
||||
// Arrange
|
||||
Book book = BookFixture.CreateValidBook();
|
||||
Book book = _bookFixture.Create();
|
||||
DateTime lastUpdateUtc = DateTime.UtcNow;
|
||||
|
||||
// Act
|
||||
@@ -48,7 +49,7 @@ public class BookTests
|
||||
public void MarkMetadataAsFailed_WhenCalled_ShouldUpdateStatus()
|
||||
{
|
||||
// Arrange
|
||||
Book book = BookFixture.CreateValidBook();
|
||||
Book book = _bookFixture.Create();
|
||||
|
||||
// Act
|
||||
book.MarkMetadataAsFailed();
|
||||
|
||||
-70
@@ -1,70 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.UnitTests.Core.Aggregates.BookLibraryAggregate.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="Book"/> domain entity.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public static class BookFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a valid book domain entity with random data.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="Book"/> domain entity.</returns>
|
||||
public static Book CreateValidBook()
|
||||
{
|
||||
Result<Book> bookResult = Book.Create(
|
||||
LibraryId.Create(Guid.NewGuid()),
|
||||
"/books/test.epub",
|
||||
WrittenContentMetadata.Create(
|
||||
"Test Title",
|
||||
Optional<string>.None(),
|
||||
Optional<string>.None(),
|
||||
ReleaseInfo.Create(
|
||||
Optional<DateOnly>.None(),
|
||||
Optional<int>.None(),
|
||||
Optional<DateOnly>.None(),
|
||||
Optional<int>.None(),
|
||||
Optional<string>.None(),
|
||||
Optional<string>.None()
|
||||
).Value,
|
||||
[],
|
||||
[],
|
||||
Optional<LanguageInfo>.None(),
|
||||
Optional<LanguageInfo>.None(),
|
||||
Optional<string>.None(),
|
||||
Optional<int>.None()
|
||||
).Value,
|
||||
Optional<BookFormat>.None(),
|
||||
Optional<string>.None(),
|
||||
Optional<int>.None(),
|
||||
Optional<BookSeries>.None(),
|
||||
Optional<string>.None(),
|
||||
Optional<string>.None(),
|
||||
Optional<string>.None(),
|
||||
Optional<string>.None(),
|
||||
Optional<string>.None(),
|
||||
Optional<string>.None(),
|
||||
Optional<string>.None(),
|
||||
Optional<string>.None(),
|
||||
Optional<string>.None(),
|
||||
[],
|
||||
[],
|
||||
[]
|
||||
);
|
||||
if (bookResult.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create a valid book in the test fixture.");
|
||||
return bookResult.Value;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -4,8 +4,8 @@ using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.Fixtures;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
-109
@@ -1,109 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.Entities.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="Directory"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DirectoryFixture
|
||||
{
|
||||
private readonly Faker _faker;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DirectoryFixture"/> class.
|
||||
/// </summary>
|
||||
public DirectoryFixture()
|
||||
{
|
||||
_faker = new Faker();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="Directory"/>.
|
||||
/// </summary>
|
||||
/// <param name="path">Optional. The directory path. If not provided, a random path is generated.</param>
|
||||
/// <param name="name">Optional. The directory name. If not provided, a random name is generated.</param>
|
||||
/// <param name="dateCreated">Optional. The directory's creation date. If not provided, a random past date is generated.</param>
|
||||
/// <param name="dateModified">Optional. The directory's modification date. If not provided, a recent date is generated.</param>
|
||||
/// <param name="status">Optional. The directory's status. If not provided, a random status is assigned.</param>
|
||||
/// <param name="childItems">Optional. A list of child items to be added to the directory.</param>
|
||||
/// <returns>A newly created <see cref="Directory"/> instance.</returns>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the <see cref="Directory"/> creation fails.</exception>
|
||||
public Directory CreateDirectory(
|
||||
string? path = null,
|
||||
string? name = null,
|
||||
Optional<DateTime>? dateCreated = null,
|
||||
Optional<DateTime>? dateModified = null,
|
||||
FileSystemItemStatus? status = null,
|
||||
List<FileSystemItem>? childItems = null)
|
||||
{
|
||||
path ??= _faker.System.FilePath();
|
||||
name ??= _faker.System.FileName();
|
||||
dateCreated ??= Optional<DateTime>.Some(_faker.Date.Past());
|
||||
dateModified ??= Optional<DateTime>.Some(_faker.Date.Recent());
|
||||
status ??= _faker.PickRandom<FileSystemItemStatus>();
|
||||
|
||||
Result<Directory> directoryResult = Directory.Create(path, name, dateCreated.Value, dateModified.Value, status.Value);
|
||||
|
||||
if (directoryResult.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create Directory: " + string.Join(", ", directoryResult.Errors));
|
||||
Directory directory = directoryResult.Value;
|
||||
|
||||
if (childItems != null)
|
||||
foreach (FileSystemItem item in childItems)
|
||||
directory.AddItem(item);
|
||||
return directory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="Directory"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<Directory> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => CreateDirectory())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of nested <see cref="Directory"/> objects with a hierarchical structure.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of top-level directories to create. Default is 3.</param>
|
||||
/// <param name="maxDepth">The maximum depth of the directory hierarchy. Default is 3.</param>
|
||||
/// <param name="maxChildrenPerDirectory">The maximum number of child items (files or directories) per directory. Default is 3.</param>
|
||||
/// <returns>A list of <see cref="Directory"/> objects with nested structures.</returns>
|
||||
public List<Directory> CreateManyNested(int count = 3, int maxDepth = 3, int maxChildrenPerDirectory = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => CreateNestedDirectory(1, maxDepth, maxChildrenPerDirectory))];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recursively creates a nested <see cref="Directory"/> structure.
|
||||
/// </summary>
|
||||
/// <param name="currentDepth">The current depth in the directory hierarchy.</param>
|
||||
/// <param name="maxDepth">The maximum allowed depth for the directory hierarchy.</param>
|
||||
/// <param name="maxChildrenPerDirectory">The maximum number of child items (files or directories) allowed per directory.</param>
|
||||
/// <returns>A <see cref="Directory"/> object that may contain nested directories and files.</returns>
|
||||
private Directory CreateNestedDirectory(int currentDepth, int maxDepth, int maxChildrenPerDirectory)
|
||||
{
|
||||
List<FileSystemItem> childItems = [];
|
||||
|
||||
if (currentDepth < maxDepth)
|
||||
{
|
||||
int childCount = _faker.Random.Int(0, maxChildrenPerDirectory);
|
||||
for (int i = 0; i < childCount; i++)
|
||||
childItems.Add(CreateNestedDirectory(currentDepth + 1, maxDepth, maxChildrenPerDirectory));
|
||||
}
|
||||
return CreateDirectory(childItems: childItems);
|
||||
}
|
||||
}
|
||||
-81
@@ -1,81 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.Entities.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="File"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FileFixture
|
||||
{
|
||||
private readonly Faker _faker;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FileFixture"/> class.
|
||||
/// </summary>
|
||||
public FileFixture()
|
||||
{
|
||||
_faker = new Faker();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="File"/>.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="File"/>.</returns>
|
||||
public File CreateFile(
|
||||
string? path = null,
|
||||
string? name = null,
|
||||
Optional<DateTime>? dateCreated = null,
|
||||
Optional<DateTime>? dateModified = null,
|
||||
long? size = null,
|
||||
FileSystemItemStatus? status = null)
|
||||
{
|
||||
path ??= _faker.System.FilePath();
|
||||
name ??= _faker.System.FileName();
|
||||
dateCreated ??= Optional<DateTime>.Some(_faker.Date.Past());
|
||||
dateModified ??= Optional<DateTime>.Some(_faker.Date.Recent());
|
||||
size ??= _faker.Random.Long();
|
||||
status ??= _faker.PickRandom<FileSystemItemStatus>();
|
||||
|
||||
Result<File> fileResult = File.Create(path, name, dateCreated.Value, dateModified.Value, size.Value, status.Value);
|
||||
|
||||
if (fileResult.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create File: " + string.Join(", ", fileResult.Errors));
|
||||
return fileResult.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="File"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<File> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => CreateFile())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="File"/>, without creationg and modification dates.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static File CreateFileWithoutDates()
|
||||
{
|
||||
return File.Create(
|
||||
"/path/to/file_without_dates.txt",
|
||||
"file_without_dates.txt",
|
||||
Optional<DateTime>.None(),
|
||||
Optional<DateTime>.None(),
|
||||
2048,
|
||||
FileSystemItemStatus.Accessible
|
||||
).Value;
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -5,9 +5,9 @@ using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.Fixtures;
|
||||
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.ValueObjects.Fixtures;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
@@ -35,7 +35,7 @@ public class FileSystemItemTests
|
||||
public void Constructor_WhenCalled_ShouldSetPropertiesCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId id = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId id = _fileSystemPathIdFixture.Create();
|
||||
string name = "TestItem";
|
||||
FileSystemItemType type = FileSystemItemType.File;
|
||||
|
||||
@@ -101,7 +101,7 @@ public class FileSystemItemTests
|
||||
public void Equals_WithSameId_ShouldReturnTrue()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId id = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId id = _fileSystemPathIdFixture.Create();
|
||||
FileSystemItemFixture item1 = CreateFileSystemItemFixture(id);
|
||||
FileSystemItemFixture item2 = CreateFileSystemItemFixture(id);
|
||||
|
||||
@@ -130,7 +130,7 @@ public class FileSystemItemTests
|
||||
public void GetHashCode_WithSameId_ShouldReturnSameHashCode()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId id = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId id = _fileSystemPathIdFixture.Create();
|
||||
FileSystemItemFixture item1 = CreateFileSystemItemFixture(id);
|
||||
FileSystemItemFixture item2 = CreateFileSystemItemFixture(id);
|
||||
|
||||
@@ -159,7 +159,7 @@ public class FileSystemItemTests
|
||||
|
||||
private FileSystemItemFixture CreateFileSystemItemFixture(FileSystemPathId? id = null)
|
||||
{
|
||||
id ??= _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
id ??= _fileSystemPathIdFixture.Create();
|
||||
string name = _fixture.Create<string>();
|
||||
FileSystemItemType type = _fixture.Create<FileSystemItemType>();
|
||||
return new FileSystemItemFixture(id, name, type);
|
||||
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FileSystemItem"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FileSystemItemFixture : FileSystemItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FileSystemItemFixture"/> class.
|
||||
/// </summary>
|
||||
/// <param name="id">The unique identifier for the file system path.</param>
|
||||
/// <param name="name">The name of the file system item.</param>
|
||||
/// <param name="fileSystemItemType">The type of the file system item.</param>
|
||||
public FileSystemItemFixture(FileSystemPathId id, string name, FileSystemItemType fileSystemItemType)
|
||||
: base(id, name, fileSystemItemType)
|
||||
{
|
||||
}
|
||||
}
|
||||
+51
-51
@@ -5,9 +5,9 @@ using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Primitives;
|
||||
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.ValueObjects.Fixtures;
|
||||
using NSubstitute;
|
||||
using NSubstitute.ExceptionExtensions;
|
||||
using System;
|
||||
@@ -72,7 +72,7 @@ public class DirectoryProviderServiceTests
|
||||
public void GetSubdirectoryPaths_WhenUserHasNoAccess_ShouldReturnUnauthorizedAccessError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ListDirectory, false).Returns(false);
|
||||
|
||||
// Act
|
||||
@@ -87,7 +87,7 @@ public class DirectoryProviderServiceTests
|
||||
public void GetSubdirectoryPaths_WhenUserHasAccess_ShouldReturnSubdirectories()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
string[] subdirectories = [.. _fixture.CreateMany<string>(3)];
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ListDirectory, false).Returns(true);
|
||||
_mockFileSystem.Directory.GetDirectories(path.Path).Returns(subdirectories);
|
||||
@@ -109,7 +109,7 @@ public class DirectoryProviderServiceTests
|
||||
public void GetSubdirectoryPaths_WhenIncludeHiddenElementsIsFalse_ShouldExcludeHiddenDirectories()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
string[] subdirectories = [_pathVisible1, _pathHidden1];
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ListDirectory, false).Returns(true);
|
||||
_mockFileSystem.Directory.GetDirectories(path.Path).Returns(subdirectories);
|
||||
@@ -130,7 +130,7 @@ public class DirectoryProviderServiceTests
|
||||
public void GetSubdirectoryPaths_WhenIncludeHiddenElementsIsTrue_ShouldIncludeHiddenDirectories()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
string[] subdirectories = [_pathVisible1, _pathHidden1];
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ListDirectory, false).Returns(true);
|
||||
_mockFileSystem.Directory.GetDirectories(path.Path).Returns(subdirectories);
|
||||
@@ -154,7 +154,7 @@ public class DirectoryProviderServiceTests
|
||||
public void GetSubdirectoryPaths_WhenGetAttributesThrowsException_ShouldStillAddDirectory()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
string[] subdirectories = [_pathValid1, _pathInvalid1];
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ListDirectory, false).Returns(true);
|
||||
_mockFileSystem.Directory.GetDirectories(path.Path).Returns(subdirectories);
|
||||
@@ -176,7 +176,7 @@ public class DirectoryProviderServiceTests
|
||||
public void GetSubdirectoryPaths_WhenCalled_ShouldOrderDirectoriesAlphabetically()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
string[] subdirectories = s_isUnix
|
||||
? ["/C", "/A", "/B"]
|
||||
: [@"C:\C", @"C:\A", @"C:\B"];
|
||||
@@ -200,7 +200,7 @@ public class DirectoryProviderServiceTests
|
||||
public void GetSubdirectoryPaths_WhenDirectoryHasNoSubdirectories_ShouldReturnEmptyList()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ListDirectory, false).Returns(true);
|
||||
_mockFileSystem.Directory.GetDirectories(path.Path).Returns([]);
|
||||
|
||||
@@ -216,7 +216,7 @@ public class DirectoryProviderServiceTests
|
||||
public void DirectoryExists_WhenDirectoryExists_ShouldReturnTrue()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
_mockFileSystem.Directory.Exists(path.Path).Returns(true);
|
||||
|
||||
// Act
|
||||
@@ -231,7 +231,7 @@ public class DirectoryProviderServiceTests
|
||||
public void DirectoryExists_WhenDirectoryDoesNotExist_ShouldReturnFalse()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
_mockFileSystem.Directory.Exists(path.Path).Returns(false);
|
||||
|
||||
// Act
|
||||
@@ -249,7 +249,7 @@ public class DirectoryProviderServiceTests
|
||||
string fullPath = s_isUnix
|
||||
? "/folder/subfolder/file.txt"
|
||||
: @"C:\folder\subfolder\file.txt";
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(fullPath);
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(fullPath);
|
||||
_mockFileSystem.Path.GetFileName(fullPath).Returns("file.txt");
|
||||
|
||||
// Act
|
||||
@@ -267,7 +267,7 @@ public class DirectoryProviderServiceTests
|
||||
string fullPath = s_isUnix
|
||||
? "/folder/subfolder/"
|
||||
: @"C:\folder\subfolder\";
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(fullPath);
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(fullPath);
|
||||
_mockFileSystem.Path.GetFileName(fullPath[..^1]).Returns("subfolder");
|
||||
_mockFileSystem.Path.DirectorySeparatorChar.Returns(_dirSeparator);
|
||||
|
||||
@@ -286,7 +286,7 @@ public class DirectoryProviderServiceTests
|
||||
string fullPath = s_isUnix
|
||||
? "/C/"
|
||||
: @"/";
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(fullPath);
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(fullPath);
|
||||
_mockFileSystem.Path.GetFileName(fullPath[..^1]).Returns(string.Empty);
|
||||
_mockFileSystem.Path.DirectorySeparatorChar.Returns(_dirSeparator);
|
||||
|
||||
@@ -302,7 +302,7 @@ public class DirectoryProviderServiceTests
|
||||
public void GetLastWriteTime_WhenUserHasAccess_ShouldReturnLastWriteTime()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
DateTime expectedDateTime = DateTime.Now;
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties, false).Returns(true);
|
||||
_mockFileSystem.Directory.GetLastWriteTime(path.Path).Returns(expectedDateTime);
|
||||
@@ -320,7 +320,7 @@ public class DirectoryProviderServiceTests
|
||||
public void GetLastWriteTime_WhenUserHasNoAccess_ShouldReturnUnauthorizedAccessError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties, false).Returns(false);
|
||||
|
||||
// Act
|
||||
@@ -335,7 +335,7 @@ public class DirectoryProviderServiceTests
|
||||
public void GetCreationTime_WhenUserHasAccess_ShouldReturnCreationTime()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
DateTime expectedDateTime = DateTime.Now;
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties, false).Returns(true);
|
||||
_mockFileSystem.Directory.GetCreationTime(path.Path).Returns(expectedDateTime);
|
||||
@@ -353,7 +353,7 @@ public class DirectoryProviderServiceTests
|
||||
public void GetCreationTime_WhenUserHasNoAccess_ShouldReturnUnauthorizedAccessError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties, false).Returns(false);
|
||||
|
||||
// Act
|
||||
@@ -368,7 +368,7 @@ public class DirectoryProviderServiceTests
|
||||
public void CreateDirectory_WhenUserHasAccess_ShouldCreateDirectoryAndReturnPath()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId parentPath = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\Parent");
|
||||
FileSystemPathId parentPath = _fileSystemPathIdFixture.Create(@"C:\Parent");
|
||||
string directoryName = "NewDirectory";
|
||||
string fullPath = s_isUnix
|
||||
? "/Parent/NewDirectory"
|
||||
@@ -394,7 +394,7 @@ public class DirectoryProviderServiceTests
|
||||
public void CreateDirectory_WhenUserHasNoAccess_ShouldReturnUnauthorizedAccessError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId parentPath = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId parentPath = _fileSystemPathIdFixture.Create();
|
||||
string directoryName = "NewDirectory";
|
||||
|
||||
_mockFileSystemPermissionsService.CanAccessPath(parentPath, FileAccessMode.Write, false).Returns(false);
|
||||
@@ -427,7 +427,7 @@ public class DirectoryProviderServiceTests
|
||||
public void CreateDirectory_WhenCreatedDirectoryPathIsInvalid_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId parentPath = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\Parent");
|
||||
FileSystemPathId parentPath = _fileSystemPathIdFixture.Create(@"C:\Parent");
|
||||
string directoryName = "NewDirectory";
|
||||
string invalidPath = "Invalid:Path";
|
||||
|
||||
@@ -447,8 +447,8 @@ public class DirectoryProviderServiceTests
|
||||
public void CopyDirectory_WhenSourceDirectoryExistsAndUserHasAccess_ShouldCopyDirectoryAndReturnPath()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSource);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination);
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.Create(_pathSource);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.Create(_pathDestination);
|
||||
bool overrideExisting = false;
|
||||
|
||||
_mockFileSystem.Directory.Exists(sourcePath.Path).Returns(true);
|
||||
@@ -476,8 +476,8 @@ public class DirectoryProviderServiceTests
|
||||
public void CopyDirectory_WhenSourceDirectoryDoesNotExist_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.Create();
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.Create();
|
||||
bool overrideExisting = false;
|
||||
|
||||
_mockFileSystem.Directory.Exists(sourcePath.Path).Returns(false);
|
||||
@@ -494,8 +494,8 @@ public class DirectoryProviderServiceTests
|
||||
public void CopyDirectory_WhenDestinationDirectoryExists_ShouldCreateUniqueDirectoryName()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSource);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination);
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.Create(_pathSource);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.Create(_pathDestination);
|
||||
string expectedNewDirectoryPath = s_isUnix
|
||||
? "/Destination - Copy (1)"
|
||||
: @"C:\Destination - Copy (1)";
|
||||
@@ -528,8 +528,8 @@ public class DirectoryProviderServiceTests
|
||||
public void CopyDirectory_WhenCopyingFilesAndSubdirectories_ShouldCopyAllContents()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSource);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination);
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.Create(_pathSource);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.Create(_pathDestination);
|
||||
bool overrideExisting = true;
|
||||
|
||||
|
||||
@@ -583,8 +583,8 @@ public class DirectoryProviderServiceTests
|
||||
public void CopyDirectory_WhenExceptionOccurs_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.Create();
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.Create();
|
||||
bool overrideExisting = false;
|
||||
|
||||
_mockFileSystem.Directory.Exists(sourcePath.Path).Returns(true);
|
||||
@@ -602,10 +602,10 @@ public class DirectoryProviderServiceTests
|
||||
public void MoveDirectory_WhenSourceDirectoryDoesNotExist_ShouldReturnDirectoryNotFoundError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/NonExistentSource" : @"C:\NonExistentSource"
|
||||
);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.Create(_pathDestination);
|
||||
bool overrideExisting = false;
|
||||
|
||||
_mockFileSystem.Directory.Exists(sourcePath.Path).Returns(false);
|
||||
@@ -622,8 +622,8 @@ public class DirectoryProviderServiceTests
|
||||
public void MoveDirectory_WhenDestinationDirectoryDoesNotExist_ShouldPerformSimpleMove()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSource);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination);
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.Create(_pathSource);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.Create(_pathDestination);
|
||||
bool overrideExisting = false;
|
||||
|
||||
_mockFileSystem.Directory.Exists(sourcePath.Path).Returns(true);
|
||||
@@ -642,8 +642,8 @@ public class DirectoryProviderServiceTests
|
||||
public void MoveDirectory_WhenDestinationDirectoryExists_ShouldMergeDirectories()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSource);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination);
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.Create(_pathSource);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.Create(_pathDestination);
|
||||
bool overrideExisting = true;
|
||||
|
||||
_mockFileSystem.Directory.Exists(sourcePath.Path).Returns(true);
|
||||
@@ -681,8 +681,8 @@ public class DirectoryProviderServiceTests
|
||||
public void MoveDirectory_WhenExceptionOccurs_ShouldReturnDirectoryMoveError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSource);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination);
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.Create(_pathSource);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.Create(_pathDestination);
|
||||
bool overrideExisting = false;
|
||||
|
||||
_mockFileSystem.Directory.Exists(sourcePath.Path).Returns(true);
|
||||
@@ -702,8 +702,8 @@ public class DirectoryProviderServiceTests
|
||||
public void MergeDirectories_WhenSourceContainsFilesAndSubdirectories_ShouldMergeCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSource);
|
||||
FileSystemPathId destPath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination);
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.Create(_pathSource);
|
||||
FileSystemPathId destPath = _fileSystemPathIdFixture.Create(_pathDestination);
|
||||
bool overwrite = true;
|
||||
|
||||
_mockFileSystem.Directory.Exists(sourcePath.Path).Returns(true);
|
||||
@@ -745,8 +745,8 @@ public class DirectoryProviderServiceTests
|
||||
public void MoveDirectory_WhenOverwriteIsFalse_ShouldMoveOnlyNonExistingFiles()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSource);
|
||||
FileSystemPathId destPath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination);
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.Create(_pathSource);
|
||||
FileSystemPathId destPath = _fileSystemPathIdFixture.Create(_pathDestination);
|
||||
bool overwrite = false;
|
||||
|
||||
_mockFileSystem.Directory.Exists(sourcePath.Path).Returns(true);
|
||||
@@ -803,8 +803,8 @@ public class DirectoryProviderServiceTests
|
||||
public void MergeDirectories_WhenSourceContainsNestedDirectories_ShouldMergeRecursively()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSource);
|
||||
FileSystemPathId destPath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination);
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.Create(_pathSource);
|
||||
FileSystemPathId destPath = _fileSystemPathIdFixture.Create(_pathDestination);
|
||||
bool overwrite = true;
|
||||
|
||||
_mockFileSystem.Directory.Exists(sourcePath.Path).Returns(true);
|
||||
@@ -850,7 +850,7 @@ public class DirectoryProviderServiceTests
|
||||
public void RenameDirectory_WhenParentDirectoryIsWritable_ShouldRenameSuccessfully()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/OldName" : @"C:\OldName"
|
||||
);
|
||||
string newName = "NewName";
|
||||
@@ -877,7 +877,7 @@ public class DirectoryProviderServiceTests
|
||||
public void RenameDirectory_WhenParentDirectoryIsNotWritable_ShouldReturnUnauthorizedAccessError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/OldName" : @"C:\OldName"
|
||||
);
|
||||
string newName = "NewName";
|
||||
@@ -903,7 +903,7 @@ public class DirectoryProviderServiceTests
|
||||
public void RenameDirectory_WhenDirectoryIsNotExecutable_ShouldReturnUnauthorizedAccessError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/OldName" : @"C:\OldName"
|
||||
);
|
||||
string newName = "NewName";
|
||||
@@ -930,7 +930,7 @@ public class DirectoryProviderServiceTests
|
||||
public void RenameDirectory_WhenParentDirectoryIsNull_ShouldReturnInvalidPathError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/OldName" : @"C:\OldName"
|
||||
);
|
||||
string newName = "NewName";
|
||||
@@ -950,7 +950,7 @@ public class DirectoryProviderServiceTests
|
||||
public void RenameDirectory_WhenNewPathIsInvalid_ShouldReturnInvalidPathError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/OldName" : @"C:\OldName"
|
||||
);
|
||||
string newName = "NewName";
|
||||
@@ -974,7 +974,7 @@ public class DirectoryProviderServiceTests
|
||||
public void DeleteDirectory_WhenDirectoryExistsAndHasDeletePermission_ShouldDeleteSuccessfully()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/DirectoryToDelete" : @"C:\DirectoryToDelete"
|
||||
);
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.Delete, false).Returns(true);
|
||||
@@ -994,7 +994,7 @@ public class DirectoryProviderServiceTests
|
||||
public void DeleteDirectory_WhenNoDeletePermission_ShouldReturnUnauthorizedAccessError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/DirectoryToDelete" : @"C:\DirectoryToDelete"
|
||||
);
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.Delete, false).Returns(false);
|
||||
|
||||
+50
-50
@@ -6,9 +6,9 @@ using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.File
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.Entities.Fixtures;
|
||||
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.ValueObjects.Fixtures;
|
||||
using NSubstitute;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -57,11 +57,11 @@ public class DirectoryServiceTests
|
||||
// Arrange
|
||||
string path = _pathDirTest;
|
||||
bool includeHiddenElements = false;
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
FileSystemPathId[] subPaths =
|
||||
[
|
||||
_fileSystemPathIdFixture.CreateFileSystemPathId(_pathDirTestSubDir1),
|
||||
_fileSystemPathIdFixture.CreateFileSystemPathId(_pathDirTestSubDir2)
|
||||
_fileSystemPathIdFixture.Create(_pathDirTestSubDir1),
|
||||
_fileSystemPathIdFixture.Create(_pathDirTestSubDir2)
|
||||
];
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetSubdirectoryPaths(pathId, includeHiddenElements)
|
||||
@@ -107,7 +107,7 @@ public class DirectoryServiceTests
|
||||
// Arrange
|
||||
string path = _pathDirTest;
|
||||
bool includeHiddenElements = false;
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetSubdirectoryPaths(pathId, includeHiddenElements)
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
@@ -126,8 +126,8 @@ public class DirectoryServiceTests
|
||||
// Arrange
|
||||
string path = _pathDirTest;
|
||||
bool includeHiddenElements = false;
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId subPath = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
FileSystemPathId subPath = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/TestDir/InaccessibleSub" : @"C:\TestDir\InaccessibleSub"
|
||||
);
|
||||
|
||||
@@ -154,12 +154,12 @@ public class DirectoryServiceTests
|
||||
public void GetSubdirectoriesOverload_WithValidDirectory_ShouldReturnListOfDirectories()
|
||||
{
|
||||
// Arrange
|
||||
Directory parentDirectory = _directoryFixture.CreateDirectory();
|
||||
Directory parentDirectory = _directoryFixture.Create();
|
||||
bool includeHiddenElements = false;
|
||||
FileSystemPathId[] subPaths =
|
||||
[
|
||||
_fileSystemPathIdFixture.CreateFileSystemPathId(_pathDirTestSubDir1),
|
||||
_fileSystemPathIdFixture.CreateFileSystemPathId(_pathDirTestSubDir2)
|
||||
_fileSystemPathIdFixture.Create(_pathDirTestSubDir1),
|
||||
_fileSystemPathIdFixture.Create(_pathDirTestSubDir2)
|
||||
];
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetSubdirectoryPaths(parentDirectory.Id, includeHiddenElements)
|
||||
@@ -188,7 +188,7 @@ public class DirectoryServiceTests
|
||||
public void GetSubdirectoriesOverload_WhenDirectoryProviderServiceReturnsError_ShouldPropagateError()
|
||||
{
|
||||
// Arrange
|
||||
Directory parentDirectory = _directoryFixture.CreateDirectory();
|
||||
Directory parentDirectory = _directoryFixture.Create();
|
||||
bool includeHiddenElements = false;
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetSubdirectoryPaths(parentDirectory.Id, includeHiddenElements)
|
||||
@@ -206,9 +206,9 @@ public class DirectoryServiceTests
|
||||
public void GetSubdirectoriesOverload_WhenSubdirectoryDetailsAreInaccessible_ShouldReturnInaccessibleDirectory()
|
||||
{
|
||||
// Arrange
|
||||
Directory parentDirectory = _directoryFixture.CreateDirectory();
|
||||
Directory parentDirectory = _directoryFixture.Create();
|
||||
bool includeHiddenElements = false;
|
||||
FileSystemPathId subPath = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId subPath = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/TestDir/InaccessibleSub" : @"C:\TestDir\InaccessibleSub"
|
||||
);
|
||||
|
||||
@@ -235,12 +235,12 @@ public class DirectoryServiceTests
|
||||
public void GetSubdirectories_WithValidFileSystemPathId_ShouldReturnListOfDirectories()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDirTest);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(_pathDirTest);
|
||||
bool includeHiddenElements = false;
|
||||
FileSystemPathId[] subPaths =
|
||||
[
|
||||
_fileSystemPathIdFixture.CreateFileSystemPathId(_pathDirTestSubDir1),
|
||||
_fileSystemPathIdFixture.CreateFileSystemPathId(_pathDirTestSubDir2)
|
||||
_fileSystemPathIdFixture.Create(_pathDirTestSubDir1),
|
||||
_fileSystemPathIdFixture.Create(_pathDirTestSubDir2)
|
||||
];
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetSubdirectoryPaths(pathId, includeHiddenElements)
|
||||
@@ -269,7 +269,7 @@ public class DirectoryServiceTests
|
||||
public void GetSubdirectoriesWithFileSystemPathId_WhenDirectoryProviderServiceReturnsError_ShouldPropagateError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDirTest);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(_pathDirTest);
|
||||
bool includeHiddenElements = false;
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetSubdirectoryPaths(pathId, includeHiddenElements)
|
||||
@@ -287,9 +287,9 @@ public class DirectoryServiceTests
|
||||
public void GetSubdirectoriesWithFileSystemPathId_WhenSubdirectoryDetailsAreInaccessible_ShouldReturnInaccessibleDirectory()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDirTest);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(_pathDirTest);
|
||||
bool includeHiddenElements = false;
|
||||
FileSystemPathId subPath = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId subPath = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/TestDir/InaccessibleSub" : @"C:\TestDir\InaccessibleSub"
|
||||
);
|
||||
|
||||
@@ -318,8 +318,8 @@ public class DirectoryServiceTests
|
||||
// Arrange
|
||||
string parentPath = _pathDirTest;
|
||||
string newDirName = "NewDirectory";
|
||||
FileSystemPathId parentPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(parentPath);
|
||||
FileSystemPathId newDirPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(System.IO.Path.Combine(parentPath, newDirName));
|
||||
FileSystemPathId parentPathId = _fileSystemPathIdFixture.Create(parentPath);
|
||||
FileSystemPathId newDirPathId = _fileSystemPathIdFixture.Create(System.IO.Path.Combine(parentPath, newDirName));
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(parentPathId, newDirName).Returns(Result.From(newDirPathId));
|
||||
_mockEnvironmentContext.DirectoryProviderService.DirectoryExists(newDirPathId).Returns(Result.From(false));
|
||||
@@ -360,9 +360,9 @@ public class DirectoryServiceTests
|
||||
public void CreateDirectory_WithFileSystemPathId_ShouldReturnNewDirectory()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId parentPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDirTest);
|
||||
FileSystemPathId parentPathId = _fileSystemPathIdFixture.Create(_pathDirTest);
|
||||
string newDirName = "NewDirectory";
|
||||
FileSystemPathId newDirPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(System.IO.Path.Combine(parentPathId.Path, newDirName));
|
||||
FileSystemPathId newDirPathId = _fileSystemPathIdFixture.Create(System.IO.Path.Combine(parentPathId.Path, newDirName));
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(parentPathId, newDirName).Returns(Result.From(newDirPathId));
|
||||
_mockEnvironmentContext.DirectoryProviderService.DirectoryExists(newDirPathId).Returns(Result.From(false));
|
||||
@@ -388,9 +388,9 @@ public class DirectoryServiceTests
|
||||
public void CreateDirectory_WhenDirectoryProviderServiceReturnsError_ShouldPropagateError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId parentPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDirTest);
|
||||
FileSystemPathId parentPathId = _fileSystemPathIdFixture.Create(_pathDirTest);
|
||||
string newDirName = "NewDirectory";
|
||||
FileSystemPathId newDirPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(System.IO.Path.Combine(parentPathId.Path, newDirName));
|
||||
FileSystemPathId newDirPathId = _fileSystemPathIdFixture.Create(System.IO.Path.Combine(parentPathId.Path, newDirName));
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(parentPathId, newDirName).Returns(Result.From(newDirPathId));
|
||||
_mockEnvironmentContext.DirectoryProviderService.DirectoryExists(newDirPathId).Returns(Result.From(false));
|
||||
@@ -410,9 +410,9 @@ public class DirectoryServiceTests
|
||||
public void CreateDirectory_WhenDirectoryDetailsAreInaccessible_ShouldReturnInaccessibleDirectory()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId parentPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDirTest);
|
||||
FileSystemPathId parentPathId = _fileSystemPathIdFixture.Create(_pathDirTest);
|
||||
string newDirName = "NewDirectory";
|
||||
FileSystemPathId newDirPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(System.IO.Path.Combine(parentPathId.Path, newDirName));
|
||||
FileSystemPathId newDirPathId = _fileSystemPathIdFixture.Create(System.IO.Path.Combine(parentPathId.Path, newDirName));
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(parentPathId, newDirName).Returns(Result.From(newDirPathId));
|
||||
_mockEnvironmentContext.DirectoryProviderService.DirectoryExists(newDirPathId).Returns(Result.From(false));
|
||||
@@ -442,9 +442,9 @@ public class DirectoryServiceTests
|
||||
public void CreateDirectory_WhenDirectoryExistsReturnsError_ShouldPropagateError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId parentPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDirTest);
|
||||
FileSystemPathId parentPathId = _fileSystemPathIdFixture.Create(_pathDirTest);
|
||||
string newDirName = "NewDirectory";
|
||||
FileSystemPathId newDirPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(System.IO.Path.Combine(parentPathId.Path, newDirName));
|
||||
FileSystemPathId newDirPathId = _fileSystemPathIdFixture.Create(System.IO.Path.Combine(parentPathId.Path, newDirName));
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(parentPathId, newDirName).Returns(Result.From(newDirPathId));
|
||||
_mockEnvironmentContext.DirectoryProviderService.DirectoryExists(newDirPathId)
|
||||
@@ -462,9 +462,9 @@ public class DirectoryServiceTests
|
||||
public void CreateDirectory_WhenDirectoryAlreadyExists_ShouldReturnDirectoryAlreadyExistsError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId parentPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDirTest);
|
||||
FileSystemPathId parentPathId = _fileSystemPathIdFixture.Create(_pathDirTest);
|
||||
string newDirName = "ExistingDirectory";
|
||||
FileSystemPathId newDirPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(System.IO.Path.Combine(parentPathId.Path, newDirName));
|
||||
FileSystemPathId newDirPathId = _fileSystemPathIdFixture.Create(System.IO.Path.Combine(parentPathId.Path, newDirName));
|
||||
_mockPlatformContext.PathStrategy.CombinePath(parentPathId, newDirName).Returns(Result.From(newDirPathId));
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.DirectoryExists(newDirPathId).Returns(true);
|
||||
@@ -481,7 +481,7 @@ public class DirectoryServiceTests
|
||||
public void CreateDirectory_WhenCombinePathReturnsError_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId parentPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDirTest);
|
||||
FileSystemPathId parentPathId = _fileSystemPathIdFixture.Create(_pathDirTest);
|
||||
string newDirName = "NewDirectory";
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(parentPathId, newDirName)
|
||||
@@ -505,8 +505,8 @@ public class DirectoryServiceTests
|
||||
// Arrange
|
||||
string oldPath = s_isUnix ? "/TestDir/OldName" : @"C:\TestDir\OldName";
|
||||
string newName = "NewName";
|
||||
FileSystemPathId oldPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(oldPath);
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId oldPathId = _fileSystemPathIdFixture.Create(oldPath);
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/TestDir/NewName" : @"C:\TestDir\NewName"
|
||||
);
|
||||
|
||||
@@ -550,11 +550,11 @@ public class DirectoryServiceTests
|
||||
public void RenameDirectory_WithFileSystemPathId_ShouldReturnRenamedDirectory()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId oldPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId oldPathId = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/TestDir/OldName" : @"C:\TestDir\OldName"
|
||||
);
|
||||
string newName = "NewName";
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/TestDir/NewName" : @"C:\TestDir\NewName"
|
||||
);
|
||||
|
||||
@@ -583,11 +583,11 @@ public class DirectoryServiceTests
|
||||
public void RenameDirectory_WhenDirectoryProviderServiceReturnsError_ShouldPropagateError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId oldPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId oldPathId = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/TestDir/OldName" : @"C:\TestDir\OldName"
|
||||
);
|
||||
string newName = "NewName";
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/TestDir/NewName" : @"C:\TestDir\NewName"
|
||||
);
|
||||
|
||||
@@ -609,11 +609,11 @@ public class DirectoryServiceTests
|
||||
public void RenameDirectory_WhenDirectoryDetailsAreInaccessible_ShouldReturnInaccessibleDirectory()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId oldPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId oldPathId = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/TestDir/OldName" : @"C:\TestDir\OldName"
|
||||
);
|
||||
string newName = "NewName";
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/TestDir/NewName" : @"C:\TestDir\NewName"
|
||||
);
|
||||
|
||||
@@ -645,11 +645,11 @@ public class DirectoryServiceTests
|
||||
public void RenameDirectory_WhenDirectoryAlreadyExists_ShouldReturnDirectoryAlreadyExistsError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId oldPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId oldPathId = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/TestDir/OldName" : @"C:\TestDir\OldName"
|
||||
);
|
||||
string newName = "ExistingDirectory";
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/TestDir/ExistingDirectory" : @"C:\TestDir\ExistingDirectory"
|
||||
);
|
||||
|
||||
@@ -670,7 +670,7 @@ public class DirectoryServiceTests
|
||||
public void RenameDirectory_WhenCombinePathReturnsError_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId oldPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId oldPathId = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/TestDir/OldName" : @"C:\TestDir\OldName"
|
||||
);
|
||||
string newName = "NewName";
|
||||
@@ -694,11 +694,11 @@ public class DirectoryServiceTests
|
||||
public void RenameDirectory_WhenDirectoryExistsReturnsError_ShouldPropagateError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId oldPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId oldPathId = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/TestDir/OldName" : @"C:\TestDir\OldName"
|
||||
);
|
||||
string newName = "NewName";
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/TestDir/NewName" : @"C:\TestDir\NewName"
|
||||
);
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
@@ -723,7 +723,7 @@ public class DirectoryServiceTests
|
||||
{
|
||||
// Arrange
|
||||
string path = s_isUnix ? "/TestDir/ToDelete" : @"C:\TestDir\ToDelete";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.DeleteDirectory(pathId)
|
||||
.Returns(Result.Deleted);
|
||||
@@ -754,7 +754,7 @@ public class DirectoryServiceTests
|
||||
public void DeleteDirectory_WithFileSystemPathId_ShouldReturnDeleted()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/TestDir/ToDelete" : @"C:\TestDir\ToDelete"
|
||||
);
|
||||
|
||||
@@ -773,7 +773,7 @@ public class DirectoryServiceTests
|
||||
public void DeleteDirectory_WhenDirectoryProviderServiceReturnsError_ShouldPropagateError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/TestDir/ToDelete" : @"C:\TestDir\ToDelete"
|
||||
);
|
||||
|
||||
@@ -792,7 +792,7 @@ public class DirectoryServiceTests
|
||||
public void DeleteDirectory_WhenDirectoryDoesNotExist_ShouldReturnDirectoryNotFoundError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/TestDir/NonExistent" : @"C:\TestDir\NonExistent"
|
||||
);
|
||||
|
||||
|
||||
+47
-47
@@ -5,8 +5,8 @@ using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.ValueObjects.Fixtures;
|
||||
using NSubstitute;
|
||||
using NSubstitute.ExceptionExtensions;
|
||||
using System;
|
||||
@@ -57,7 +57,7 @@ public class FileProviderServiceTests
|
||||
public void GetFilePaths_WhenUserHasNoAccess_ShouldReturnUnauthorizedAccessError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ListDirectory).Returns(false);
|
||||
|
||||
// Act
|
||||
@@ -72,8 +72,8 @@ public class FileProviderServiceTests
|
||||
public void GetFilePaths_WhenUserHasAccess_ShouldReturnFiles()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
string[] files = _fixture.CreateMany<string>(3).ToArray();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
string[] files = [.. _fixture.CreateMany<string>(3)];
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ListDirectory).Returns(true);
|
||||
_mockFileSystem.Directory.GetFiles(path.Path).Returns(files);
|
||||
|
||||
@@ -93,7 +93,7 @@ public class FileProviderServiceTests
|
||||
public void GetFilePaths_WhenIncludeHiddenElementsIsFalse_ShouldExcludeHiddenFiles()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
string[] files = [_pathVisible1, _pathHidden1];
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ListDirectory).Returns(true);
|
||||
_mockFileSystem.Directory.GetFiles(path.Path).Returns(files);
|
||||
@@ -113,7 +113,7 @@ public class FileProviderServiceTests
|
||||
public void GetFilePaths_WhenIncludeHiddenElementsIsTrue_ShouldIncludeHiddenFiles()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
string[] files = [_pathVisible1, _pathHidden1];
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ListDirectory).Returns(true);
|
||||
_mockFileSystem.Directory.GetFiles(path.Path).Returns(files);
|
||||
@@ -136,7 +136,7 @@ public class FileProviderServiceTests
|
||||
public void GetFilePaths_WhenGetAttributesThrowsException_ShouldStillAddFile()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
string[] files = [_pathValid1, _pathInvalid1];
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ListDirectory).Returns(true);
|
||||
_mockFileSystem.Directory.GetFiles(path.Path).Returns(files);
|
||||
@@ -156,7 +156,7 @@ public class FileProviderServiceTests
|
||||
public void GetFilePaths_WhenCalled_ShouldOrderFilesAlphabetically()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
string[] files = s_isUnix
|
||||
? ["/C.txt", "/A.txt", "/B.txt"]
|
||||
: [@"C:\C.txt", @"C:\A.txt", @"C:\B.txt"];
|
||||
@@ -179,7 +179,7 @@ public class FileProviderServiceTests
|
||||
public void GetFilePaths_WhenDirectoryHasNoFiles_ShouldReturnEmptyList()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ListDirectory).Returns(true);
|
||||
_mockFileSystem.Directory.GetFiles(path.Path).Returns([]);
|
||||
|
||||
@@ -195,7 +195,7 @@ public class FileProviderServiceTests
|
||||
public void FileExists_WhenFileExists_ShouldReturnTrue()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
_mockFileSystem.File.Exists(path.Path).Returns(true);
|
||||
|
||||
// Act
|
||||
@@ -210,7 +210,7 @@ public class FileProviderServiceTests
|
||||
public void FileExists_WhenFileDoesNotExist_ShouldReturnFalse()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
_mockFileSystem.File.Exists(path.Path).Returns(false);
|
||||
|
||||
// Act
|
||||
@@ -225,7 +225,7 @@ public class FileProviderServiceTests
|
||||
public void GetFileName_WhenPathIsValid_ShouldReturnFileName()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
string expectedFileName = "testfile.txt";
|
||||
_mockFileSystem.Path.GetFileName(path.Path).Returns(expectedFileName);
|
||||
|
||||
@@ -241,7 +241,7 @@ public class FileProviderServiceTests
|
||||
public void GetFileName_WhenPathIsEmpty_ShouldReturnEmptyString()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
_mockFileSystem.Path.GetFileName(path.Path).Returns(string.Empty);
|
||||
|
||||
// Act
|
||||
@@ -286,7 +286,7 @@ public class FileProviderServiceTests
|
||||
public void GetFileAsync_WhenUserHasNoAccess_ShouldReturnUnauthorizedAccessError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadContents).Returns(false);
|
||||
|
||||
// Act
|
||||
@@ -353,7 +353,7 @@ public class FileProviderServiceTests
|
||||
public void GetLastWriteTime_WhenUserHasNoAccess_ShouldReturnUnauthorizedAccessError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties).Returns(false);
|
||||
|
||||
// Act
|
||||
@@ -396,7 +396,7 @@ public class FileProviderServiceTests
|
||||
public void GetCreationTime_WhenUserHasNoAccess_ShouldReturnUnauthorizedAccessError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties).Returns(false);
|
||||
|
||||
// Act
|
||||
@@ -440,7 +440,7 @@ public class FileProviderServiceTests
|
||||
public void GetSize_WhenUserHasNoAccess_ShouldReturnUnauthorizedAccessError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties).Returns(false);
|
||||
|
||||
// Act
|
||||
@@ -473,8 +473,8 @@ public class FileProviderServiceTests
|
||||
public void CopyFile_WhenSourceFileExistsAndUserHasAccess_ShouldCopyFileAndReturnPath()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceFile);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination);
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.Create(_pathSourceFile);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.Create(_pathDestination);
|
||||
bool overrideExisting = false;
|
||||
|
||||
_mockFileSystem.File.Exists(sourcePath.Path).Returns(true);
|
||||
@@ -496,8 +496,8 @@ public class FileProviderServiceTests
|
||||
public void CopyFile_WhenSourceFileDoesNotExist_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.Create();
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.Create();
|
||||
bool overrideExisting = false;
|
||||
|
||||
_mockFileSystem.File.Exists(sourcePath.Path).Returns(false);
|
||||
@@ -514,8 +514,8 @@ public class FileProviderServiceTests
|
||||
public void CopyFile_WhenDestinationFileExistsAndOverrideIsFalse_ShouldReturnFileAlreadyExistsError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceFile);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination);
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.Create(_pathSourceFile);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.Create(_pathDestination);
|
||||
string expectedDestinationFilePath = _pathDestinationFile;
|
||||
bool overrideExisting = false;
|
||||
|
||||
@@ -541,8 +541,8 @@ public class FileProviderServiceTests
|
||||
public void CopyFile_WhenOverrideExistingIsTrue_ShouldOverwriteExistingFile()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceFile);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination);
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.Create(_pathSourceFile);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.Create(_pathDestination);
|
||||
bool overrideExisting = true;
|
||||
|
||||
_mockFileSystem.File.Exists(sourcePath.Path).Returns(true);
|
||||
@@ -564,8 +564,8 @@ public class FileProviderServiceTests
|
||||
public void CopyFile_WhenExceptionOccurs_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.Create();
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.Create();
|
||||
bool overrideExisting = false;
|
||||
|
||||
_mockFileSystem.File.Exists(sourcePath.Path).Returns(true);
|
||||
@@ -585,8 +585,8 @@ public class FileProviderServiceTests
|
||||
{
|
||||
// Arrange
|
||||
string sourceDirectory = _pathSource;
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId(Path.Combine(sourceDirectory, "file.txt"));
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.CreateFileSystemPathId(sourceDirectory);
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.Create(Path.Combine(sourceDirectory, "file.txt"));
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.Create(sourceDirectory);
|
||||
string expectedNewFilePath = Path.Combine(sourceDirectory, "file - Copy (1).txt");
|
||||
bool overrideExisting = false;
|
||||
|
||||
@@ -627,10 +627,10 @@ public class FileProviderServiceTests
|
||||
public void MoveFile_WhenSourceFileDoesNotExist_ShouldReturnFileNotFoundError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/NonExistentSource.txt" : @"C:\NonExistentSource.txt"
|
||||
);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.Create(_pathDestination);
|
||||
bool overrideExisting = false;
|
||||
|
||||
_mockFileSystem.File.Exists(sourcePath.Path).Returns(false);
|
||||
@@ -647,8 +647,8 @@ public class FileProviderServiceTests
|
||||
public void MoveFile_WhenDestinationFileDoesNotExist_ShouldPerformSimpleMove()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceFile);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination);
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.Create(_pathSourceFile);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.Create(_pathDestination);
|
||||
string destinationFilePath = _pathDestinationFile;
|
||||
bool overrideExisting = false;
|
||||
|
||||
@@ -670,8 +670,8 @@ public class FileProviderServiceTests
|
||||
public void MoveFile_WhenDestinationFileExistsAndOverrideIsTrue_ShouldOverwriteFile()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceFile);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination);
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.Create(_pathSourceFile);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.Create(_pathDestination);
|
||||
string destinationFilePath = _pathDestinationFile;
|
||||
bool overrideExisting = true;
|
||||
|
||||
@@ -693,8 +693,8 @@ public class FileProviderServiceTests
|
||||
public void MoveFile_WhenDestinationFileExistsAndOverrideIsFalse_ShouldReturnFileAlreadyExistsError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceFile);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination);
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.Create(_pathSourceFile);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.Create(_pathDestination);
|
||||
string destinationFilePath = _pathDestinationFile;
|
||||
bool overrideExisting = false;
|
||||
|
||||
@@ -715,8 +715,8 @@ public class FileProviderServiceTests
|
||||
public void MoveFile_WhenExceptionOccurs_ShouldReturnFileMoveError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceFile);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination);
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.Create(_pathSourceFile);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.Create(_pathDestination);
|
||||
string destinationFilePath = _pathDestinationFile;
|
||||
bool overrideExisting = false;
|
||||
|
||||
@@ -739,7 +739,7 @@ public class FileProviderServiceTests
|
||||
public void RenameFile_WhenParentDirectoryIsWritable_ShouldRenameSuccessfully()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/OldName.txt" : @"C:\OldName.txt"
|
||||
);
|
||||
string newName = "NewName.txt";
|
||||
@@ -766,7 +766,7 @@ public class FileProviderServiceTests
|
||||
public void RenameFile_WhenParentDirectoryIsNotWritable_ShouldReturnUnauthorizedAccessError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/OldName.txt" : @"C:\OldName.txt"
|
||||
);
|
||||
string newName = "NewName.txt";
|
||||
@@ -792,7 +792,7 @@ public class FileProviderServiceTests
|
||||
public void RenameFile_WhenFileIsNotExecutable_ShouldReturnUnauthorizedAccessError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/OldName.txt" : @"C:\OldName.txt"
|
||||
);
|
||||
string newName = "NewName.txt";
|
||||
@@ -819,7 +819,7 @@ public class FileProviderServiceTests
|
||||
public void RenameFile_WhenParentDirectoryIsNull_ShouldReturnInvalidPathError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/OldName.txt" : @"C:\OldName.txt"
|
||||
);
|
||||
string newName = "NewName.txt";
|
||||
@@ -839,7 +839,7 @@ public class FileProviderServiceTests
|
||||
public void RenameFile_WhenNewPathIsInvalid_ShouldReturnInvalidPathError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/OldName.txt" : @"C:\OldName.txt"
|
||||
);
|
||||
string newName = "NewName.txt";
|
||||
@@ -863,7 +863,7 @@ public class FileProviderServiceTests
|
||||
public void RenameFile_WhenParentDirectoryExistsButNotWritable_ShouldReturnUnauthorizedAccessError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/OldName.txt" : @"C:\OldName.txt"
|
||||
);
|
||||
string newName = "NewName.txt";
|
||||
@@ -896,7 +896,7 @@ public class FileProviderServiceTests
|
||||
public void DeleteFile_WhenFileExistsAndHasDeletePermission_ShouldDeleteSuccessfully()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/FileToDelete.txt" : @"C:\FileToDelete.txt"
|
||||
);
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.Delete).Returns(true);
|
||||
@@ -915,7 +915,7 @@ public class FileProviderServiceTests
|
||||
public void DeleteFile_WhenNoDeletePermission_ShouldReturnUnauthorizedAccessError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/FileToDelete.txt" : @"C:\FileToDelete.txt"
|
||||
);
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.Delete).Returns(false);
|
||||
|
||||
+82
-82
@@ -6,9 +6,9 @@ using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.File
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.Entities.Fixtures;
|
||||
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.ValueObjects.Fixtures;
|
||||
using NSubstitute;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -67,11 +67,11 @@ public class FileServiceTests
|
||||
// Arrange
|
||||
string path = _pathTestDir;
|
||||
bool includeHiddenElements = false;
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
FileSystemPathId[] filePaths =
|
||||
[
|
||||
_fileSystemPathIdFixture.CreateFileSystemPathId(_pathTestDirFile1),
|
||||
_fileSystemPathIdFixture.CreateFileSystemPathId(_pathTestDirFile2)
|
||||
_fileSystemPathIdFixture.Create(_pathTestDirFile1),
|
||||
_fileSystemPathIdFixture.Create(_pathTestDirFile2)
|
||||
];
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.GetFilePaths(pathId, includeHiddenElements)
|
||||
@@ -119,7 +119,7 @@ public class FileServiceTests
|
||||
// Arrange
|
||||
string path = _pathTestDir;
|
||||
bool includeHiddenElements = false;
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.GetFilePaths(pathId, includeHiddenElements)
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
@@ -138,8 +138,8 @@ public class FileServiceTests
|
||||
// Arrange
|
||||
string path = _pathTestDir;
|
||||
bool includeHiddenElements = false;
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId filePath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathTestDirInaccessible);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
FileSystemPathId filePath = _fileSystemPathIdFixture.Create(_pathTestDirInaccessible);
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.GetFilePaths(pathId, includeHiddenElements)
|
||||
.Returns(Result.From(new[] { filePath }.AsEnumerable()));
|
||||
@@ -166,12 +166,12 @@ public class FileServiceTests
|
||||
public void GetFilesOverload_WithValidFile_ShouldReturnListOfFiles()
|
||||
{
|
||||
// Arrange
|
||||
File parentFile = _fileFixture.CreateFile();
|
||||
File parentFile = _fileFixture.Create();
|
||||
bool includeHiddenElements = false;
|
||||
FileSystemPathId[] filePaths =
|
||||
[
|
||||
_fileSystemPathIdFixture.CreateFileSystemPathId(_pathTestDirFile1),
|
||||
_fileSystemPathIdFixture.CreateFileSystemPathId(_pathTestDirFile2)
|
||||
_fileSystemPathIdFixture.Create(_pathTestDirFile1),
|
||||
_fileSystemPathIdFixture.Create(_pathTestDirFile2)
|
||||
];
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.GetFilePaths(parentFile.Id, includeHiddenElements)
|
||||
@@ -202,7 +202,7 @@ public class FileServiceTests
|
||||
public void GetFilesOverload_WhenFileProviderServiceReturnsError_ShouldPropagateError()
|
||||
{
|
||||
// Arrange
|
||||
File parentFile = _fileFixture.CreateFile();
|
||||
File parentFile = _fileFixture.Create();
|
||||
bool includeHiddenElements = false;
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.GetFilePaths(parentFile.Id, includeHiddenElements)
|
||||
@@ -220,9 +220,9 @@ public class FileServiceTests
|
||||
public void GetFilesOverload_WhenFileDetailsAreInaccessible_ShouldReturnInaccessibleFile()
|
||||
{
|
||||
// Arrange
|
||||
File parentFile = _fileFixture.CreateFile();
|
||||
File parentFile = _fileFixture.Create();
|
||||
bool includeHiddenElements = false;
|
||||
FileSystemPathId filePath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathTestDirInaccessible);
|
||||
FileSystemPathId filePath = _fileSystemPathIdFixture.Create(_pathTestDirInaccessible);
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.GetFilePaths(parentFile.Id, includeHiddenElements)
|
||||
.Returns(Result.From(new[] { filePath }.AsEnumerable()));
|
||||
@@ -249,12 +249,12 @@ public class FileServiceTests
|
||||
public void GetFiles_WithValidFileSystemPathId_ShouldReturnListOfFiles()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathTestDir);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(_pathTestDir);
|
||||
bool includeHiddenElements = false;
|
||||
FileSystemPathId[] filePaths =
|
||||
[
|
||||
_fileSystemPathIdFixture.CreateFileSystemPathId(_pathTestDirFile1),
|
||||
_fileSystemPathIdFixture.CreateFileSystemPathId(_pathTestDirFile2)
|
||||
_fileSystemPathIdFixture.Create(_pathTestDirFile1),
|
||||
_fileSystemPathIdFixture.Create(_pathTestDirFile2)
|
||||
];
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.GetFilePaths(pathId, includeHiddenElements)
|
||||
@@ -285,7 +285,7 @@ public class FileServiceTests
|
||||
public void GetFilesWithFileSystemPathId_WhenFileProviderServiceReturnsError_ShouldPropagateError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathTestDir);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(_pathTestDir);
|
||||
bool includeHiddenElements = false;
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.GetFilePaths(pathId, includeHiddenElements)
|
||||
@@ -303,9 +303,9 @@ public class FileServiceTests
|
||||
public void GetFilesWithFileSystemPathId_WhenFileDetailsAreInaccessible_ShouldReturnInaccessibleFile()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathTestDir);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(_pathTestDir);
|
||||
bool includeHiddenElements = false;
|
||||
FileSystemPathId filePath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathTestDirInaccessible);
|
||||
FileSystemPathId filePath = _fileSystemPathIdFixture.Create(_pathTestDirInaccessible);
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.GetFilePaths(pathId, includeHiddenElements)
|
||||
.Returns(Result.From(new[] { filePath }.AsEnumerable()));
|
||||
@@ -335,9 +335,9 @@ public class FileServiceTests
|
||||
string sourcePath = _pathSourceFile;
|
||||
string destinationPath = _pathDestination1;
|
||||
bool overrideExisting = true;
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(sourcePath);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(destinationPath);
|
||||
FileSystemPathId copiedFilePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestinationFile);
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.Create(sourcePath);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.Create(destinationPath);
|
||||
FileSystemPathId copiedFilePathId = _fileSystemPathIdFixture.Create(_pathDestinationFile);
|
||||
|
||||
_mockPlatformContext.PathStrategy.PathSeparator.Returns(_dirSeparator);
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), Arg.Any<string>())
|
||||
@@ -369,7 +369,7 @@ public class FileServiceTests
|
||||
string sourcePath = _pathSourceNonExistingFile;
|
||||
string destinationPath = _pathDestination1;
|
||||
bool overrideExisting = true;
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(sourcePath);
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.Create(sourcePath);
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(sourcePathId).Returns(Result.From(false));
|
||||
|
||||
@@ -388,8 +388,8 @@ public class FileServiceTests
|
||||
string sourcePath = _pathSourceFile;
|
||||
string destinationPath = _pathDestination1;
|
||||
bool overrideExisting = true;
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(sourcePath);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(destinationPath);
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.Create(sourcePath);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.Create(destinationPath);
|
||||
|
||||
_mockPlatformContext.PathStrategy.PathSeparator.Returns(_dirSeparator);
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(sourcePathId).Returns(Result.From(true));
|
||||
@@ -411,9 +411,9 @@ public class FileServiceTests
|
||||
string sourcePath = _pathSourceFile;
|
||||
string destinationPath = _pathDestination1;
|
||||
bool overrideExisting = true;
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(sourcePath);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(destinationPath);
|
||||
FileSystemPathId copiedFilePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestinationFile);
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.Create(sourcePath);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.Create(destinationPath);
|
||||
FileSystemPathId copiedFilePathId = _fileSystemPathIdFixture.Create(_pathDestinationFile);
|
||||
|
||||
_mockPlatformContext.PathStrategy.PathSeparator.Returns(_dirSeparator);
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(sourcePathId).Returns(Result.From(true));
|
||||
@@ -471,9 +471,9 @@ public class FileServiceTests
|
||||
public void CopyFile_WithValidFileSystemPathIds_ShouldReturnCopiedFile()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceFile);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination2);
|
||||
FileSystemPathId copiedFilePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestinationFile);
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.Create(_pathSourceFile);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.Create(_pathDestination2);
|
||||
FileSystemPathId copiedFilePathId = _fileSystemPathIdFixture.Create(_pathDestinationFile);
|
||||
bool overrideExisting = true;
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(sourcePathId).Returns(true);
|
||||
@@ -500,8 +500,8 @@ public class FileServiceTests
|
||||
public void CopyFileWithFileSystemPathIds_WhenSourceDoesNotExist_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceNonExistingFile);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination2);
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.Create(_pathSourceNonExistingFile);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.Create(_pathDestination2);
|
||||
bool overrideExisting = true;
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(sourcePathId).Returns(false);
|
||||
@@ -518,8 +518,8 @@ public class FileServiceTests
|
||||
public void CopyFileWithFileSystemPathIds_WhenFileProviderServiceReturnsError_ShouldPropagateError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceFile);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination2);
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.Create(_pathSourceFile);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.Create(_pathDestination2);
|
||||
bool overrideExisting = true;
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(sourcePathId).Returns(true);
|
||||
@@ -538,9 +538,9 @@ public class FileServiceTests
|
||||
public void CopyFileWithFileSystemPathIds_WhenRetrievingFileInfoFails_ShouldReturnInaccessibleFile()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceFile);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination2);
|
||||
FileSystemPathId copiedFilePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestinationFile);
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.Create(_pathSourceFile);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.Create(_pathDestination2);
|
||||
FileSystemPathId copiedFilePathId = _fileSystemPathIdFixture.Create(_pathDestinationFile);
|
||||
bool overrideExisting = true;
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(sourcePathId).Returns(true);
|
||||
@@ -568,9 +568,9 @@ public class FileServiceTests
|
||||
string sourcePath = _pathSourceFile;
|
||||
string destinationPath = _pathDestination1;
|
||||
bool overrideExisting = true;
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(sourcePath);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(destinationPath);
|
||||
FileSystemPathId movedFilePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestinationFile);
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.Create(sourcePath);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.Create(destinationPath);
|
||||
FileSystemPathId movedFilePathId = _fileSystemPathIdFixture.Create(_pathDestinationFile);
|
||||
|
||||
_mockPlatformContext.PathStrategy.PathSeparator.Returns(_dirSeparator);
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), Arg.Any<string>())
|
||||
@@ -602,7 +602,7 @@ public class FileServiceTests
|
||||
string sourcePath = _pathSourceNonExistingFile;
|
||||
string destinationPath = _pathDestination2;
|
||||
bool overrideExisting = true;
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(sourcePath);
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.Create(sourcePath);
|
||||
|
||||
_mockPlatformContext.PathStrategy.PathSeparator.Returns(_dirSeparator);
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(sourcePathId).Returns(false);
|
||||
@@ -622,8 +622,8 @@ public class FileServiceTests
|
||||
string sourcePath = _pathSourceFile;
|
||||
string destinationPath = _pathDestination1;
|
||||
bool overrideExisting = true;
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(sourcePath);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(destinationPath);
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.Create(sourcePath);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.Create(destinationPath);
|
||||
|
||||
_mockPlatformContext.PathStrategy.PathSeparator.Returns(_dirSeparator);
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(sourcePathId).Returns(true);
|
||||
@@ -645,9 +645,9 @@ public class FileServiceTests
|
||||
string sourcePath = _pathSourceFile;
|
||||
string destinationPath = _pathDestination1;
|
||||
bool overrideExisting = true;
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(sourcePath);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(destinationPath);
|
||||
FileSystemPathId movedFilePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestinationFile);
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.Create(sourcePath);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.Create(destinationPath);
|
||||
FileSystemPathId movedFilePathId = _fileSystemPathIdFixture.Create(_pathDestinationFile);
|
||||
|
||||
_mockPlatformContext.PathStrategy.PathSeparator.Returns(_dirSeparator);
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), Arg.Any<string>())
|
||||
@@ -710,9 +710,9 @@ public class FileServiceTests
|
||||
public void MoveFile_WithValidFileSystemPathIds_ShouldReturnMovedFile()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceFile);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination2);
|
||||
FileSystemPathId movedFilePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestinationFile);
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.Create(_pathSourceFile);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.Create(_pathDestination2);
|
||||
FileSystemPathId movedFilePathId = _fileSystemPathIdFixture.Create(_pathDestinationFile);
|
||||
bool overrideExisting = true;
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(sourcePathId).Returns(true);
|
||||
@@ -739,10 +739,10 @@ public class FileServiceTests
|
||||
public void MoveFileWithFileSystemPathIds_WhenSourceDoesNotExist_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/Source/nonexistent.txt" : _pathSourceNonExistingFile
|
||||
);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination2);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.Create(_pathDestination2);
|
||||
bool overrideExisting = true;
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(sourcePathId).Returns(false);
|
||||
@@ -759,8 +759,8 @@ public class FileServiceTests
|
||||
public void MoveFileWithFileSystemPathIds_WhenFileProviderServiceReturnsError_ShouldPropagateError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceFile);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination1);
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.Create(_pathSourceFile);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.Create(_pathDestination1);
|
||||
bool overrideExisting = true;
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(sourcePathId).Returns(true);
|
||||
@@ -779,9 +779,9 @@ public class FileServiceTests
|
||||
public void MoveFileWithFileSystemPathIds_WhenRetrievingFileInfoFails_ShouldReturnInaccessibleFile()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceFile);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination1);
|
||||
FileSystemPathId movedFilePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestinationFile);
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.Create(_pathSourceFile);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.Create(_pathDestination1);
|
||||
FileSystemPathId movedFilePathId = _fileSystemPathIdFixture.Create(_pathDestinationFile);
|
||||
bool overrideExisting = true;
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(sourcePathId).Returns(true);
|
||||
@@ -809,7 +809,7 @@ public class FileServiceTests
|
||||
string sourcePath = _pathSourceFile;
|
||||
string destinationPath = _pathDestination1;
|
||||
bool overrideExisting = true;
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(sourcePath);
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.Create(sourcePath);
|
||||
|
||||
_mockPlatformContext.PathStrategy.PathSeparator.Returns(_dirSeparator);
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(sourcePathId)
|
||||
@@ -829,8 +829,8 @@ public class FileServiceTests
|
||||
// Arrange
|
||||
string path = _pathSourceOldFile;
|
||||
string newName = "newfile.txt";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceNewFile);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.Create(_pathSourceNewFile);
|
||||
|
||||
_mockPlatformContext.PathStrategy.PathSeparator.Returns(_dirSeparator);
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
@@ -861,7 +861,7 @@ public class FileServiceTests
|
||||
// Arrange
|
||||
string path = _pathSourceOldFile;
|
||||
string newName = "existingfile.txt";
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceExistingFile);
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.Create(_pathSourceExistingFile);
|
||||
|
||||
_mockPlatformContext.PathStrategy.PathSeparator.Returns(_dirSeparator);
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
@@ -882,8 +882,8 @@ public class FileServiceTests
|
||||
// Arrange
|
||||
string path = _pathSourceOldFile;
|
||||
string newName = "newfile.txt";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceNewFile);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.Create(_pathSourceNewFile);
|
||||
|
||||
_mockPlatformContext.PathStrategy.PathSeparator.Returns(_dirSeparator);
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
@@ -906,8 +906,8 @@ public class FileServiceTests
|
||||
// Arrange
|
||||
string path = _pathSourceOldFile;
|
||||
string newName = "newfile.txt";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceNewFile);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.Create(_pathSourceNewFile);
|
||||
|
||||
_mockPlatformContext.PathStrategy.PathSeparator.Returns(_dirSeparator);
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
@@ -951,9 +951,9 @@ public class FileServiceTests
|
||||
public void RenameFileWithValidFileSystemPathIdAndName_ShouldReturnRenamedFile()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceOldFile);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(_pathSourceOldFile);
|
||||
string newName = "newfile.txt";
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceNewFile);
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.Create(_pathSourceNewFile);
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
.Returns(Result.From(newPathId));
|
||||
@@ -981,9 +981,9 @@ public class FileServiceTests
|
||||
public void RenameFileWithFileSystemPathId_WhenNewNameAlreadyExists_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceOldFile);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(_pathSourceOldFile);
|
||||
string newName = "existingfile.txt";
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceExistingFile);
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.Create(_pathSourceExistingFile);
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
.Returns(Result.From(newPathId));
|
||||
@@ -1001,9 +1001,9 @@ public class FileServiceTests
|
||||
public void RenameFileWithFileSystemPathId_WhenFileProviderServiceReturnsError_ShouldPropagateError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceOldFile);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(_pathSourceOldFile);
|
||||
string newName = "newfile.txt";
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceNewFile);
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.Create(_pathSourceNewFile);
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
.Returns(Result.From(newPathId));
|
||||
@@ -1023,9 +1023,9 @@ public class FileServiceTests
|
||||
public void RenameFileWithFileSystemPathId_WhenRetrievingFileInfoFails_ShouldReturnInaccessibleFile()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceOldFile);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(_pathSourceOldFile);
|
||||
string newName = "newfile.txt";
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceNewFile);
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.Create(_pathSourceNewFile);
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
.Returns(Result.From(newPathId));
|
||||
@@ -1072,7 +1072,7 @@ public class FileServiceTests
|
||||
// Arrange
|
||||
string path = _pathSourceOldFile;
|
||||
string newName = "newfile.txt";
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceNewFile);
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.Create(_pathSourceNewFile);
|
||||
|
||||
_mockPlatformContext.PathStrategy.PathSeparator.Returns(_dirSeparator);
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
@@ -1092,7 +1092,7 @@ public class FileServiceTests
|
||||
public void RenameFileWithFileSystemPathId_WhenCombinePathReturnsError_ShouldPropagateError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceOldFile);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(_pathSourceOldFile);
|
||||
string newName = "newfile.txt";
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
@@ -1110,9 +1110,9 @@ public class FileServiceTests
|
||||
public void RenameFileWithFileSystemPathId_WhenFileExistsReturnsError_ShouldPropagateError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceOldFile);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(_pathSourceOldFile);
|
||||
string newName = "newfile.txt";
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceNewFile);
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.Create(_pathSourceNewFile);
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
.Returns(Result.From(newPathId));
|
||||
@@ -1132,7 +1132,7 @@ public class FileServiceTests
|
||||
{
|
||||
// Arrange
|
||||
string path = _pathSourceFile;
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.DeleteFile(pathId)
|
||||
.Returns(Result.Deleted);
|
||||
@@ -1164,7 +1164,7 @@ public class FileServiceTests
|
||||
{
|
||||
// Arrange
|
||||
string path = _pathSourceFile;
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.DeleteFile(pathId)
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
@@ -1181,7 +1181,7 @@ public class FileServiceTests
|
||||
public void DeleteFile_WithValidFileSystemPathId_ShouldReturnDeleted()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceFile);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(_pathSourceFile);
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.DeleteFile(pathId)
|
||||
.Returns(Result.Deleted);
|
||||
@@ -1198,7 +1198,7 @@ public class FileServiceTests
|
||||
public void DeleteFileWithFileSystemPathId_WhenFileProviderServiceReturnsError_ShouldPropagateError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceFile);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(_pathSourceFile);
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.DeleteFile(pathId)
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
+11
-11
@@ -4,10 +4,10 @@ using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.PhotoLibrary;
|
||||
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.Entities.Fixtures;
|
||||
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.ValueObjects.Fixtures;
|
||||
using NSubstitute;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -46,7 +46,7 @@ public class FileTypeServiceTests
|
||||
public async Task GetImageTypeAsync_WithValidFile_ShouldReturnCorrectImageType()
|
||||
{
|
||||
// Arrange
|
||||
File file = _fileFixture.CreateFile();
|
||||
File file = _fileFixture.Create();
|
||||
byte[] pngHeader = [137, 80, 78, 71, 13, 10, 26, 10];
|
||||
byte[] fileContent = [.. pngHeader, .. Enumerable.Repeat<byte>(0, 100)];
|
||||
|
||||
@@ -66,7 +66,7 @@ public class FileTypeServiceTests
|
||||
public async Task GetImageTypeAsync_WithUnauthorizedAccess_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
File file = _fileFixture.CreateFile();
|
||||
File file = _fileFixture.Create();
|
||||
|
||||
SetupMockFileSystem(file.Id, []);
|
||||
sut = new FileTypeService(_mockFileSystem, _mockFileSystemPermissionsService);
|
||||
@@ -85,7 +85,7 @@ public class FileTypeServiceTests
|
||||
public async Task GetImageTypeAsync_WithSmallFile_ShouldReturnNone()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\test.jpg");
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(@"C:\test.jpg");
|
||||
byte[] fileContent = [1, 2, 3]; // Less than BUFFER_SIZE
|
||||
|
||||
SetupMockFileSystem(pathId, fileContent);
|
||||
@@ -104,7 +104,7 @@ public class FileTypeServiceTests
|
||||
public async Task GetImageTypeAsync_WithSvgFile_ShouldReturnSvgType()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\test.svg");
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(@"C:\test.svg");
|
||||
string svgContent = "<svg xmlns=\"http://www.w3.org/2000/svg\"></svg>";
|
||||
byte[] fileContent = Encoding.UTF8.GetBytes(svgContent);
|
||||
|
||||
@@ -124,7 +124,7 @@ public class FileTypeServiceTests
|
||||
public async Task GetImageTypeAsync_WithTgaFile_ShouldReturnTgaType()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\test.tga");
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(@"C:\test.tga");
|
||||
byte[] tgaHeader = new byte[18];
|
||||
tgaHeader[2] = 2; // Set image type to 2 (uncompressed true-color image)
|
||||
byte[] fileContent = [.. tgaHeader, .. Enumerable.Repeat<byte>(0, 100)];
|
||||
@@ -146,8 +146,8 @@ public class FileTypeServiceTests
|
||||
public async Task GetImageTypeAsync_WithUnknownImageType_ShouldReturnNone()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\test.unknown");
|
||||
byte[] fileContent = Enumerable.Repeat<byte>(0, 100).ToArray();
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(@"C:\test.unknown");
|
||||
byte[] fileContent = [.. Enumerable.Repeat<byte>(0, 100)];
|
||||
|
||||
SetupMockFileSystem(pathId, fileContent);
|
||||
sut = new FileTypeService(_mockFileSystem, _mockFileSystemPermissionsService);
|
||||
@@ -175,7 +175,7 @@ public class FileTypeServiceTests
|
||||
public async Task GetImageTypeAsync_WithSvgFileStartingWithXmlDeclaration_ShouldReturnSvgType()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\test.svg");
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(@"C:\test.svg");
|
||||
string svgContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<svg xmlns=\"http://www.w3.org/2000/svg\"></svg>";
|
||||
byte[] fileContent = Encoding.UTF8.GetBytes(svgContent);
|
||||
|
||||
@@ -212,7 +212,7 @@ public class FileTypeServiceTests
|
||||
public async Task GetImageTypeAsync_WithVariousImageTypes_ShouldIdentifyCorrectly(byte[] header, ImageType expectedType, string testName)
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId($@"C:\test.{testName.ToLower()}");
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create($@"C:\test.{testName.ToLower()}");
|
||||
byte[] fileContent = [.. header, .. Enumerable.Repeat<byte>(0, 100)];
|
||||
|
||||
SetupMockFileSystem(pathId, fileContent);
|
||||
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.PhotoLibrary;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.Formats;
|
||||
using SixLabors.ImageSharp.Formats.Bmp;
|
||||
using SixLabors.ImageSharp.Formats.Gif;
|
||||
using SixLabors.ImageSharp.Formats.Jpeg;
|
||||
using SixLabors.ImageSharp.Formats.Png;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.Services.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ImageType"/> enum.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ImageTypeFixture : TheoryData<ImageType, byte[]>
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ImageTypeFixture"/> class.
|
||||
/// </summary>
|
||||
public ImageTypeFixture()
|
||||
{
|
||||
Add(ImageType.JPEG, CreateImage(new JpegEncoder()));
|
||||
Add(ImageType.PNG, CreateImage(new PngEncoder()));
|
||||
Add(ImageType.BMP, CreateImage(new BmpEncoder()));
|
||||
Add(ImageType.GIF, CreateImage(new GifEncoder()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a byte array representing a thumbnail fixture.
|
||||
/// </summary>
|
||||
/// <param name="encoder">The encoder used for the image.</param>
|
||||
/// <returns>The byte array of the created image.</returns>
|
||||
private static byte[] CreateImage(IImageEncoder encoder)
|
||||
{
|
||||
using Image<Rgba32> image = new(10, 10);
|
||||
using MemoryStream ms = new();
|
||||
image.Save(ms, encoder);
|
||||
return ms.ToArray();
|
||||
}
|
||||
}
|
||||
+18
-18
@@ -5,7 +5,7 @@ using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.File
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Path;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.ValueObjects.Fixtures;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using NSubstitute;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -47,7 +47,7 @@ public class PathServiceTests
|
||||
{
|
||||
// Arrange
|
||||
string validPath = @"C:\ValidPath";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(validPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(validPath);
|
||||
_mockPathStrategy.IsValidPath(pathId).Returns(true);
|
||||
|
||||
// Act
|
||||
@@ -63,7 +63,7 @@ public class PathServiceTests
|
||||
{
|
||||
// Arrange
|
||||
string invalidPath = @"C:\Invalid\*Path";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(invalidPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(invalidPath);
|
||||
_mockPathStrategy.IsValidPath(pathId).Returns(false);
|
||||
|
||||
// Act
|
||||
@@ -107,7 +107,7 @@ public class PathServiceTests
|
||||
{
|
||||
// Arrange
|
||||
string existingPath = @"C:\ExistingPath";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(existingPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(existingPath);
|
||||
_mockPathStrategy.Exists(pathId).Returns(true);
|
||||
|
||||
// Act
|
||||
@@ -123,7 +123,7 @@ public class PathServiceTests
|
||||
{
|
||||
// Arrange
|
||||
string existingPath = @"C:\ExistingPath";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(existingPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(existingPath);
|
||||
_mockPathStrategy.Exists(pathId, true).Returns(true);
|
||||
|
||||
// Act
|
||||
@@ -139,7 +139,7 @@ public class PathServiceTests
|
||||
{
|
||||
// Arrange
|
||||
string existingPath = @"C:\ExistingPath";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(existingPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(existingPath);
|
||||
_mockPathStrategy.Exists(pathId, false).Returns(false);
|
||||
|
||||
// Act
|
||||
@@ -155,7 +155,7 @@ public class PathServiceTests
|
||||
{
|
||||
// Arrange
|
||||
string nonExistingPath = @"C:\NonExistingPath";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(nonExistingPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(nonExistingPath);
|
||||
_mockPathStrategy.Exists(pathId).Returns(false);
|
||||
|
||||
// Act
|
||||
@@ -200,8 +200,8 @@ public class PathServiceTests
|
||||
// Arrange
|
||||
string path = @"C:\BaseDir";
|
||||
string name = "SubDir";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId combinedPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\BaseDir\SubDir");
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
FileSystemPathId combinedPathId = _fileSystemPathIdFixture.Create(@"C:\BaseDir\SubDir");
|
||||
_mockPathStrategy.CombinePath(pathId, name).Returns(Result.From(combinedPathId));
|
||||
|
||||
// Act
|
||||
@@ -235,7 +235,7 @@ public class PathServiceTests
|
||||
// Arrange
|
||||
string path = @"C:\BaseDir";
|
||||
string name = "Invalid*Name";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
_mockPathStrategy.CombinePath(pathId, name).Returns(Errors.FileSystemManagement.InvalidPath);
|
||||
|
||||
// Act
|
||||
@@ -268,7 +268,7 @@ public class PathServiceTests
|
||||
{
|
||||
// Arrange
|
||||
string validPath = @"C:\ValidPath\SubDir";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(validPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(validPath);
|
||||
List<PathSegment> expectedSegments = _pathSegmentFixture.CreateMany();
|
||||
_mockPathStrategy.ParsePath(pathId).Returns(Result.From(expectedSegments.AsEnumerable()));
|
||||
|
||||
@@ -301,7 +301,7 @@ public class PathServiceTests
|
||||
{
|
||||
// Arrange
|
||||
string path = @"C:\InvalidPath\*SubDir";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
_mockPathStrategy.ParsePath(pathId).Returns(Errors.FileSystemManagement.InvalidPath);
|
||||
|
||||
// Act
|
||||
@@ -333,7 +333,7 @@ public class PathServiceTests
|
||||
{
|
||||
// Arrange
|
||||
string validPath = @"C:\ValidPath\SubDir";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(validPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(validPath);
|
||||
List<PathSegment> expectedSegments = _pathSegmentFixture.CreateMany(2); // Assuming parent path has 2 segments
|
||||
_mockPathStrategy.GoUpOneLevel(pathId).Returns(Result.From(expectedSegments.AsEnumerable()));
|
||||
|
||||
@@ -351,7 +351,7 @@ public class PathServiceTests
|
||||
{
|
||||
// Arrange
|
||||
string rootPath = @"C:\";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(rootPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(rootPath);
|
||||
List<PathSegment> emptySegmentList = [];
|
||||
_mockPathStrategy.GoUpOneLevel(pathId).Returns(Result.From(emptySegmentList.AsEnumerable()));
|
||||
|
||||
@@ -384,7 +384,7 @@ public class PathServiceTests
|
||||
{
|
||||
// Arrange
|
||||
string path = @"C:\InvalidPath\*SubDir";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
_mockPathStrategy.GoUpOneLevel(pathId).Returns(Errors.FileSystemManagement.InvalidPath);
|
||||
|
||||
// Act
|
||||
@@ -463,8 +463,8 @@ public class PathServiceTests
|
||||
{
|
||||
// Arrange
|
||||
string validPath = @"C:\ValidPath\SubDir";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(validPath);
|
||||
PathSegment expectedRootSegment = _pathSegmentFixture.CreatePathSegment(name: "C:", isDirectory: false, isDrive: true);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(validPath);
|
||||
PathSegment expectedRootSegment = _pathSegmentFixture.Create(name: "C:", isDirectory: false, isDrive: true);
|
||||
_mockPathStrategy.GetPathRoot(pathId).Returns(Result.From(expectedRootSegment));
|
||||
|
||||
// Act
|
||||
@@ -496,7 +496,7 @@ public class PathServiceTests
|
||||
{
|
||||
// Arrange
|
||||
string path = @"C:\InvalidPath\*SubDir";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
_mockPathStrategy.GetPathRoot(pathId).Returns(Errors.FileSystemManagement.InvalidPath);
|
||||
|
||||
// Act
|
||||
|
||||
+8
-8
@@ -4,9 +4,9 @@ using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Common.Enums.PhotoLibrary;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.PhotoLibrary;
|
||||
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.Services.Fixtures;
|
||||
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.ValueObjects.Fixtures;
|
||||
using NSubstitute;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.Formats.Jpeg;
|
||||
@@ -45,7 +45,7 @@ public class ThumbnailServiceTests
|
||||
// Arrange
|
||||
string path = @"C:\TestImage.jpg";
|
||||
int quality = 80;
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
|
||||
// Create a small valid JPEG image
|
||||
byte[] imageBytes;
|
||||
@@ -89,7 +89,7 @@ public class ThumbnailServiceTests
|
||||
public async Task GetThumbnailAsync_WhenFileTypeServiceReturnsError_ShouldPropagateError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\TestImage.jpg");
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(@"C:\TestImage.jpg");
|
||||
int quality = 80;
|
||||
|
||||
_mockEnvironmentContext.FileTypeService.GetImageTypeAsync(pathId, Arg.Any<CancellationToken>())
|
||||
@@ -107,7 +107,7 @@ public class ThumbnailServiceTests
|
||||
public async Task GetThumbnailAsync_WhenImageTypeIsNone_ShouldReturnNoThumbnailError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\TestFile.txt");
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(@"C:\TestFile.txt");
|
||||
int quality = 80;
|
||||
|
||||
_mockEnvironmentContext.FileTypeService.GetImageTypeAsync(pathId, Arg.Any<CancellationToken>())
|
||||
@@ -125,7 +125,7 @@ public class ThumbnailServiceTests
|
||||
public async Task GetThumbnailAsync_WhenFileProviderServiceReturnsError_ShouldPropagateError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\TestImage.jpg");
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(@"C:\TestImage.jpg");
|
||||
int quality = 80;
|
||||
|
||||
_mockEnvironmentContext.FileTypeService.GetImageTypeAsync(pathId, Arg.Any<CancellationToken>())
|
||||
@@ -146,7 +146,7 @@ public class ThumbnailServiceTests
|
||||
public async Task GetThumbnailAsync_WithDifferentImageTypes_ShouldReturnThumbnail(ImageType imageType, byte[] imageBytes)
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\TestImage");
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(@"C:\TestImage");
|
||||
int quality = 80;
|
||||
|
||||
_mockEnvironmentContext.FileTypeService.GetImageTypeAsync(pathId, Arg.Any<CancellationToken>())
|
||||
@@ -173,7 +173,7 @@ public class ThumbnailServiceTests
|
||||
public async Task GetThumbnailAsync_WithCancellation_ShouldThrowTaskCanceledException()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\TestImage.jpg");
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(@"C:\TestImage.jpg");
|
||||
int quality = 80;
|
||||
CancellationTokenSource cts = new();
|
||||
cts.Cancel();
|
||||
|
||||
+47
-47
@@ -3,7 +3,7 @@ using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Path;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.ValueObjects.Fixtures;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using NSubstitute;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -44,7 +44,7 @@ public class UnixPathStrategyTests
|
||||
public void IsValidPath_WithValidUnixPaths_ShouldReturnTrue(string path)
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
|
||||
// Act
|
||||
bool result = _sut.IsValidPath(pathId);
|
||||
@@ -61,7 +61,7 @@ public class UnixPathStrategyTests
|
||||
public void IsValidPath_WithInvalidUnixPaths_ShouldReturnFalse(string path)
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
|
||||
// Act
|
||||
bool result = _sut.IsValidPath(pathId);
|
||||
@@ -75,7 +75,7 @@ public class UnixPathStrategyTests
|
||||
{
|
||||
// Arrange
|
||||
string invalidPath = "/home/user/file\0name";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(invalidPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(invalidPath);
|
||||
|
||||
// Act
|
||||
bool result = _sut.IsValidPath(pathId);
|
||||
@@ -98,7 +98,7 @@ public class UnixPathStrategyTests
|
||||
public void IsValidPath_WithValidSpecialCharacters_ShouldReturnTrue(string path)
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
|
||||
// Act
|
||||
bool result = _sut.IsValidPath(pathId);
|
||||
@@ -112,7 +112,7 @@ public class UnixPathStrategyTests
|
||||
{
|
||||
// Arrange
|
||||
string longPath = "/" + string.Join("/", Enumerable.Repeat("a", 100));
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(longPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(longPath);
|
||||
|
||||
// Act
|
||||
bool result = _sut.IsValidPath(pathId);
|
||||
@@ -126,7 +126,7 @@ public class UnixPathStrategyTests
|
||||
{
|
||||
// Arrange
|
||||
string existingPath = "/home/user/existing_file.txt";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(existingPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(existingPath);
|
||||
|
||||
_mockFileSystem.Path.Exists(existingPath).Returns(true);
|
||||
_mockFileSystem.File.Exists(existingPath).Returns(true);
|
||||
@@ -144,7 +144,7 @@ public class UnixPathStrategyTests
|
||||
{
|
||||
// Arrange
|
||||
string existingPath = "/home/user/existing_file.txt";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(existingPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(existingPath);
|
||||
_mockFileSystem.Path.Exists(existingPath).Returns(true);
|
||||
_mockFileSystem.File.Exists(existingPath).Returns(true);
|
||||
IFileInfo mockFileInfo = Substitute.For<IFileInfo>();
|
||||
@@ -164,7 +164,7 @@ public class UnixPathStrategyTests
|
||||
{
|
||||
// Arrange
|
||||
string nonExistingPath = "/home/user/non_existing_file.txt";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(nonExistingPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(nonExistingPath);
|
||||
_mockFileSystem.Path.Exists(nonExistingPath).Returns(false);
|
||||
|
||||
// Act
|
||||
@@ -180,7 +180,7 @@ public class UnixPathStrategyTests
|
||||
{
|
||||
// Arrange
|
||||
string rootPath = "/";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(rootPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(rootPath);
|
||||
_mockFileSystem.Path.Exists(rootPath).Returns(true);
|
||||
|
||||
// Act
|
||||
@@ -196,7 +196,7 @@ public class UnixPathStrategyTests
|
||||
{
|
||||
// Arrange
|
||||
string directoryPath = "/home/user/documents/";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(directoryPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(directoryPath);
|
||||
_mockFileSystem.Path.Exists(directoryPath).Returns(true);
|
||||
_mockFileSystem.Directory.Exists(directoryPath).Returns(true);
|
||||
|
||||
@@ -213,7 +213,7 @@ public class UnixPathStrategyTests
|
||||
{
|
||||
// Arrange
|
||||
string filePath = "/home/user/documents/file.txt";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(filePath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(filePath);
|
||||
_mockFileSystem.Path.Exists(filePath).Returns(true);
|
||||
_mockFileSystem.File.Exists(filePath).Returns(true);
|
||||
|
||||
@@ -229,7 +229,7 @@ public class UnixPathStrategyTests
|
||||
public void CombinePath_WithValidPathAndName_ShouldReturnCombinedPath()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/home/user");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create("/home/user");
|
||||
string name = "documents";
|
||||
|
||||
// Act
|
||||
@@ -244,7 +244,7 @@ public class UnixPathStrategyTests
|
||||
public void CombinePath_WithTrailingSlashInPath_ShouldReturnCorrectlyCombinedPath()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/home/user/");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create("/home/user/");
|
||||
string name = "documents";
|
||||
|
||||
// Act
|
||||
@@ -259,7 +259,7 @@ public class UnixPathStrategyTests
|
||||
public void CombinePath_WithLeadingSlashInName_ShouldReturnCorrectlyCombinedPath()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/home/user");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create("/home/user");
|
||||
string name = "/documents";
|
||||
|
||||
// Act
|
||||
@@ -274,7 +274,7 @@ public class UnixPathStrategyTests
|
||||
public void CombinePath_WithEmptyName_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/home/user");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create("/home/user");
|
||||
string name = "";
|
||||
|
||||
// Act
|
||||
@@ -289,7 +289,7 @@ public class UnixPathStrategyTests
|
||||
public void CombinePath_WithNullName_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/home/user");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create("/home/user");
|
||||
string name = null!;
|
||||
|
||||
// Act
|
||||
@@ -304,7 +304,7 @@ public class UnixPathStrategyTests
|
||||
public void CombinePath_WithRootPath_ShouldReturnCorrectlyCombinedPath()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create("/");
|
||||
string name = "home";
|
||||
|
||||
// Act
|
||||
@@ -319,7 +319,7 @@ public class UnixPathStrategyTests
|
||||
public void ParsePath_WithValidUnixPath_ShouldReturnCorrectPathSegments()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/home/user/documents/file.txt");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create("/home/user/documents/file.txt");
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
@@ -327,18 +327,18 @@ public class UnixPathStrategyTests
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(5, result.Value.Count());
|
||||
Assert.Equal(_pathSegmentFixture.CreatePathSegment("/", false, true), result.Value.ElementAt(0));
|
||||
Assert.Equal(_pathSegmentFixture.CreatePathSegment("home", true, false), result.Value.ElementAt(1));
|
||||
Assert.Equal(_pathSegmentFixture.CreatePathSegment("user", true, false), result.Value.ElementAt(2));
|
||||
Assert.Equal(_pathSegmentFixture.CreatePathSegment("documents", true, false), result.Value.ElementAt(3));
|
||||
Assert.Equal(_pathSegmentFixture.CreatePathSegment("file.txt", false, false), result.Value.ElementAt(4));
|
||||
Assert.Equal(_pathSegmentFixture.Create("/", false, true), result.Value.ElementAt(0));
|
||||
Assert.Equal(_pathSegmentFixture.Create("home", true, false), result.Value.ElementAt(1));
|
||||
Assert.Equal(_pathSegmentFixture.Create("user", true, false), result.Value.ElementAt(2));
|
||||
Assert.Equal(_pathSegmentFixture.Create("documents", true, false), result.Value.ElementAt(3));
|
||||
Assert.Equal(_pathSegmentFixture.Create("file.txt", false, false), result.Value.ElementAt(4));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParsePath_WithRootPath_ShouldReturnSingleRootSegment()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create("/");
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
@@ -346,14 +346,14 @@ public class UnixPathStrategyTests
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Single(result.Value);
|
||||
Assert.Equal(_pathSegmentFixture.CreatePathSegment("/", false, true), result.Value.Single());
|
||||
Assert.Equal(_pathSegmentFixture.Create("/", false, true), result.Value.Single());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParsePath_WithTrailingSlash_ShouldTreatLastSegmentAsDirectory()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/home/user/documents/");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create("/home/user/documents/");
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
@@ -361,14 +361,14 @@ public class UnixPathStrategyTests
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(4, result.Value.Count());
|
||||
Assert.Equal(_pathSegmentFixture.CreatePathSegment("documents", true, false), result.Value.Last());
|
||||
Assert.Equal(_pathSegmentFixture.Create("documents", true, false), result.Value.Last());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParsePath_WithRelativePath_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("home/user");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create("home/user");
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
@@ -382,7 +382,7 @@ public class UnixPathStrategyTests
|
||||
public void ParsePath_WithPathContainingDots_ShouldParseCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/home/user/file.with.dots.txt");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create("/home/user/file.with.dots.txt");
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
@@ -390,14 +390,14 @@ public class UnixPathStrategyTests
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(4, result.Value.Count());
|
||||
Assert.Equal(_pathSegmentFixture.CreatePathSegment("file.with.dots.txt", false, false), result.Value.Last());
|
||||
Assert.Equal(_pathSegmentFixture.Create("file.with.dots.txt", false, false), result.Value.Last());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GoUpOneLevel_WithValidPath_ShouldReturnParentPath()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/home/user/documents");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create("/home/user/documents");
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
@@ -405,16 +405,16 @@ public class UnixPathStrategyTests
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(3, result.Value.Count());
|
||||
Assert.Equal(_pathSegmentFixture.CreatePathSegment("/", false, true), result.Value.ElementAt(0));
|
||||
Assert.Equal(_pathSegmentFixture.CreatePathSegment("home", true, false), result.Value.ElementAt(1));
|
||||
Assert.Equal(_pathSegmentFixture.CreatePathSegment("user", true, false), result.Value.ElementAt(2));
|
||||
Assert.Equal(_pathSegmentFixture.Create("/", false, true), result.Value.ElementAt(0));
|
||||
Assert.Equal(_pathSegmentFixture.Create("home", true, false), result.Value.ElementAt(1));
|
||||
Assert.Equal(_pathSegmentFixture.Create("user", true, false), result.Value.ElementAt(2));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GoUpOneLevel_WithRootPath_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create("/");
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
@@ -428,7 +428,7 @@ public class UnixPathStrategyTests
|
||||
public void GoUpOneLevel_WithTrailingSlash_ShouldReturnCorrectParentPath()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/home/user/");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create("/home/user/");
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
@@ -436,15 +436,15 @@ public class UnixPathStrategyTests
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(2, result.Value.Count());
|
||||
Assert.Equal(_pathSegmentFixture.CreatePathSegment("/", false, true), result.Value.ElementAt(0));
|
||||
Assert.Equal(_pathSegmentFixture.CreatePathSegment("home", true, false), result.Value.ElementAt(1));
|
||||
Assert.Equal(_pathSegmentFixture.Create("/", false, true), result.Value.ElementAt(0));
|
||||
Assert.Equal(_pathSegmentFixture.Create("home", true, false), result.Value.ElementAt(1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GoUpOneLevel_WithInvalidPath_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("invalid/path");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create("invalid/path");
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
@@ -458,7 +458,7 @@ public class UnixPathStrategyTests
|
||||
public void GoUpOneLevel_WithSingleLevelPath_ShouldReturnRootPath()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/home");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create("/home");
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
@@ -466,7 +466,7 @@ public class UnixPathStrategyTests
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Single(result.Value);
|
||||
Assert.Equal(_pathSegmentFixture.CreatePathSegment("/", false, true), result.Value.Single());
|
||||
Assert.Equal(_pathSegmentFixture.Create("/", false, true), result.Value.Single());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -513,35 +513,35 @@ public class UnixPathStrategyTests
|
||||
public void GetPathRoot_WithValidUnixPath_ShouldReturnRootSegment()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/home/user/documents");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create("/home/user/documents");
|
||||
|
||||
// Act
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(_pathSegmentFixture.CreatePathSegment("/", false, true), result.Value);
|
||||
Assert.Equal(_pathSegmentFixture.Create("/", false, true), result.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetPathRoot_WithRootPath_ShouldReturnRootSegment()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create("/");
|
||||
|
||||
// Act
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(_pathSegmentFixture.CreatePathSegment("/", false, true), result.Value);
|
||||
Assert.Equal(_pathSegmentFixture.Create("/", false, true), result.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetPathRoot_WithInvalidPath_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("home/user");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create("home/user");
|
||||
|
||||
// Act
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
|
||||
+76
-76
@@ -3,7 +3,7 @@ using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Path;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.ValueObjects.Fixtures;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using NSubstitute;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -44,7 +44,7 @@ public class WindowsPathStrategyTests
|
||||
public void IsValidPath_WithValidWindowsPaths_ShouldReturnTrue(string path)
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
|
||||
// Act
|
||||
bool result = _sut.IsValidPath(pathId);
|
||||
@@ -62,7 +62,7 @@ public class WindowsPathStrategyTests
|
||||
public void IsValidPath_WithInvalidWindowsPaths_ShouldReturnFalse(string path)
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
|
||||
// Act
|
||||
bool result = _sut.IsValidPath(pathId);
|
||||
@@ -76,7 +76,7 @@ public class WindowsPathStrategyTests
|
||||
{
|
||||
// Arrange
|
||||
string invalidPath = @"C:\Users\User\file<name>";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(invalidPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(invalidPath);
|
||||
|
||||
// Act
|
||||
bool result = _sut.IsValidPath(pathId);
|
||||
@@ -94,7 +94,7 @@ public class WindowsPathStrategyTests
|
||||
public void IsValidPath_WithValidSpecialCharacters_ShouldReturnTrue(string path)
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
|
||||
// Act
|
||||
bool result = _sut.IsValidPath(pathId);
|
||||
@@ -108,7 +108,7 @@ public class WindowsPathStrategyTests
|
||||
{
|
||||
// Arrange
|
||||
string longPath = @"C:\" + string.Join("\\", Enumerable.Repeat("a", 100));
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(longPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(longPath);
|
||||
|
||||
// Act
|
||||
bool result = _sut.IsValidPath(pathId);
|
||||
@@ -124,7 +124,7 @@ public class WindowsPathStrategyTests
|
||||
public void IsValidPath_WithValidUNCPaths_ShouldReturnTrue(string path)
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
|
||||
// Act
|
||||
bool result = _sut.IsValidPath(pathId);
|
||||
@@ -140,7 +140,7 @@ public class WindowsPathStrategyTests
|
||||
public void IsValidPath_WithInvalidUNCPaths_ShouldReturnFalse(string path)
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
|
||||
// Act
|
||||
bool result = _sut.IsValidPath(pathId);
|
||||
@@ -154,7 +154,7 @@ public class WindowsPathStrategyTests
|
||||
{
|
||||
// Arrange
|
||||
string existingPath = @"C:\Users\User\existing_file.txt";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(existingPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(existingPath);
|
||||
_mockFileSystem.Path.Exists(existingPath).Returns(true);
|
||||
_mockFileSystem.File.Exists(existingPath).Returns(true);
|
||||
|
||||
@@ -171,7 +171,7 @@ public class WindowsPathStrategyTests
|
||||
{
|
||||
// Arrange
|
||||
string existingPath = @"C:\Users\User\existing_file.txt";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(existingPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(existingPath);
|
||||
_mockFileSystem.Path.Exists(existingPath).Returns(true);
|
||||
_mockFileSystem.File.Exists(existingPath).Returns(true);
|
||||
IFileInfo mockFileInfo = Substitute.For<IFileInfo>();
|
||||
@@ -191,7 +191,7 @@ public class WindowsPathStrategyTests
|
||||
{
|
||||
// Arrange
|
||||
string nonExistingPath = @"C:\Users\User\non_existing_file.txt";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(nonExistingPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(nonExistingPath);
|
||||
_mockFileSystem.Path.Exists(nonExistingPath).Returns(false);
|
||||
|
||||
// Act
|
||||
@@ -207,7 +207,7 @@ public class WindowsPathStrategyTests
|
||||
{
|
||||
// Arrange
|
||||
string rootPath = @"C:\";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(rootPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(rootPath);
|
||||
_mockFileSystem.Path.Exists(rootPath).Returns(true);
|
||||
|
||||
// Act
|
||||
@@ -223,7 +223,7 @@ public class WindowsPathStrategyTests
|
||||
{
|
||||
// Arrange
|
||||
string directoryPath = @"C:\Users\User\Documents\";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(directoryPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(directoryPath);
|
||||
_mockFileSystem.Path.Exists(directoryPath).Returns(true);
|
||||
_mockFileSystem.Directory.Exists(directoryPath).Returns(true);
|
||||
|
||||
@@ -240,7 +240,7 @@ public class WindowsPathStrategyTests
|
||||
{
|
||||
// Arrange
|
||||
string filePath = @"C:\Users\User\Documents\file.txt";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(filePath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(filePath);
|
||||
_mockFileSystem.Path.Exists(filePath).Returns(true);
|
||||
_mockFileSystem.File.Exists(filePath).Returns(true);
|
||||
|
||||
@@ -257,7 +257,7 @@ public class WindowsPathStrategyTests
|
||||
{
|
||||
// Arrange
|
||||
string uncPath = @"\\server\share\folder\file.txt";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(uncPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(uncPath);
|
||||
_mockFileSystem.Path.Exists(uncPath).Returns(true);
|
||||
|
||||
// Act
|
||||
@@ -272,7 +272,7 @@ public class WindowsPathStrategyTests
|
||||
public void CombinePath_WithValidPathAndName_ShouldReturnCombinedPath()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\Users\User");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"C:\Users\User");
|
||||
string name = "Documents";
|
||||
|
||||
// Act
|
||||
@@ -287,7 +287,7 @@ public class WindowsPathStrategyTests
|
||||
public void CombinePath_WithTrailingBackslashInPath_ShouldReturnCorrectlyCombinedPath()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\Users\User\");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"C:\Users\User\");
|
||||
string name = "Documents";
|
||||
|
||||
// Act
|
||||
@@ -302,7 +302,7 @@ public class WindowsPathStrategyTests
|
||||
public void CombinePath_WithLeadingBackslashInName_ShouldReturnCorrectlyCombinedPath()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\Users\User");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"C:\Users\User");
|
||||
string name = @"\Documents";
|
||||
|
||||
// Act
|
||||
@@ -317,7 +317,7 @@ public class WindowsPathStrategyTests
|
||||
public void CombinePath_WithNullName_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\Users\User");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"C:\Users\User");
|
||||
string name = null!;
|
||||
|
||||
// Act
|
||||
@@ -332,7 +332,7 @@ public class WindowsPathStrategyTests
|
||||
public void CombinePath_WithRootPath_ShouldReturnCorrectlyCombinedPath()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"C:\");
|
||||
string name = "Users";
|
||||
|
||||
// Act
|
||||
@@ -347,7 +347,7 @@ public class WindowsPathStrategyTests
|
||||
public void CombinePath_WithUNCPath_ShouldReturnCorrectlyCombinedPath()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"\\server\share");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"\\server\share");
|
||||
string name = "folder";
|
||||
|
||||
// Act
|
||||
@@ -362,7 +362,7 @@ public class WindowsPathStrategyTests
|
||||
public void ParsePath_WithValidWindowsPath_ShouldReturnCorrectPathSegments()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\Users\User\Documents\file.txt");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"C:\Users\User\Documents\file.txt");
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
@@ -370,18 +370,18 @@ public class WindowsPathStrategyTests
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(5, result.Value.Count());
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("C:", false, true), result.Value.ElementAt(0));
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("Users", true, false), result.Value.ElementAt(1));
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("User", true, false), result.Value.ElementAt(2));
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("Documents", true, false), result.Value.ElementAt(3));
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("file.txt", false, false), result.Value.ElementAt(4));
|
||||
Assert.Equivalent(_pathSegmentFixture.Create("C:", false, true), result.Value.ElementAt(0));
|
||||
Assert.Equivalent(_pathSegmentFixture.Create("Users", true, false), result.Value.ElementAt(1));
|
||||
Assert.Equivalent(_pathSegmentFixture.Create("User", true, false), result.Value.ElementAt(2));
|
||||
Assert.Equivalent(_pathSegmentFixture.Create("Documents", true, false), result.Value.ElementAt(3));
|
||||
Assert.Equivalent(_pathSegmentFixture.Create("file.txt", false, false), result.Value.ElementAt(4));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParsePath_WithRootPath_ShouldReturnSingleRootSegment()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"C:\");
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
@@ -389,14 +389,14 @@ public class WindowsPathStrategyTests
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Single(result.Value);
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("C:", false, true), result.Value.Single());
|
||||
Assert.Equivalent(_pathSegmentFixture.Create("C:", false, true), result.Value.Single());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParsePath_WithTrailingBackslash_ShouldTreatLastSegmentAsDirectory()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\Users\User\Documents\");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"C:\Users\User\Documents\");
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
@@ -404,14 +404,14 @@ public class WindowsPathStrategyTests
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(4, result.Value.Count());
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("Documents", true, false), result.Value.Last());
|
||||
Assert.Equivalent(_pathSegmentFixture.Create("Documents", true, false), result.Value.Last());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParsePath_WithRelativePath_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"Users\User");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"Users\User");
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
@@ -425,7 +425,7 @@ public class WindowsPathStrategyTests
|
||||
public void ParsePath_WithPathContainingDots_ShouldParseCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\Users\User\file.with.dots.txt");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"C:\Users\User\file.with.dots.txt");
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
@@ -433,14 +433,14 @@ public class WindowsPathStrategyTests
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(4, result.Value.Count());
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("file.with.dots.txt", false, false), result.Value.Last());
|
||||
Assert.Equivalent(_pathSegmentFixture.Create("file.with.dots.txt", false, false), result.Value.Last());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParsePath_WithUNCPath_ShouldReturnCorrectPathSegments()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"\\server\share\folder\file.txt");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"\\server\share\folder\file.txt");
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
@@ -448,18 +448,18 @@ public class WindowsPathStrategyTests
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(5, result.Value.Count());
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment(@"\\", false, true), result.Value.ElementAt(0));
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("server", true, false), result.Value.ElementAt(1));
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("share", true, false), result.Value.ElementAt(2));
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("folder", true, false), result.Value.ElementAt(3));
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("file.txt", false, false), result.Value.ElementAt(4));
|
||||
Assert.Equivalent(_pathSegmentFixture.Create(@"\\", false, true), result.Value.ElementAt(0));
|
||||
Assert.Equivalent(_pathSegmentFixture.Create("server", true, false), result.Value.ElementAt(1));
|
||||
Assert.Equivalent(_pathSegmentFixture.Create("share", true, false), result.Value.ElementAt(2));
|
||||
Assert.Equivalent(_pathSegmentFixture.Create("folder", true, false), result.Value.ElementAt(3));
|
||||
Assert.Equivalent(_pathSegmentFixture.Create("file.txt", false, false), result.Value.ElementAt(4));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GoUpOneLevel_WithValidPath_ShouldReturnParentPath()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\Users\User\Documents");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"C:\Users\User\Documents");
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
@@ -467,16 +467,16 @@ public class WindowsPathStrategyTests
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(3, result.Value.Count());
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("C:", false, true), result.Value.ElementAt(0));
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("Users", true, false), result.Value.ElementAt(1));
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("User", true, false), result.Value.ElementAt(2));
|
||||
Assert.Equivalent(_pathSegmentFixture.Create("C:", false, true), result.Value.ElementAt(0));
|
||||
Assert.Equivalent(_pathSegmentFixture.Create("Users", true, false), result.Value.ElementAt(1));
|
||||
Assert.Equivalent(_pathSegmentFixture.Create("User", true, false), result.Value.ElementAt(2));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GoUpOneLevel_WithRootPath_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"C:\");
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
@@ -490,7 +490,7 @@ public class WindowsPathStrategyTests
|
||||
public void GoUpOneLevel_WithTrailingBackslash_ShouldReturnCorrectParentPath()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\Users\User\");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"C:\Users\User\");
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
@@ -498,15 +498,15 @@ public class WindowsPathStrategyTests
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(2, result.Value.Count());
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("C:", false, true), result.Value.ElementAt(0));
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("Users", true, false), result.Value.ElementAt(1));
|
||||
Assert.Equivalent(_pathSegmentFixture.Create("C:", false, true), result.Value.ElementAt(0));
|
||||
Assert.Equivalent(_pathSegmentFixture.Create("Users", true, false), result.Value.ElementAt(1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GoUpOneLevel_WithInvalidPath_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"invalid\path");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"invalid\path");
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
@@ -520,7 +520,7 @@ public class WindowsPathStrategyTests
|
||||
public void GoUpOneLevel_WithSingleLevelPath_ShouldReturnRootPath()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\Users");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"C:\Users");
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
@@ -528,14 +528,14 @@ public class WindowsPathStrategyTests
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Single(result.Value);
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("C:", false, true), result.Value.Single());
|
||||
Assert.Equivalent(_pathSegmentFixture.Create("C:", false, true), result.Value.Single());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GoUpOneLevel_WithUNCPath_ShouldReturnParentPath()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"\\server\share\folder\subfolder");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"\\server\share\folder\subfolder");
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
@@ -543,17 +543,17 @@ public class WindowsPathStrategyTests
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(4, result.Value.Count());
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment(@"\\", false, true), result.Value.ElementAt(0));
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("server", true, false), result.Value.ElementAt(1));
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("share", true, false), result.Value.ElementAt(2));
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("folder", true, false), result.Value.ElementAt(3));
|
||||
Assert.Equivalent(_pathSegmentFixture.Create(@"\\", false, true), result.Value.ElementAt(0));
|
||||
Assert.Equivalent(_pathSegmentFixture.Create("server", true, false), result.Value.ElementAt(1));
|
||||
Assert.Equivalent(_pathSegmentFixture.Create("share", true, false), result.Value.ElementAt(2));
|
||||
Assert.Equivalent(_pathSegmentFixture.Create("folder", true, false), result.Value.ElementAt(3));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GoUpOneLevel_WithUNCRootPath_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"\\server\share");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"\\server\share");
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
@@ -567,7 +567,7 @@ public class WindowsPathStrategyTests
|
||||
public void GoUpOneLevel_WithUNCPathWithOneFolder_ShouldReturnUNCRoot()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"\\server\share\folder");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"\\server\share\folder");
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
@@ -575,16 +575,16 @@ public class WindowsPathStrategyTests
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(3, result.Value.Count());
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment(@"\\", false, true), result.Value.ElementAt(0));
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("server", true, false), result.Value.ElementAt(1));
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("share", true, false), result.Value.ElementAt(2));
|
||||
Assert.Equivalent(_pathSegmentFixture.Create(@"\\", false, true), result.Value.ElementAt(0));
|
||||
Assert.Equivalent(_pathSegmentFixture.Create("server", true, false), result.Value.ElementAt(1));
|
||||
Assert.Equivalent(_pathSegmentFixture.Create("share", true, false), result.Value.ElementAt(2));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GoUpOneLevel_WithDriveRootAndBackslash_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"C:\");
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
@@ -631,35 +631,35 @@ public class WindowsPathStrategyTests
|
||||
public void GetPathRoot_WithValidWindowsPath_ShouldReturnRootSegment()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\Users\User\Documents");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"C:\Users\User\Documents");
|
||||
|
||||
// Act
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("C:\\", true, true), result.Value);
|
||||
Assert.Equivalent(_pathSegmentFixture.Create("C:\\", true, true), result.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetPathRoot_WithRootPath_ShouldReturnRootSegment()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"C:\");
|
||||
|
||||
// Act
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("C:\\", true, true), result.Value);
|
||||
Assert.Equivalent(_pathSegmentFixture.Create("C:\\", true, true), result.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetPathRoot_WithInvalidPath_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"InvalidFolder");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"InvalidFolder");
|
||||
|
||||
// Act
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
@@ -673,21 +673,21 @@ public class WindowsPathStrategyTests
|
||||
public void GetPathRoot_WithUNCPath_ShouldReturnUNCRootSegment()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"\\server\share\folder");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"\\server\share\folder");
|
||||
|
||||
// Act
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment(@"\\server\share\", true, false), result.Value);
|
||||
Assert.Equivalent(_pathSegmentFixture.Create(@"\\server\share\", true, false), result.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetPathRoot_WithInvalidUNCPath_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"\\");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"\\");
|
||||
|
||||
// Act
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
@@ -701,7 +701,7 @@ public class WindowsPathStrategyTests
|
||||
public void GetPathRoot_WithUNCPathWithoutShare_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"\\server");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"\\server");
|
||||
|
||||
// Act
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
@@ -715,7 +715,7 @@ public class WindowsPathStrategyTests
|
||||
public void GetPathRoot_WithNonDriveNonUNCPath_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"InvalidPath");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"InvalidPath");
|
||||
|
||||
// Act
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
@@ -729,7 +729,7 @@ public class WindowsPathStrategyTests
|
||||
public void GetPathRoot_WithUNCPathMissingServerName_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"\\");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"\\");
|
||||
|
||||
// Act
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
@@ -743,21 +743,21 @@ public class WindowsPathStrategyTests
|
||||
public void GetPathRoot_WithUNCPathWithoutThirdBackslash_ShouldReturnServerAndShare()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"\\server\share");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"\\server\share");
|
||||
|
||||
// Act
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment(@"\\server\share\", true, false), result.Value);
|
||||
Assert.Equivalent(_pathSegmentFixture.Create(@"\\server\share\", true, false), result.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetPathRoot_WithNeitherUNCNorDrivePath_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"invalid\path");
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(@"invalid\path");
|
||||
|
||||
// Act
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.Strategies.Platform.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture interface for non existing platform context.
|
||||
/// </summary>
|
||||
public interface INonExistentPlatformContextFixture : IPlatformContext
|
||||
{
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Path;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
|
||||
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.Strategies.Platform.Fixtures;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
+13
-13
@@ -2,7 +2,7 @@
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.ValueObjects.Fixtures;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
@@ -57,8 +57,8 @@ public class FileSystemPathIdTests
|
||||
{
|
||||
// Arrange
|
||||
string path = @"C:\TestDir\file.txt";
|
||||
FileSystemPathId id1 = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId id2 = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId id1 = _fileSystemPathIdFixture.Create(path);
|
||||
FileSystemPathId id2 = _fileSystemPathIdFixture.Create(path);
|
||||
|
||||
// Act
|
||||
bool result = id1.Equals(id2);
|
||||
@@ -71,8 +71,8 @@ public class FileSystemPathIdTests
|
||||
public void Equals_WithDifferentPath_ShouldReturnFalse()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId id1 = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\TestDir\file1.txt");
|
||||
FileSystemPathId id2 = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\TestDir\file2.txt");
|
||||
FileSystemPathId id1 = _fileSystemPathIdFixture.Create(@"C:\TestDir\file1.txt");
|
||||
FileSystemPathId id2 = _fileSystemPathIdFixture.Create(@"C:\TestDir\file2.txt");
|
||||
|
||||
// Act
|
||||
bool result = id1.Equals(id2);
|
||||
@@ -86,8 +86,8 @@ public class FileSystemPathIdTests
|
||||
{
|
||||
// Arrange
|
||||
string path = @"C:\TestDir\file.txt";
|
||||
FileSystemPathId id1 = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId id2 = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId id1 = _fileSystemPathIdFixture.Create(path);
|
||||
FileSystemPathId id2 = _fileSystemPathIdFixture.Create(path);
|
||||
|
||||
// Act
|
||||
int hashCode1 = id1.GetHashCode();
|
||||
@@ -101,8 +101,8 @@ public class FileSystemPathIdTests
|
||||
public void GetHashCode_WithDifferentPath_ShouldReturnDifferentHashCode()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId id1 = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\TestDir\file1.txt");
|
||||
FileSystemPathId id2 = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\TestDir\file2.txt");
|
||||
FileSystemPathId id1 = _fileSystemPathIdFixture.Create(@"C:\TestDir\file1.txt");
|
||||
FileSystemPathId id2 = _fileSystemPathIdFixture.Create(@"C:\TestDir\file2.txt");
|
||||
|
||||
// Act
|
||||
int hashCode1 = id1.GetHashCode();
|
||||
@@ -117,8 +117,8 @@ public class FileSystemPathIdTests
|
||||
{
|
||||
// Arrange
|
||||
string path = @"C:\TestDir\file.txt";
|
||||
FileSystemPathId id1 = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId id2 = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId id1 = _fileSystemPathIdFixture.Create(path);
|
||||
FileSystemPathId id2 = _fileSystemPathIdFixture.Create(path);
|
||||
|
||||
// Act
|
||||
bool result = id1 == id2;
|
||||
@@ -131,8 +131,8 @@ public class FileSystemPathIdTests
|
||||
public void InequalityOperator_WithDifferentPath_ShouldReturnTrue()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId id1 = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\TestDir\file1.txt");
|
||||
FileSystemPathId id2 = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\TestDir\file2.txt");
|
||||
FileSystemPathId id1 = _fileSystemPathIdFixture.Create(@"C:\TestDir\file1.txt");
|
||||
FileSystemPathId id2 = _fileSystemPathIdFixture.Create(@"C:\TestDir\file2.txt");
|
||||
|
||||
// Act
|
||||
bool result = id1 != id2;
|
||||
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.ValueObjects.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FileSystemPathId"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FileSystemPathIdFixture
|
||||
{
|
||||
private readonly Faker _faker;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FileSystemPathIdFixture"/> class.
|
||||
/// </summary>
|
||||
public FileSystemPathIdFixture()
|
||||
{
|
||||
_faker = new Faker();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="FileSystemPathId"/>.
|
||||
/// </summary>
|
||||
/// <param name="path">The path of the file system path element.</param>
|
||||
/// <returns>The created <see cref="FileSystemPathId"/>.</returns>
|
||||
public FileSystemPathId CreateFileSystemPathId(string? path = null)
|
||||
{
|
||||
path ??= _faker.System.FilePath();
|
||||
|
||||
Result<FileSystemPathId> fileSystemPathIdResult = FileSystemPathId.Create(path);
|
||||
|
||||
if (fileSystemPathIdResult.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create FileSystemPathId: " + string.Join(", ", fileSystemPathIdResult.Errors));
|
||||
return fileSystemPathIdResult.Value;
|
||||
}
|
||||
}
|
||||
-58
@@ -1,58 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.ValueObjects.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PathSegment"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PathSegmentFixture
|
||||
{
|
||||
private readonly Faker _faker;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PathSegmentFixture"/> class.
|
||||
/// </summary>
|
||||
public PathSegmentFixture()
|
||||
{
|
||||
_faker = new Faker();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PathSegment"/>.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="PathSegment"/>.</returns>
|
||||
public PathSegment CreatePathSegment(
|
||||
string? name = null,
|
||||
bool? isDirectory = null,
|
||||
bool? isDrive = null)
|
||||
{
|
||||
name ??= _faker.System.FileName();
|
||||
isDirectory ??= true;
|
||||
isDrive ??= false;
|
||||
|
||||
Result<PathSegment> pathResult = PathSegment.Create(name, isDirectory.Value, isDrive.Value);
|
||||
|
||||
if (pathResult.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create PathSegment: " + string.Join(", ", pathResult.Errors));
|
||||
return pathResult.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PathSegment"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<PathSegment> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => CreatePathSegment())];
|
||||
}
|
||||
}
|
||||
-77
@@ -1,77 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.ValueObjects.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="StreamInfo"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class StreamInfoFixture
|
||||
{
|
||||
private readonly Faker _faker;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="StreamInfoFixture"/> class.
|
||||
/// </summary>
|
||||
public StreamInfoFixture()
|
||||
{
|
||||
_faker = new Faker();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="StreamInfo"/>.
|
||||
/// </summary>
|
||||
/// <param name="streamId">Optional. The unique identifier for the stream. If not provided, a default value may be used.</param>
|
||||
/// <param name="mimeType">Optional. The MIME type of the stream (e.g., video/mp4, audio/mpeg). If not provided, a default MIME type may be used.</param>
|
||||
/// <param name="bitrate">Optional. The bitrate of the stream in kbps. If not provided, a default value may be used.</param>
|
||||
/// <param name="codec">Optional. The codec used for the stream (e.g., H.264, AAC). If not provided, a default codec may be used.</param>
|
||||
/// <param name="resolution">Optional. The video resolution (e.g., 1920x1080). If not provided, a default resolution may be used.</param>
|
||||
/// <param name="frameRate">Optional. The frame rate of the video stream in frames per second (fps). If not provided, a default frame rate may be used.</param>
|
||||
/// <param name="sampleRate">Optional. The sample rate of the audio stream in Hz. If not provided, a default sample rate may be used.</param>
|
||||
/// <param name="channels">Optional. The number of audio channels (e.g., 2 for stereo, 6 for 5.1 surround). If not provided, a default channel count may be used.</param>
|
||||
/// <returns>The created <see cref="StreamInfo"/>.</returns>
|
||||
public StreamInfo CreateStreamInfo(
|
||||
string? streamId = null,
|
||||
string? mimeType = null,
|
||||
int? bitrate = null,
|
||||
string? codec = null,
|
||||
Optional<string>? resolution = null,
|
||||
Optional<float>? frameRate = null,
|
||||
Optional<int>? sampleRate = null,
|
||||
Optional<int>? channels = null)
|
||||
{
|
||||
streamId ??= _faker.Random.AlphaNumeric(10);
|
||||
mimeType ??= _faker.System.MimeType();
|
||||
bitrate ??= _faker.Random.Number(1, 10000);
|
||||
codec ??= _faker.Random.Word();
|
||||
resolution ??= Optional<string>.FromNullable(_faker.Random.Bool() ? $"{_faker.Random.Number(100, 4000)}x{_faker.Random.Number(100, 4000)}" : null);
|
||||
frameRate ??= Optional<float>.FromNullable(_faker.Random.Bool() ? (float?)_faker.Random.Float(1, 120) : null);
|
||||
sampleRate ??= Optional<int>.FromNullable(_faker.Random.Bool() ? (int?)_faker.Random.Number(8000, 192000) : null);
|
||||
channels ??= Optional<int>.FromNullable(_faker.Random.Bool() ? (int?)_faker.Random.Number(1, 8) : null);
|
||||
|
||||
Result<StreamInfo> streamInfoResult = StreamInfo.Create(
|
||||
streamId, mimeType, bitrate.Value, codec, resolution.Value, frameRate.Value, sampleRate.Value, channels.Value);
|
||||
|
||||
if (streamInfoResult.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create StreamInfo: " + string.Join(", ", streamInfoResult.Errors));
|
||||
return streamInfoResult.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="StreamInfo"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<StreamInfo> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => CreateStreamInfo())];
|
||||
}
|
||||
}
|
||||
-51
@@ -1,51 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.PhotoLibrary;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.ValueObjects.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="Thumbnail"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ThumbnailFixture
|
||||
{
|
||||
private readonly Faker _faker;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ThumbnailFixture"/> class.
|
||||
/// </summary>
|
||||
public ThumbnailFixture()
|
||||
{
|
||||
_faker = new Faker();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="Thumbnail"/>.
|
||||
/// </summary>
|
||||
/// <param name="type">Optional. The <see cref="ImageType"/> of the thumbnail. If not provided, a random image type is selected.</param>
|
||||
/// <param name="bytes">Optional. The byte array representing the image data. If not provided, a random 1KB byte array is generated.</param>
|
||||
/// <returns>A newly created <see cref="Thumbnail"/> instance.</returns>
|
||||
public Thumbnail CreateThumbnail(ImageType? type = null, byte[]? bytes = null)
|
||||
{
|
||||
type ??= _faker.PickRandom<ImageType>();
|
||||
bytes ??= _faker.Random.Bytes(1024); // Generate 1KB of random bytes
|
||||
|
||||
return new Thumbnail(type.Value, bytes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="Thumbnail"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<Thumbnail> CreateMany(int count = 3)
|
||||
{
|
||||
return Enumerable.Range(0, count).Select(_ => CreateThumbnail()).ToList();
|
||||
}
|
||||
}
|
||||
+13
-13
@@ -2,7 +2,7 @@
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.ValueObjects.Fixtures;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
@@ -60,8 +60,8 @@ public class PathSegmentTests
|
||||
public void Equals_WithSameProperties_ShouldReturnTrue()
|
||||
{
|
||||
// Arrange
|
||||
PathSegment segment1 = _pathSegmentFixture.CreatePathSegment("folder", true, false);
|
||||
PathSegment segment2 = _pathSegmentFixture.CreatePathSegment("folder", true, false);
|
||||
PathSegment segment1 = _pathSegmentFixture.Create("folder", true, false);
|
||||
PathSegment segment2 = _pathSegmentFixture.Create("folder", true, false);
|
||||
|
||||
// Act
|
||||
bool result = segment1.Equals(segment2);
|
||||
@@ -74,8 +74,8 @@ public class PathSegmentTests
|
||||
public void Equals_WithDifferentProperties_ShouldReturnFalse()
|
||||
{
|
||||
// Arrange
|
||||
PathSegment segment1 = _pathSegmentFixture.CreatePathSegment("folder1", true, false);
|
||||
PathSegment segment2 = _pathSegmentFixture.CreatePathSegment("folder2", true, false);
|
||||
PathSegment segment1 = _pathSegmentFixture.Create("folder1", true, false);
|
||||
PathSegment segment2 = _pathSegmentFixture.Create("folder2", true, false);
|
||||
|
||||
// Act
|
||||
bool result = segment1.Equals(segment2);
|
||||
@@ -88,8 +88,8 @@ public class PathSegmentTests
|
||||
public void GetHashCode_WithSameProperties_ShouldReturnSameHashCode()
|
||||
{
|
||||
// Arrange
|
||||
PathSegment segment1 = _pathSegmentFixture.CreatePathSegment("folder", true, false);
|
||||
PathSegment segment2 = _pathSegmentFixture.CreatePathSegment("folder", true, false);
|
||||
PathSegment segment1 = _pathSegmentFixture.Create("folder", true, false);
|
||||
PathSegment segment2 = _pathSegmentFixture.Create("folder", true, false);
|
||||
|
||||
// Act
|
||||
int hashCode1 = segment1.GetHashCode();
|
||||
@@ -103,8 +103,8 @@ public class PathSegmentTests
|
||||
public void GetHashCode_WithDifferentProperties_ShouldReturnDifferentHashCode()
|
||||
{
|
||||
// Arrange
|
||||
PathSegment segment1 = _pathSegmentFixture.CreatePathSegment("folder1", true, false);
|
||||
PathSegment segment2 = _pathSegmentFixture.CreatePathSegment("folder2", true, false);
|
||||
PathSegment segment1 = _pathSegmentFixture.Create("folder1", true, false);
|
||||
PathSegment segment2 = _pathSegmentFixture.Create("folder2", true, false);
|
||||
|
||||
// Act
|
||||
int hashCode1 = segment1.GetHashCode();
|
||||
@@ -118,8 +118,8 @@ public class PathSegmentTests
|
||||
public void EqualityOperator_WithSameProperties_ShouldReturnTrue()
|
||||
{
|
||||
// Arrange
|
||||
PathSegment segment1 = _pathSegmentFixture.CreatePathSegment("folder", true, false);
|
||||
PathSegment segment2 = _pathSegmentFixture.CreatePathSegment("folder", true, false);
|
||||
PathSegment segment1 = _pathSegmentFixture.Create("folder", true, false);
|
||||
PathSegment segment2 = _pathSegmentFixture.Create("folder", true, false);
|
||||
|
||||
// Act
|
||||
bool result = segment1 == segment2;
|
||||
@@ -132,8 +132,8 @@ public class PathSegmentTests
|
||||
public void InequalityOperator_WithDifferentProperties_ShouldReturnTrue()
|
||||
{
|
||||
// Arrange
|
||||
PathSegment segment1 = _pathSegmentFixture.CreatePathSegment("folder1", true, false);
|
||||
PathSegment segment2 = _pathSegmentFixture.CreatePathSegment("folder2", true, false);
|
||||
PathSegment segment1 = _pathSegmentFixture.Create("folder1", true, false);
|
||||
PathSegment segment2 = _pathSegmentFixture.Create("folder2", true, false);
|
||||
|
||||
// Act
|
||||
bool result = segment1 != segment2;
|
||||
|
||||
+9
-9
@@ -2,7 +2,7 @@
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.ValueObjects.Fixtures;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
@@ -108,8 +108,8 @@ public class StreamInfoTests
|
||||
public void Equals_WithSameProperties_ShouldReturnTrue()
|
||||
{
|
||||
// Arrange
|
||||
StreamInfo info1 = _streamInfoFixture.CreateStreamInfo();
|
||||
StreamInfo info2 = _streamInfoFixture.CreateStreamInfo(
|
||||
StreamInfo info1 = _streamInfoFixture.Create();
|
||||
StreamInfo info2 = _streamInfoFixture.Create(
|
||||
info1.StreamId, info1.MimeType, info1.Bitrate, info1.Codec,
|
||||
info1.Resolution, info1.FrameRate, info1.SampleRate, info1.Channels);
|
||||
|
||||
@@ -124,8 +124,8 @@ public class StreamInfoTests
|
||||
public void Equals_WithDifferentProperties_ShouldReturnFalse()
|
||||
{
|
||||
// Arrange
|
||||
StreamInfo info1 = _streamInfoFixture.CreateStreamInfo();
|
||||
StreamInfo info2 = _streamInfoFixture.CreateStreamInfo();
|
||||
StreamInfo info1 = _streamInfoFixture.Create();
|
||||
StreamInfo info2 = _streamInfoFixture.Create();
|
||||
|
||||
// Act
|
||||
bool result = info1.Equals(info2);
|
||||
@@ -138,8 +138,8 @@ public class StreamInfoTests
|
||||
public void GetHashCode_WithSameProperties_ShouldReturnSameHashCode()
|
||||
{
|
||||
// Arrange
|
||||
StreamInfo info1 = _streamInfoFixture.CreateStreamInfo();
|
||||
StreamInfo info2 = _streamInfoFixture.CreateStreamInfo(
|
||||
StreamInfo info1 = _streamInfoFixture.Create();
|
||||
StreamInfo info2 = _streamInfoFixture.Create(
|
||||
info1.StreamId, info1.MimeType, info1.Bitrate, info1.Codec,
|
||||
info1.Resolution, info1.FrameRate, info1.SampleRate, info1.Channels);
|
||||
|
||||
@@ -155,8 +155,8 @@ public class StreamInfoTests
|
||||
public void GetHashCode_WithDifferentProperties_ShouldReturnDifferentHashCode()
|
||||
{
|
||||
// Arrange
|
||||
StreamInfo info1 = _streamInfoFixture.CreateStreamInfo();
|
||||
StreamInfo info2 = _streamInfoFixture.CreateStreamInfo();
|
||||
StreamInfo info1 = _streamInfoFixture.Create();
|
||||
StreamInfo info2 = _streamInfoFixture.Create();
|
||||
|
||||
// Act
|
||||
int hashCode1 = info1.GetHashCode();
|
||||
|
||||
+12
-12
@@ -1,7 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.PhotoLibrary;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.ValueObjects.Fixtures;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.PhotoLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
@@ -45,7 +45,7 @@ public class ThumbnailTests
|
||||
public void Equals_WithSameProperties_ShouldReturnTrue()
|
||||
{
|
||||
// Arrange
|
||||
Thumbnail thumbnail1 = _thumbnailFixture.CreateThumbnail();
|
||||
Thumbnail thumbnail1 = _thumbnailFixture.Create();
|
||||
Thumbnail thumbnail2 = new(thumbnail1.Type, thumbnail1.Bytes);
|
||||
|
||||
// Act
|
||||
@@ -59,8 +59,8 @@ public class ThumbnailTests
|
||||
public void Equals_WithDifferentType_ShouldReturnFalse()
|
||||
{
|
||||
// Arrange
|
||||
Thumbnail thumbnail1 = _thumbnailFixture.CreateThumbnail(ImageType.PNG);
|
||||
Thumbnail thumbnail2 = _thumbnailFixture.CreateThumbnail(ImageType.JPEG, thumbnail1.Bytes);
|
||||
Thumbnail thumbnail1 = _thumbnailFixture.Create(ImageType.PNG);
|
||||
Thumbnail thumbnail2 = _thumbnailFixture.Create(ImageType.JPEG, thumbnail1.Bytes);
|
||||
|
||||
// Act
|
||||
bool result = thumbnail1.Equals(thumbnail2);
|
||||
@@ -73,8 +73,8 @@ public class ThumbnailTests
|
||||
public void Equals_WithDifferentBytes_ShouldReturnFalse()
|
||||
{
|
||||
// Arrange
|
||||
Thumbnail thumbnail1 = _thumbnailFixture.CreateThumbnail();
|
||||
Thumbnail thumbnail2 = _thumbnailFixture.CreateThumbnail(thumbnail1.Type);
|
||||
Thumbnail thumbnail1 = _thumbnailFixture.Create();
|
||||
Thumbnail thumbnail2 = _thumbnailFixture.Create(thumbnail1.Type);
|
||||
|
||||
// Act
|
||||
bool result = thumbnail1.Equals(thumbnail2);
|
||||
@@ -87,7 +87,7 @@ public class ThumbnailTests
|
||||
public void GetHashCode_WithSameProperties_ShouldReturnSameHashCode()
|
||||
{
|
||||
// Arrange
|
||||
Thumbnail thumbnail1 = _thumbnailFixture.CreateThumbnail();
|
||||
Thumbnail thumbnail1 = _thumbnailFixture.Create();
|
||||
Thumbnail thumbnail2 = new(thumbnail1.Type, thumbnail1.Bytes);
|
||||
|
||||
// Act
|
||||
@@ -102,8 +102,8 @@ public class ThumbnailTests
|
||||
public void GetHashCode_WithDifferentProperties_ShouldReturnDifferentHashCode()
|
||||
{
|
||||
// Arrange
|
||||
Thumbnail thumbnail1 = _thumbnailFixture.CreateThumbnail();
|
||||
Thumbnail thumbnail2 = _thumbnailFixture.CreateThumbnail();
|
||||
Thumbnail thumbnail1 = _thumbnailFixture.Create();
|
||||
Thumbnail thumbnail2 = _thumbnailFixture.Create();
|
||||
|
||||
// Act
|
||||
int hashCode1 = thumbnail1.GetHashCode();
|
||||
@@ -117,10 +117,10 @@ public class ThumbnailTests
|
||||
public void GetEqualityComponents_ShouldReturnTypeAndBytes()
|
||||
{
|
||||
// Arrange
|
||||
Thumbnail thumbnail = _thumbnailFixture.CreateThumbnail();
|
||||
Thumbnail thumbnail = _thumbnailFixture.Create();
|
||||
|
||||
// Act
|
||||
List<object> components = thumbnail.GetEqualityComponents().ToList();
|
||||
List<object> components = [.. thumbnail.GetEqualityComponents()];
|
||||
|
||||
// Assert
|
||||
Assert.Equal(2, components.Count);
|
||||
|
||||
Reference in new issue
Block a user