mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 18:21:10 +00:00
Replaces ErrorOr library with a custom implementation.
This commit is contained in:
1 parent
8fe90a4dde
commit
3b772d68ca
436 files changed
+4234
-3922
No files matched your search
+3
-5
@@ -1,14 +1,12 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
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.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
@@ -26,7 +24,7 @@ public static class BookFixture
|
||||
/// <returns>The created <see cref="Book"/> domain entity.</returns>
|
||||
public static Book CreateValidBook()
|
||||
{
|
||||
ErrorOr<Book> bookResult = Book.Create(
|
||||
Result<Book> bookResult = Book.Create(
|
||||
LibraryId.Create(Guid.NewGuid()),
|
||||
"/books/test.epub",
|
||||
WrittenContentMetadata.Create(
|
||||
@@ -65,7 +63,7 @@ public static class BookFixture
|
||||
[],
|
||||
[]
|
||||
);
|
||||
if (bookResult.IsError)
|
||||
if (bookResult.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create a valid book in the test fixture.");
|
||||
return bookResult.Value;
|
||||
}
|
||||
|
||||
+23
-24
@@ -1,11 +1,10 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using Lumina.Domain.SharedKernel.Common.Errors;
|
||||
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.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.Fixtures;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -29,10 +28,10 @@ public class DirectoryTests
|
||||
Optional<DateTime> dateModified = DateTime.Now;
|
||||
|
||||
// Act
|
||||
ErrorOr<Directory> result = Directory.Create(path, name, dateCreated, dateModified);
|
||||
Result<Directory> result = Directory.Create(path, name, dateCreated, dateModified);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(name, result.Value.Name);
|
||||
Assert.Equal(dateCreated, result.Value.DateCreated);
|
||||
@@ -50,10 +49,10 @@ public class DirectoryTests
|
||||
Optional<DateTime> dateModified = DateTime.Now;
|
||||
|
||||
// Act
|
||||
ErrorOr<Directory> result = Directory.Create(invalidPath, name, dateCreated, dateModified);
|
||||
Result<Directory> result = Directory.Create(invalidPath, name, dateCreated, dateModified);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -61,18 +60,18 @@ public class DirectoryTests
|
||||
public void Create_WhenCalledWithFileSystemPathId_ShouldReturnSuccessfulResult()
|
||||
{
|
||||
// Arrange
|
||||
ErrorOr<FileSystemPathId> pathIdResult = FileSystemPathId.Create("/valid/path");
|
||||
Assert.False(pathIdResult.IsError);
|
||||
Result<FileSystemPathId> pathIdResult = FileSystemPathId.Create("/valid/path");
|
||||
Assert.False(pathIdResult.IsFailure);
|
||||
FileSystemPathId pathId = pathIdResult.Value;
|
||||
string name = "TestDirectory";
|
||||
Optional<DateTime> dateCreated = DateTime.Now;
|
||||
Optional<DateTime> dateModified = DateTime.Now;
|
||||
|
||||
// Act
|
||||
ErrorOr<Directory> result = Directory.Create(pathId, name, dateCreated, dateModified);
|
||||
Result<Directory> result = Directory.Create(pathId, name, dateCreated, dateModified);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(pathId, result.Value.Id);
|
||||
Assert.Equal(name, result.Value.Name);
|
||||
@@ -85,16 +84,16 @@ public class DirectoryTests
|
||||
public void UpdateLastModified_WhenCalled_ShouldUpdateDateModified()
|
||||
{
|
||||
// Arrange
|
||||
ErrorOr<Directory> directoryResult = Directory.Create("/valid/path", "TestDirectory", Optional<DateTime>.None(), Optional<DateTime>.None());
|
||||
Assert.False(directoryResult.IsError);
|
||||
Result<Directory> directoryResult = Directory.Create("/valid/path", "TestDirectory", Optional<DateTime>.None(), Optional<DateTime>.None());
|
||||
Assert.False(directoryResult.IsFailure);
|
||||
Directory directory = directoryResult.Value;
|
||||
DateTime newDate = DateTime.Now;
|
||||
|
||||
// Act
|
||||
ErrorOr<Updated> result = directory.UpdateLastModified(newDate);
|
||||
Result<Updated> result = directory.UpdateLastModified(newDate);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(newDate, directory.DateModified.Value);
|
||||
}
|
||||
|
||||
@@ -102,16 +101,16 @@ public class DirectoryTests
|
||||
public void AddItem_WhenCalled_ShouldAddItemToCollection()
|
||||
{
|
||||
// Arrange
|
||||
ErrorOr<Directory> directoryResult = Directory.Create("/valid/path", "TestDirectory", Optional<DateTime>.None(), Optional<DateTime>.None());
|
||||
Assert.False(directoryResult.IsError);
|
||||
Result<Directory> directoryResult = Directory.Create("/valid/path", "TestDirectory", Optional<DateTime>.None(), Optional<DateTime>.None());
|
||||
Assert.False(directoryResult.IsFailure);
|
||||
Directory directory = directoryResult.Value;
|
||||
FileSystemItem item = new FileSystemItemFixture(FileSystemPathId.Create("/mock/path").Value, "MockItem", FileSystemItemType.File);
|
||||
|
||||
// Act
|
||||
ErrorOr<Updated> result = directory.AddItem(item);
|
||||
Result<Updated> result = directory.AddItem(item);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Contains(item, directory.Items);
|
||||
}
|
||||
|
||||
@@ -119,17 +118,17 @@ public class DirectoryTests
|
||||
public void RemoveItem_WhenCalledWithExistingItem_ShouldRemoveItemFromCollection()
|
||||
{
|
||||
// Arrange
|
||||
ErrorOr<Directory> directoryResult = Directory.Create("/valid/path", "TestDirectory", Optional<DateTime>.None(), Optional<DateTime>.None());
|
||||
Assert.False(directoryResult.IsError);
|
||||
Result<Directory> directoryResult = Directory.Create("/valid/path", "TestDirectory", Optional<DateTime>.None(), Optional<DateTime>.None());
|
||||
Assert.False(directoryResult.IsFailure);
|
||||
Directory directory = directoryResult.Value;
|
||||
FileSystemItem item = new FileSystemItemFixture(FileSystemPathId.Create("/mock/path").Value, "MockItem", FileSystemItemType.File);
|
||||
directory.AddItem(item);
|
||||
|
||||
// Act
|
||||
ErrorOr<Updated> result = directory.RemoveItem(item);
|
||||
Result<Updated> result = directory.RemoveItem(item);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.DoesNotContain(item, directory.Items);
|
||||
}
|
||||
}
|
||||
+26
-27
@@ -1,10 +1,9 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using Lumina.Domain.SharedKernel.Common.Errors;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
@@ -28,10 +27,10 @@ public class FileTests
|
||||
long size = 1024;
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = File.Create(path, name, dateCreated, dateModified, size);
|
||||
Result<File> result = File.Create(path, name, dateCreated, dateModified, size);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(name, result.Value.Name);
|
||||
Assert.Equal(dateCreated, result.Value.DateCreated);
|
||||
@@ -51,10 +50,10 @@ public class FileTests
|
||||
long size = 1024;
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = File.Create(invalidPath, name, dateCreated, dateModified, size);
|
||||
Result<File> result = File.Create(invalidPath, name, dateCreated, dateModified, size);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -62,8 +61,8 @@ public class FileTests
|
||||
public void Create_WhenCalledWithFileSystemPathId_ShouldReturnSuccessfulResult()
|
||||
{
|
||||
// Arrange
|
||||
ErrorOr<FileSystemPathId> pathIdResult = FileSystemPathId.Create("/valid/path/file.txt");
|
||||
Assert.False(pathIdResult.IsError);
|
||||
Result<FileSystemPathId> pathIdResult = FileSystemPathId.Create("/valid/path/file.txt");
|
||||
Assert.False(pathIdResult.IsFailure);
|
||||
FileSystemPathId pathId = pathIdResult.Value;
|
||||
string name = "file.txt";
|
||||
Optional<DateTime> dateCreated = DateTime.Now;
|
||||
@@ -71,10 +70,10 @@ public class FileTests
|
||||
long size = 1024;
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = File.Create(pathId, name, dateCreated, dateModified, size);
|
||||
Result<File> result = File.Create(pathId, name, dateCreated, dateModified, size);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(pathId, result.Value.Id);
|
||||
Assert.Equal(name, result.Value.Name);
|
||||
@@ -88,16 +87,16 @@ public class FileTests
|
||||
public void UpdateLastModified_WhenCalled_ShouldUpdateDateModified()
|
||||
{
|
||||
// Arrange
|
||||
ErrorOr<File> fileResult = File.Create("/valid/path/file.txt", "file.txt", Optional<DateTime>.None(), Optional<DateTime>.None(), 1024);
|
||||
Assert.False(fileResult.IsError);
|
||||
Result<File> fileResult = File.Create("/valid/path/file.txt", "file.txt", Optional<DateTime>.None(), Optional<DateTime>.None(), 1024);
|
||||
Assert.False(fileResult.IsFailure);
|
||||
File file = fileResult.Value;
|
||||
DateTime newDate = DateTime.Now;
|
||||
|
||||
// Act
|
||||
ErrorOr<Updated> result = file.UpdateLastModified(newDate);
|
||||
Result<Updated> result = file.UpdateLastModified(newDate);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(newDate, file.DateModified.Value);
|
||||
}
|
||||
|
||||
@@ -105,16 +104,16 @@ public class FileTests
|
||||
public void UpdateSize_WhenCalled_ShouldUpdateFileSize()
|
||||
{
|
||||
// Arrange
|
||||
ErrorOr<File> fileResult = File.Create("/valid/path/file.txt", "file.txt", Optional<DateTime>.None(), Optional<DateTime>.None(), 1024);
|
||||
Assert.False(fileResult.IsError);
|
||||
Result<File> fileResult = File.Create("/valid/path/file.txt", "file.txt", Optional<DateTime>.None(), Optional<DateTime>.None(), 1024);
|
||||
Assert.False(fileResult.IsFailure);
|
||||
File file = fileResult.Value;
|
||||
long newSize = 2048;
|
||||
|
||||
// Act
|
||||
ErrorOr<Updated> result = file.UpdateSize(newSize);
|
||||
Result<Updated> result = file.UpdateSize(newSize);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(newSize, file.Size);
|
||||
}
|
||||
|
||||
@@ -122,16 +121,16 @@ public class FileTests
|
||||
public void Rename_WhenCalledWithValidName_ShouldUpdateFileName()
|
||||
{
|
||||
// Arrange
|
||||
ErrorOr<File> fileResult = File.Create("/valid/path/file.txt", "file.txt", Optional<DateTime>.None(), Optional<DateTime>.None(), 1024);
|
||||
Assert.False(fileResult.IsError);
|
||||
Result<File> fileResult = File.Create("/valid/path/file.txt", "file.txt", Optional<DateTime>.None(), Optional<DateTime>.None(), 1024);
|
||||
Assert.False(fileResult.IsFailure);
|
||||
File file = fileResult.Value;
|
||||
string newName = "newfile.txt";
|
||||
|
||||
// Act
|
||||
ErrorOr<Updated> result = file.Rename(newName);
|
||||
Result<Updated> result = file.Rename(newName);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(newName, file.Name);
|
||||
}
|
||||
|
||||
@@ -139,16 +138,16 @@ public class FileTests
|
||||
public void Rename_WhenCalledWithEmptyName_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
ErrorOr<File> fileResult = File.Create("/valid/path/file.txt", "file.txt", Optional<DateTime>.None(), Optional<DateTime>.None(), 1024);
|
||||
Assert.False(fileResult.IsError);
|
||||
Result<File> fileResult = File.Create("/valid/path/file.txt", "file.txt", Optional<DateTime>.None(), Optional<DateTime>.None(), 1024);
|
||||
Assert.False(fileResult.IsFailure);
|
||||
File file = fileResult.Value;
|
||||
string emptyName = "";
|
||||
|
||||
// Act
|
||||
ErrorOr<Updated> result = file.Rename(emptyName);
|
||||
Result<Updated> result = file.Rename(emptyName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.NameCannotBeEmpty, result.FirstError);
|
||||
Assert.Equal("file.txt", file.Name);
|
||||
}
|
||||
|
||||
+5
-6
@@ -1,10 +1,9 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
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;
|
||||
@@ -54,9 +53,9 @@ public class DirectoryFixture
|
||||
dateModified ??= Optional<DateTime>.Some(_faker.Date.Recent());
|
||||
status ??= _faker.PickRandom<FileSystemItemStatus>();
|
||||
|
||||
ErrorOr<Directory> directoryResult = Directory.Create(path, name, dateCreated.Value, dateModified.Value, status.Value);
|
||||
Result<Directory> directoryResult = Directory.Create(path, name, dateCreated.Value, dateModified.Value, status.Value);
|
||||
|
||||
if (directoryResult.IsError)
|
||||
if (directoryResult.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create Directory: " + string.Join(", ", directoryResult.Errors));
|
||||
Directory directory = directoryResult.Value;
|
||||
|
||||
@@ -73,7 +72,7 @@ public class DirectoryFixture
|
||||
/// <returns>The created list.</returns>
|
||||
public List<Directory> CreateMany(int count = 3)
|
||||
{
|
||||
return Enumerable.Range(0, count).Select(_ => CreateDirectory()).ToList();
|
||||
return [.. Enumerable.Range(0, count).Select(_ => CreateDirectory())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -85,7 +84,7 @@ public class DirectoryFixture
|
||||
/// <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)).ToList();
|
||||
return [.. Enumerable.Range(0, count).Select(_ => CreateNestedDirectory(1, maxDepth, maxChildrenPerDirectory))];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+4
-5
@@ -1,9 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
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;
|
||||
@@ -47,9 +46,9 @@ public class FileFixture
|
||||
size ??= _faker.Random.Long();
|
||||
status ??= _faker.PickRandom<FileSystemItemStatus>();
|
||||
|
||||
ErrorOr<File> fileResult = File.Create(path, name, dateCreated.Value, dateModified.Value, size.Value, status.Value);
|
||||
Result<File> fileResult = File.Create(path, name, dateCreated.Value, dateModified.Value, size.Value, status.Value);
|
||||
|
||||
if (fileResult.IsError)
|
||||
if (fileResult.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create File: " + string.Join(", ", fileResult.Errors));
|
||||
return fileResult.Value;
|
||||
}
|
||||
@@ -61,7 +60,7 @@ public class FileFixture
|
||||
/// <returns>The created list.</returns>
|
||||
public List<File> CreateMany(int count = 3)
|
||||
{
|
||||
return Enumerable.Range(0, count).Select(_ => CreateFile()).ToList();
|
||||
return [.. Enumerable.Range(0, count).Select(_ => CreateFile())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+17
-17
@@ -1,9 +1,9 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using Lumina.Domain.SharedKernel.Common.Errors;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
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.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
@@ -20,10 +20,10 @@ public class UnixRootItemTests
|
||||
public void Create_WhenCalledWithDefaultStatus_ShouldReturnSuccessfulResult()
|
||||
{
|
||||
// Arrange & Act
|
||||
ErrorOr<UnixRootItem> result = UnixRootItem.Create();
|
||||
Result<UnixRootItem> result = UnixRootItem.Create();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal("/", result.Value.Name);
|
||||
Assert.Equal("/", result.Value.Id.Path);
|
||||
@@ -39,10 +39,10 @@ public class UnixRootItemTests
|
||||
FileSystemItemStatus customStatus = FileSystemItemStatus.Accessible;
|
||||
|
||||
// Act
|
||||
ErrorOr<UnixRootItem> result = UnixRootItem.Create(customStatus);
|
||||
Result<UnixRootItem> result = UnixRootItem.Create(customStatus);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal("/", result.Value.Name);
|
||||
Assert.Equal("/", result.Value.Id.Path);
|
||||
@@ -55,8 +55,8 @@ public class UnixRootItemTests
|
||||
public void Items_WhenAccessed_ShouldReturnEmptyReadOnlyCollection()
|
||||
{
|
||||
// Arrange
|
||||
ErrorOr<UnixRootItem> createResult = UnixRootItem.Create();
|
||||
Assert.False(createResult.IsError);
|
||||
Result<UnixRootItem> createResult = UnixRootItem.Create();
|
||||
Assert.False(createResult.IsFailure);
|
||||
UnixRootItem unixRootItem = createResult.Value;
|
||||
|
||||
// Act
|
||||
@@ -71,16 +71,16 @@ public class UnixRootItemTests
|
||||
public void SetStatus_WhenCalledWithNewStatus_ShouldUpdateStatus()
|
||||
{
|
||||
// Arrange
|
||||
ErrorOr<UnixRootItem> createResult = UnixRootItem.Create();
|
||||
Assert.False(createResult.IsError);
|
||||
Result<UnixRootItem> createResult = UnixRootItem.Create();
|
||||
Assert.False(createResult.IsFailure);
|
||||
UnixRootItem unixRootItem = createResult.Value;
|
||||
FileSystemItemStatus newStatus = FileSystemItemStatus.Accessible;
|
||||
|
||||
// Act
|
||||
ErrorOr<Updated> result = unixRootItem.SetStatus(newStatus);
|
||||
Result<Updated> result = unixRootItem.SetStatus(newStatus);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(newStatus, unixRootItem.Status);
|
||||
}
|
||||
|
||||
@@ -88,15 +88,15 @@ public class UnixRootItemTests
|
||||
public void SetParent_WhenCalledWithNullParent_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
ErrorOr<UnixRootItem> createResult = UnixRootItem.Create();
|
||||
Assert.False(createResult.IsError);
|
||||
Result<UnixRootItem> createResult = UnixRootItem.Create();
|
||||
Assert.False(createResult.IsFailure);
|
||||
UnixRootItem unixRootItem = createResult.Value;
|
||||
|
||||
// Act
|
||||
ErrorOr<Updated> result = unixRootItem.SetParent(null!);
|
||||
Result<Updated> result = unixRootItem.SetParent(null!);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.ParentNodeCannotBeNull, result.FirstError);
|
||||
Assert.False(unixRootItem.Parent.HasValue);
|
||||
}
|
||||
|
||||
+23
-23
@@ -1,10 +1,10 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using Lumina.Domain.SharedKernel.Common.Errors;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
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.SharedKernel.Common.Enums.FileSystem;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
@@ -25,10 +25,10 @@ public class WindowsRootItemTests
|
||||
string name = "C:";
|
||||
|
||||
// Act
|
||||
ErrorOr<WindowsRootItem> result = WindowsRootItem.Create(path, name);
|
||||
Result<WindowsRootItem> result = WindowsRootItem.Create(path, name);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(name, result.Value.Name);
|
||||
Assert.Equal(path, result.Value.Id.Path);
|
||||
@@ -45,10 +45,10 @@ public class WindowsRootItemTests
|
||||
string name = "Invalid";
|
||||
|
||||
// Act
|
||||
ErrorOr<WindowsRootItem> result = WindowsRootItem.Create(invalidPath, name);
|
||||
Result<WindowsRootItem> result = WindowsRootItem.Create(invalidPath, name);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -61,10 +61,10 @@ public class WindowsRootItemTests
|
||||
FileSystemItemStatus customStatus = FileSystemItemStatus.Accessible;
|
||||
|
||||
// Act
|
||||
ErrorOr<WindowsRootItem> result = WindowsRootItem.Create(path, name, customStatus);
|
||||
Result<WindowsRootItem> result = WindowsRootItem.Create(path, name, customStatus);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(name, result.Value.Name);
|
||||
Assert.Equal(path, result.Value.Id.Path);
|
||||
@@ -76,16 +76,16 @@ public class WindowsRootItemTests
|
||||
public void Create_WhenCalledWithFileSystemPathId_ShouldReturnSuccessfulResult()
|
||||
{
|
||||
// Arrange
|
||||
ErrorOr<FileSystemPathId> pathIdResult = FileSystemPathId.Create("E:\\");
|
||||
Assert.False(pathIdResult.IsError);
|
||||
Result<FileSystemPathId> pathIdResult = FileSystemPathId.Create("E:\\");
|
||||
Assert.False(pathIdResult.IsFailure);
|
||||
FileSystemPathId pathId = pathIdResult.Value;
|
||||
string name = "E:";
|
||||
|
||||
// Act
|
||||
ErrorOr<WindowsRootItem> result = WindowsRootItem.Create(pathId, name);
|
||||
Result<WindowsRootItem> result = WindowsRootItem.Create(pathId, name);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(pathId, result.Value.Id);
|
||||
Assert.Equal(name, result.Value.Name);
|
||||
@@ -97,8 +97,8 @@ public class WindowsRootItemTests
|
||||
public void Items_WhenAccessed_ShouldReturnEmptyReadOnlyCollection()
|
||||
{
|
||||
// Arrange
|
||||
ErrorOr<WindowsRootItem> createResult = WindowsRootItem.Create("F:\\", "F:");
|
||||
Assert.False(createResult.IsError);
|
||||
Result<WindowsRootItem> createResult = WindowsRootItem.Create("F:\\", "F:");
|
||||
Assert.False(createResult.IsFailure);
|
||||
WindowsRootItem windowsRootItem = createResult.Value;
|
||||
|
||||
// Act
|
||||
@@ -113,16 +113,16 @@ public class WindowsRootItemTests
|
||||
public void SetStatus_WhenCalledWithNewStatus_ShouldUpdateStatus()
|
||||
{
|
||||
// Arrange
|
||||
ErrorOr<WindowsRootItem> createResult = WindowsRootItem.Create("G:\\", "G:");
|
||||
Assert.False(createResult.IsError);
|
||||
Result<WindowsRootItem> createResult = WindowsRootItem.Create("G:\\", "G:");
|
||||
Assert.False(createResult.IsFailure);
|
||||
WindowsRootItem windowsRootItem = createResult.Value;
|
||||
FileSystemItemStatus newStatus = FileSystemItemStatus.Accessible;
|
||||
|
||||
// Act
|
||||
ErrorOr<Updated> result = windowsRootItem.SetStatus(newStatus);
|
||||
Result<Updated> result = windowsRootItem.SetStatus(newStatus);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(newStatus, windowsRootItem.Status);
|
||||
}
|
||||
|
||||
@@ -130,15 +130,15 @@ public class WindowsRootItemTests
|
||||
public void SetParent_WhenCalledWithNullParent_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
ErrorOr<WindowsRootItem> createResult = WindowsRootItem.Create("H:\\", "H:");
|
||||
Assert.False(createResult.IsError);
|
||||
Result<WindowsRootItem> createResult = WindowsRootItem.Create("H:\\", "H:");
|
||||
Assert.False(createResult.IsFailure);
|
||||
WindowsRootItem windowsRootItem = createResult.Value;
|
||||
|
||||
// Act
|
||||
ErrorOr<Updated> result = windowsRootItem.SetParent(null!);
|
||||
Result<Updated> result = windowsRootItem.SetParent(null!);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.ParentNodeCannotBeNull, result.FirstError);
|
||||
Assert.False(windowsRootItem.Parent.HasValue);
|
||||
}
|
||||
|
||||
+8
-9
@@ -1,12 +1,11 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using AutoFixture;
|
||||
using AutoFixture.AutoNSubstitute;
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using Lumina.Domain.SharedKernel.Common.Errors;
|
||||
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.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;
|
||||
@@ -59,10 +58,10 @@ public class FileSystemItemTests
|
||||
FileSystemItemStatus newStatus = FileSystemItemStatus.Inaccessible;
|
||||
|
||||
// Act
|
||||
ErrorOr<Updated> result = item.SetStatus(newStatus);
|
||||
Result<Updated> result = item.SetStatus(newStatus);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(Result.Updated, result.Value);
|
||||
Assert.Equal(newStatus, item.Status);
|
||||
}
|
||||
@@ -75,10 +74,10 @@ public class FileSystemItemTests
|
||||
FileSystemItemFixture parent = CreateFileSystemItemFixture();
|
||||
|
||||
// Act
|
||||
ErrorOr<Updated> result = item.SetParent(parent);
|
||||
Result<Updated> result = item.SetParent(parent);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(Result.Updated, result.Value);
|
||||
Assert.Equal(Optional<FileSystemItem>.Some(parent), item.Parent);
|
||||
}
|
||||
@@ -90,10 +89,10 @@ public class FileSystemItemTests
|
||||
FileSystemItemFixture item = CreateFileSystemItemFixture();
|
||||
|
||||
// Act
|
||||
ErrorOr<Updated> result = item.SetParent(null!);
|
||||
Result<Updated> result = item.SetParent(null!);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.ParentNodeCannotBeNull, result.FirstError);
|
||||
Assert.Equal(Optional<FileSystemItem>.None(), item.Parent);
|
||||
}
|
||||
|
||||
+82
-82
@@ -1,12 +1,12 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using AutoFixture;
|
||||
using AutoFixture.AutoNSubstitute;
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using Lumina.Domain.SharedKernel.Common.Errors;
|
||||
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.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;
|
||||
@@ -76,10 +76,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ListDirectory, false).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetSubdirectoryPaths(path, false);
|
||||
Result<IEnumerable<FileSystemPathId>> result = _sut.GetSubdirectoryPaths(path, false);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -88,16 +88,16 @@ public class DirectoryProviderServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
string[] subdirectories = _fixture.CreateMany<string>(3).ToArray();
|
||||
string[] subdirectories = [.. _fixture.CreateMany<string>(3)];
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ListDirectory, false).Returns(true);
|
||||
_mockFileSystem.Directory.GetDirectories(path.Path).Returns(subdirectories);
|
||||
_mockFileSystem.Path.DirectorySeparatorChar.Returns(_dirSeparator);
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetSubdirectoryPaths(path, false);
|
||||
Result<IEnumerable<FileSystemPathId>> result = _sut.GetSubdirectoryPaths(path, false);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(3, result.Value.Count());
|
||||
Assert.Equal(
|
||||
subdirectories.Select(x => x + _dirSeparator).OrderBy(x => x),
|
||||
@@ -118,10 +118,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.File.GetAttributes(_pathHidden1).Returns(FileAttributes.Directory | FileAttributes.Hidden);
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetSubdirectoryPaths(path, false);
|
||||
Result<IEnumerable<FileSystemPathId>> result = _sut.GetSubdirectoryPaths(path, false);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Single(result.Value);
|
||||
Assert.Equal(_pathVisible2, result.Value.First().Path);
|
||||
}
|
||||
@@ -139,10 +139,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.File.GetAttributes(_pathHidden1).Returns(FileAttributes.Directory | FileAttributes.Hidden);
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetSubdirectoryPaths(path, true);
|
||||
Result<IEnumerable<FileSystemPathId>> result = _sut.GetSubdirectoryPaths(path, true);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(2, result.Value.Count());
|
||||
Assert.Equal(
|
||||
new[] { _pathVisible2, _pathHidden2 }.OrderBy(p => p),
|
||||
@@ -163,10 +163,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.File.GetAttributes(_pathInvalid1).Throws(new Exception("Access denied"));
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetSubdirectoryPaths(path, false);
|
||||
Result<IEnumerable<FileSystemPathId>> result = _sut.GetSubdirectoryPaths(path, false);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(2, result.Value.Count());
|
||||
Assert.Equal(_pathInvalid2, result.Value.First().Path);
|
||||
Assert.Equal(_pathValid2, result.Value.Last().Path);
|
||||
@@ -189,10 +189,10 @@ public class DirectoryProviderServiceTests
|
||||
: [@"C:\A\", @"C:\B\", @"C:\C\"];
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetSubdirectoryPaths(path, false);
|
||||
Result<IEnumerable<FileSystemPathId>> result = _sut.GetSubdirectoryPaths(path, false);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(expectedPaths, result.Value.Select(x => x.Path));
|
||||
}
|
||||
|
||||
@@ -205,10 +205,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.Directory.GetDirectories(path.Path).Returns([]);
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetSubdirectoryPaths(path, false);
|
||||
Result<IEnumerable<FileSystemPathId>> result = _sut.GetSubdirectoryPaths(path, false);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Empty(result.Value);
|
||||
}
|
||||
|
||||
@@ -220,10 +220,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.Directory.Exists(path.Path).Returns(true);
|
||||
|
||||
// Act
|
||||
ErrorOr<bool> result = _sut.DirectoryExists(path);
|
||||
Result<bool> result = _sut.DirectoryExists(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.True(result.Value);
|
||||
}
|
||||
|
||||
@@ -235,10 +235,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.Directory.Exists(path.Path).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<bool> result = _sut.DirectoryExists(path);
|
||||
Result<bool> result = _sut.DirectoryExists(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.False(result.Value);
|
||||
}
|
||||
|
||||
@@ -253,10 +253,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.Path.GetFileName(fullPath).Returns("file.txt");
|
||||
|
||||
// Act
|
||||
ErrorOr<string> result = _sut.GetFileName(path);
|
||||
Result<string> result = _sut.GetFileName(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal("file.txt", result.Value);
|
||||
}
|
||||
|
||||
@@ -272,10 +272,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.Path.DirectorySeparatorChar.Returns(_dirSeparator);
|
||||
|
||||
// Act
|
||||
ErrorOr<string> result = _sut.GetFileName(path);
|
||||
Result<string> result = _sut.GetFileName(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal("subfolder", result.Value);
|
||||
}
|
||||
|
||||
@@ -291,10 +291,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.Path.DirectorySeparatorChar.Returns(_dirSeparator);
|
||||
|
||||
// Act
|
||||
ErrorOr<string> result = _sut.GetFileName(path);
|
||||
Result<string> result = _sut.GetFileName(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Empty(result.Value);
|
||||
}
|
||||
|
||||
@@ -308,10 +308,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.Directory.GetLastWriteTime(path.Path).Returns(expectedDateTime);
|
||||
|
||||
// Act
|
||||
ErrorOr<Optional<DateTime>> result = _sut.GetLastWriteTime(path);
|
||||
Result<Optional<DateTime>> result = _sut.GetLastWriteTime(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.True(result.Value.HasValue);
|
||||
Assert.Equal(expectedDateTime, result.Value.Value);
|
||||
}
|
||||
@@ -324,10 +324,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties, false).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<Optional<DateTime>> result = _sut.GetLastWriteTime(path);
|
||||
Result<Optional<DateTime>> result = _sut.GetLastWriteTime(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -341,10 +341,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.Directory.GetCreationTime(path.Path).Returns(expectedDateTime);
|
||||
|
||||
// Act
|
||||
ErrorOr<Optional<DateTime>> result = _sut.GetCreationTime(path);
|
||||
Result<Optional<DateTime>> result = _sut.GetCreationTime(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.True(result.Value.HasValue);
|
||||
Assert.Equal(expectedDateTime, result.Value.Value);
|
||||
}
|
||||
@@ -357,10 +357,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties, false).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<Optional<DateTime>> result = _sut.GetCreationTime(path);
|
||||
Result<Optional<DateTime>> result = _sut.GetCreationTime(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -382,10 +382,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.Directory.CreateDirectory(fullPath).Returns(mockDirectoryInfo);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CreateDirectory(parentPath, directoryName);
|
||||
Result<FileSystemPathId> result = _sut.CreateDirectory(parentPath, directoryName);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(fullPath, result.Value.Path);
|
||||
_mockFileSystem.Directory.Received(1).CreateDirectory(fullPath);
|
||||
}
|
||||
@@ -400,10 +400,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(parentPath, FileAccessMode.Write, false).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CreateDirectory(parentPath, directoryName);
|
||||
Result<FileSystemPathId> result = _sut.CreateDirectory(parentPath, directoryName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
_mockFileSystem.Directory.DidNotReceive().CreateDirectory(Arg.Any<string>());
|
||||
}
|
||||
@@ -416,10 +416,10 @@ public class DirectoryProviderServiceTests
|
||||
string directoryName = "NewDirectory";
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CreateDirectory(parentPath, directoryName);
|
||||
Result<FileSystemPathId> result = _sut.CreateDirectory(parentPath, directoryName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(ErrorType.Failure, result.FirstError.Type);
|
||||
}
|
||||
|
||||
@@ -436,10 +436,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.Directory.CreateDirectory(invalidPath).Returns(Substitute.For<IDirectoryInfo>());
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CreateDirectory(parentPath, directoryName);
|
||||
Result<FileSystemPathId> result = _sut.CreateDirectory(parentPath, directoryName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(ErrorType.Validation, result.FirstError.Type);
|
||||
}
|
||||
|
||||
@@ -464,10 +464,10 @@ public class DirectoryProviderServiceTests
|
||||
.Returns(callInfo => Path.Combine(callInfo.ArgAt<string>(0), callInfo.ArgAt<string>(1)));
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CopyDirectory(sourcePath, destinationPath, overrideExisting);
|
||||
Result<FileSystemPathId> result = _sut.CopyDirectory(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(destinationPath.Path, result.Value.Path);
|
||||
_mockFileSystem.Directory.Received(1).CreateDirectory(destinationPath.Path);
|
||||
}
|
||||
@@ -483,10 +483,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.Directory.Exists(sourcePath.Path).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CopyDirectory(sourcePath, destinationPath, overrideExisting);
|
||||
Result<FileSystemPathId> result = _sut.CopyDirectory(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.DirectoryNotFound, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -516,10 +516,10 @@ public class DirectoryProviderServiceTests
|
||||
.Returns(callInfo => Path.Combine(callInfo.ArgAt<string>(0), callInfo.ArgAt<string>(1)));
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CopyDirectory(sourcePath, destinationPath, overrideExisting);
|
||||
Result<FileSystemPathId> result = _sut.CopyDirectory(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(expectedNewDirectoryPath, result.Value.Path);
|
||||
_mockFileSystem.Directory.Received(1).CreateDirectory(expectedNewDirectoryPath);
|
||||
}
|
||||
@@ -568,10 +568,10 @@ public class DirectoryProviderServiceTests
|
||||
.Returns(callInfo => Path.Combine(callInfo.ArgAt<string>(0), callInfo.ArgAt<string>(1)));
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CopyDirectory(sourcePath, destinationPath, overrideExisting);
|
||||
Result<FileSystemPathId> result = _sut.CopyDirectory(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(_pathDestination, result.Value.Path);
|
||||
_mockFileSystem.Directory.Received(1).CreateDirectory(_pathDestination);
|
||||
_mockFileSystem.Directory.Received(1).CreateDirectory(_pathDestinationSubDir);
|
||||
@@ -591,10 +591,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.Directory.CreateDirectory(Arg.Any<string>()).Throws(new Exception("Simulated error"));
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CopyDirectory(sourcePath, destinationPath, overrideExisting);
|
||||
Result<FileSystemPathId> result = _sut.CopyDirectory(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.DirectoryCopyError, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -611,10 +611,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.Directory.Exists(sourcePath.Path).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.MoveDirectory(sourcePath, destinationPath, overrideExisting);
|
||||
Result<FileSystemPathId> result = _sut.MoveDirectory(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.DirectoryNotFound, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -630,10 +630,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.Directory.Exists(destinationPath.Path).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.MoveDirectory(sourcePath, destinationPath, overrideExisting);
|
||||
Result<FileSystemPathId> result = _sut.MoveDirectory(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(destinationPath.Path, result.Value.Path);
|
||||
_mockFileSystem.Directory.Received(1).Move(sourcePath.Path, destinationPath.Path);
|
||||
}
|
||||
@@ -664,10 +664,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.Directory.EnumerateFileSystemEntries(sourcePath.Path).Returns([]);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.MoveDirectory(sourcePath, destinationPath, overrideExisting);
|
||||
Result<FileSystemPathId> result = _sut.MoveDirectory(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(destinationPath.Path, result.Value.Path);
|
||||
_mockFileSystem.File.Received(1).Move(_pathSourceFile1, _pathDestinationFile1);
|
||||
_mockFileSystem.Directory.Received(1).Move(
|
||||
@@ -691,10 +691,10 @@ public class DirectoryProviderServiceTests
|
||||
.Do(x => throw new IOException("Simulated IO error"));
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.MoveDirectory(sourcePath, destinationPath, overrideExisting);
|
||||
Result<FileSystemPathId> result = _sut.MoveDirectory(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.DirectoryMoveError, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -729,10 +729,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.Directory.EnumerateFileSystemEntries(sourcePath.Path).Returns([]);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.MoveDirectory(sourcePath, destPath, overwrite);
|
||||
Result<FileSystemPathId> result = _sut.MoveDirectory(sourcePath, destPath, overwrite);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(destPath, result.Value);
|
||||
_mockFileSystem.File.Received(1).Delete(_pathDestinationFile1);
|
||||
_mockFileSystem.File.Received(1).Move(_pathSourceFile1, _pathDestinationFile1);
|
||||
@@ -767,10 +767,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.Directory.EnumerateFileSystemEntries(sourcePath.Path).Returns([_pathSourceFile2]);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.MoveDirectory(sourcePath, destPath, overwrite);
|
||||
Result<FileSystemPathId> result = _sut.MoveDirectory(sourcePath, destPath, overwrite);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(destPath, result.Value);
|
||||
_mockFileSystem.File.DidNotReceive().Delete(Arg.Any<string>());
|
||||
_mockFileSystem.File.DidNotReceive().Move(_pathSourceFile1, _pathDestinationFile1);
|
||||
@@ -833,10 +833,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.Directory.EnumerateFileSystemEntries(_pathSourceSubDir).Returns([]);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.MoveDirectory(sourcePath, destPath, overwrite);
|
||||
Result<FileSystemPathId> result = _sut.MoveDirectory(sourcePath, destPath, overwrite);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(destPath, result.Value);
|
||||
_mockFileSystem.File.Received(1).Move(
|
||||
s_isUnix ? "/Source/SubDir/file.txt" : @"C:\Source\SubDir\file.txt",
|
||||
@@ -865,10 +865,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.Execute, false).Returns(true);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.RenameDirectory(path, newName);
|
||||
Result<FileSystemPathId> result = _sut.RenameDirectory(path, newName);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(newPath, result.Value.Path);
|
||||
_mockFileSystem.Directory.Received(1).Move(path.Path, newPath);
|
||||
}
|
||||
@@ -891,10 +891,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(Arg.Any<FileSystemPathId>(), FileAccessMode.Write, false).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.RenameDirectory(path, newName);
|
||||
Result<FileSystemPathId> result = _sut.RenameDirectory(path, newName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
_mockFileSystem.Directory.DidNotReceive().Move(Arg.Any<string>(), Arg.Any<string>());
|
||||
}
|
||||
@@ -918,10 +918,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.Execute, false).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.RenameDirectory(path, newName);
|
||||
Result<FileSystemPathId> result = _sut.RenameDirectory(path, newName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
_mockFileSystem.Directory.DidNotReceive().Move(Arg.Any<string>(), Arg.Any<string>());
|
||||
}
|
||||
@@ -938,10 +938,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.Directory.GetParent(path.Path).Returns((IDirectoryInfo)null!);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.RenameDirectory(path, newName);
|
||||
Result<FileSystemPathId> result = _sut.RenameDirectory(path, newName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
_mockFileSystem.Directory.DidNotReceive().Move(Arg.Any<string>(), Arg.Any<string>());
|
||||
}
|
||||
@@ -962,10 +962,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.Path.Combine(parentPath, newName).Returns((string)null!);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.RenameDirectory(path, newName);
|
||||
Result<FileSystemPathId> result = _sut.RenameDirectory(path, newName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
_mockFileSystem.Directory.DidNotReceive().Move(Arg.Any<string>(), Arg.Any<string>());
|
||||
}
|
||||
@@ -982,10 +982,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.DirectoryInfo.New(path.Path).Returns(mockDirectoryInfo);
|
||||
|
||||
// Act
|
||||
ErrorOr<Deleted> result = _sut.DeleteDirectory(path);
|
||||
Result<Deleted> result = _sut.DeleteDirectory(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(Result.Deleted, result.Value);
|
||||
mockDirectoryInfo.Received(1).Delete(true);
|
||||
}
|
||||
@@ -1000,10 +1000,10 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.Delete, false).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<Deleted> result = _sut.DeleteDirectory(path);
|
||||
Result<Deleted> result = _sut.DeleteDirectory(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
_mockFileSystem.DirectoryInfo.DidNotReceive().New(Arg.Any<string>());
|
||||
}
|
||||
|
||||
+131
-104
@@ -1,13 +1,12 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using Lumina.Domain.SharedKernel.Common.Errors;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
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.Strategies.Environment;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
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;
|
||||
@@ -66,23 +65,23 @@ public class DirectoryServiceTests
|
||||
];
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetSubdirectoryPaths(pathId, includeHiddenElements)
|
||||
.Returns(ErrorOrFactory.From(subPaths.AsEnumerable()));
|
||||
.Returns(Result.From(subPaths.AsEnumerable()));
|
||||
|
||||
foreach (FileSystemPathId subPath in subPaths)
|
||||
{
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetFileName(subPath)
|
||||
.Returns(ErrorOrFactory.From(System.IO.Path.GetFileName(subPath.Path)));
|
||||
.Returns(Result.From(System.IO.Path.GetFileName(subPath.Path)));
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetLastWriteTime(subPath)
|
||||
.Returns(ErrorOrFactory.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetCreationTime(subPath)
|
||||
.Returns(ErrorOrFactory.From(Optional<DateTime>.FromNullable(DateTime.Now.AddDays(-1))));
|
||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now.AddDays(-1))));
|
||||
}
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<Directory>> result = _sut.GetSubdirectories(path, includeHiddenElements);
|
||||
Result<IEnumerable<Directory>> result = _sut.GetSubdirectories(path, includeHiddenElements);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(2, result.Value.Count());
|
||||
Assert.Equal(["Sub1", "Sub2"], result.Value.Select(d => d.Name));
|
||||
}
|
||||
@@ -95,10 +94,10 @@ public class DirectoryServiceTests
|
||||
bool includeHiddenElements = false;
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<Directory>> result = _sut.GetSubdirectories(invalidPath, includeHiddenElements);
|
||||
Result<IEnumerable<Directory>> result = _sut.GetSubdirectories(invalidPath, includeHiddenElements);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -114,10 +113,10 @@ public class DirectoryServiceTests
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<Directory>> result = _sut.GetSubdirectories(path, includeHiddenElements);
|
||||
Result<IEnumerable<Directory>> result = _sut.GetSubdirectories(path, includeHiddenElements);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -133,7 +132,7 @@ public class DirectoryServiceTests
|
||||
);
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetSubdirectoryPaths(pathId, includeHiddenElements)
|
||||
.Returns(ErrorOrFactory.From(new[] { subPath }.AsEnumerable()));
|
||||
.Returns(Result.From(new[] { subPath }.AsEnumerable()));
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetFileName(subPath)
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
@@ -143,10 +142,10 @@ public class DirectoryServiceTests
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<Directory>> result = _sut.GetSubdirectories(path, includeHiddenElements);
|
||||
Result<IEnumerable<Directory>> result = _sut.GetSubdirectories(path, includeHiddenElements);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Single(result.Value);
|
||||
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.First().Status);
|
||||
}
|
||||
@@ -164,23 +163,23 @@ public class DirectoryServiceTests
|
||||
];
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetSubdirectoryPaths(parentDirectory.Id, includeHiddenElements)
|
||||
.Returns(ErrorOrFactory.From(subPaths.AsEnumerable()));
|
||||
.Returns(Result.From(subPaths.AsEnumerable()));
|
||||
|
||||
foreach (FileSystemPathId subPath in subPaths)
|
||||
{
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetFileName(subPath)
|
||||
.Returns(ErrorOrFactory.From(System.IO.Path.GetFileName(subPath.Path)));
|
||||
.Returns(Result.From(System.IO.Path.GetFileName(subPath.Path)));
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetLastWriteTime(subPath)
|
||||
.Returns(ErrorOrFactory.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetCreationTime(subPath)
|
||||
.Returns(ErrorOrFactory.From(Optional<DateTime>.FromNullable(DateTime.Now.AddDays(-1))));
|
||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now.AddDays(-1))));
|
||||
}
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<Directory>> result = _sut.GetSubdirectories(parentDirectory, includeHiddenElements);
|
||||
Result<IEnumerable<Directory>> result = _sut.GetSubdirectories(parentDirectory, includeHiddenElements);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(2, result.Value.Count());
|
||||
Assert.Equal(["Sub1", "Sub2"], result.Value.Select(d => d.Name));
|
||||
}
|
||||
@@ -196,10 +195,10 @@ public class DirectoryServiceTests
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<Directory>> result = _sut.GetSubdirectories(parentDirectory, includeHiddenElements);
|
||||
Result<IEnumerable<Directory>> result = _sut.GetSubdirectories(parentDirectory, includeHiddenElements);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -214,7 +213,7 @@ public class DirectoryServiceTests
|
||||
);
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetSubdirectoryPaths(parentDirectory.Id, includeHiddenElements)
|
||||
.Returns(ErrorOrFactory.From(new[] { subPath }.AsEnumerable()));
|
||||
.Returns(Result.From(new[] { subPath }.AsEnumerable()));
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetFileName(subPath)
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
@@ -224,10 +223,10 @@ public class DirectoryServiceTests
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<Directory>> result = _sut.GetSubdirectories(parentDirectory, includeHiddenElements);
|
||||
Result<IEnumerable<Directory>> result = _sut.GetSubdirectories(parentDirectory, includeHiddenElements);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Single(result.Value);
|
||||
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.First().Status);
|
||||
}
|
||||
@@ -245,23 +244,23 @@ public class DirectoryServiceTests
|
||||
];
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetSubdirectoryPaths(pathId, includeHiddenElements)
|
||||
.Returns(ErrorOrFactory.From(subPaths.AsEnumerable()));
|
||||
.Returns(Result.From(subPaths.AsEnumerable()));
|
||||
|
||||
foreach (FileSystemPathId subPath in subPaths)
|
||||
{
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetFileName(subPath)
|
||||
.Returns(ErrorOrFactory.From(System.IO.Path.GetFileName(subPath.Path)));
|
||||
.Returns(Result.From(System.IO.Path.GetFileName(subPath.Path)));
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetLastWriteTime(subPath)
|
||||
.Returns(ErrorOrFactory.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetCreationTime(subPath)
|
||||
.Returns(ErrorOrFactory.From(Optional<DateTime>.FromNullable(DateTime.Now.AddDays(-1))));
|
||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now.AddDays(-1))));
|
||||
}
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<Directory>> result = _sut.GetSubdirectories(pathId, includeHiddenElements);
|
||||
Result<IEnumerable<Directory>> result = _sut.GetSubdirectories(pathId, includeHiddenElements);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(2, result.Value.Count());
|
||||
Assert.Equal(["Sub1", "Sub2"], result.Value.Select(d => d.Name));
|
||||
}
|
||||
@@ -277,10 +276,10 @@ public class DirectoryServiceTests
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<Directory>> result = _sut.GetSubdirectories(pathId, includeHiddenElements);
|
||||
Result<IEnumerable<Directory>> result = _sut.GetSubdirectories(pathId, includeHiddenElements);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -295,7 +294,7 @@ public class DirectoryServiceTests
|
||||
);
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetSubdirectoryPaths(pathId, includeHiddenElements)
|
||||
.Returns(ErrorOrFactory.From(new[] { subPath }.AsEnumerable()));
|
||||
.Returns(Result.From(new[] { subPath }.AsEnumerable()));
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetFileName(subPath)
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
@@ -305,10 +304,10 @@ public class DirectoryServiceTests
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<Directory>> result = _sut.GetSubdirectories(pathId, includeHiddenElements);
|
||||
Result<IEnumerable<Directory>> result = _sut.GetSubdirectories(pathId, includeHiddenElements);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Single(result.Value);
|
||||
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.First().Status);
|
||||
}
|
||||
@@ -322,20 +321,23 @@ public class DirectoryServiceTests
|
||||
FileSystemPathId parentPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(parentPath);
|
||||
FileSystemPathId newDirPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(System.IO.Path.Combine(parentPath, newDirName));
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(parentPathId, newDirName).Returns(Result.From(newDirPathId));
|
||||
_mockEnvironmentContext.DirectoryProviderService.DirectoryExists(newDirPathId).Returns(Result.From(false));
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.CreateDirectory(parentPathId, newDirName)
|
||||
.Returns(ErrorOrFactory.From(newDirPathId));
|
||||
.Returns(Result.From(newDirPathId));
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetFileName(newDirPathId)
|
||||
.Returns(ErrorOrFactory.From(newDirName));
|
||||
.Returns(Result.From(newDirName));
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetLastWriteTime(newDirPathId)
|
||||
.Returns(ErrorOrFactory.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetCreationTime(newDirPathId)
|
||||
.Returns(ErrorOrFactory.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
|
||||
// Act
|
||||
ErrorOr<Directory> result = _sut.CreateDirectory(parentPath, newDirName);
|
||||
Result<Directory> result = _sut.CreateDirectory(parentPath, newDirName);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(newDirPathId, result.Value.Id);
|
||||
}
|
||||
|
||||
@@ -347,10 +349,10 @@ public class DirectoryServiceTests
|
||||
string newDirName = "NewDirectory";
|
||||
|
||||
// Act
|
||||
ErrorOr<Directory> result = _sut.CreateDirectory(invalidPath, newDirName);
|
||||
Result<Directory> result = _sut.CreateDirectory(invalidPath, newDirName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -362,20 +364,23 @@ public class DirectoryServiceTests
|
||||
string newDirName = "NewDirectory";
|
||||
FileSystemPathId newDirPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(System.IO.Path.Combine(parentPathId.Path, newDirName));
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(parentPathId, newDirName).Returns(Result.From(newDirPathId));
|
||||
_mockEnvironmentContext.DirectoryProviderService.DirectoryExists(newDirPathId).Returns(Result.From(false));
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.CreateDirectory(parentPathId, newDirName)
|
||||
.Returns(ErrorOrFactory.From(newDirPathId));
|
||||
.Returns(Result.From(newDirPathId));
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetFileName(newDirPathId)
|
||||
.Returns(ErrorOrFactory.From(newDirName));
|
||||
.Returns(Result.From(newDirName));
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetLastWriteTime(newDirPathId)
|
||||
.Returns(ErrorOrFactory.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetCreationTime(newDirPathId)
|
||||
.Returns(ErrorOrFactory.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
|
||||
// Act
|
||||
ErrorOr<Directory> result = _sut.CreateDirectory(parentPathId, newDirName);
|
||||
Result<Directory> result = _sut.CreateDirectory(parentPathId, newDirName);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(newDirPathId, result.Value.Id);
|
||||
}
|
||||
|
||||
@@ -385,15 +390,19 @@ public class DirectoryServiceTests
|
||||
// Arrange
|
||||
FileSystemPathId parentPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDirTest);
|
||||
string newDirName = "NewDirectory";
|
||||
FileSystemPathId newDirPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(System.IO.Path.Combine(parentPathId.Path, newDirName));
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(parentPathId, newDirName).Returns(Result.From(newDirPathId));
|
||||
_mockEnvironmentContext.DirectoryProviderService.DirectoryExists(newDirPathId).Returns(Result.From(false));
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.CreateDirectory(parentPathId, newDirName)
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<Directory> result = _sut.CreateDirectory(parentPathId, newDirName);
|
||||
Result<Directory> result = _sut.CreateDirectory(parentPathId, newDirName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -405,8 +414,11 @@ public class DirectoryServiceTests
|
||||
string newDirName = "NewDirectory";
|
||||
FileSystemPathId newDirPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(System.IO.Path.Combine(parentPathId.Path, newDirName));
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(parentPathId, newDirName).Returns(Result.From(newDirPathId));
|
||||
_mockEnvironmentContext.DirectoryProviderService.DirectoryExists(newDirPathId).Returns(Result.From(false));
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.CreateDirectory(parentPathId, newDirName)
|
||||
.Returns(ErrorOrFactory.From(newDirPathId));
|
||||
.Returns(Result.From(newDirPathId));
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetFileName(newDirPathId)
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
@@ -416,10 +428,10 @@ public class DirectoryServiceTests
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<Directory> result = _sut.CreateDirectory(parentPathId, newDirName);
|
||||
Result<Directory> result = _sut.CreateDirectory(parentPathId, newDirName);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.Status);
|
||||
Assert.Equal(newDirPathId, result.Value.Id);
|
||||
Assert.False(result.Value.DateCreated.HasValue);
|
||||
@@ -434,15 +446,15 @@ public class DirectoryServiceTests
|
||||
string newDirName = "NewDirectory";
|
||||
FileSystemPathId newDirPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(System.IO.Path.Combine(parentPathId.Path, newDirName));
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(parentPathId, newDirName).Returns(ErrorOrFactory.From(newDirPathId));
|
||||
_mockPlatformContext.PathStrategy.CombinePath(parentPathId, newDirName).Returns(Result.From(newDirPathId));
|
||||
_mockEnvironmentContext.DirectoryProviderService.DirectoryExists(newDirPathId)
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<Directory> result = _sut.CreateDirectory(parentPathId, newDirName);
|
||||
Result<Directory> result = _sut.CreateDirectory(parentPathId, newDirName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -453,15 +465,15 @@ public class DirectoryServiceTests
|
||||
FileSystemPathId parentPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDirTest);
|
||||
string newDirName = "ExistingDirectory";
|
||||
FileSystemPathId newDirPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(System.IO.Path.Combine(parentPathId.Path, newDirName));
|
||||
_mockPlatformContext.PathStrategy.CombinePath(parentPathId, newDirName).Returns(ErrorOrFactory.From(newDirPathId));
|
||||
_mockPlatformContext.PathStrategy.CombinePath(parentPathId, newDirName).Returns(Result.From(newDirPathId));
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.DirectoryExists(newDirPathId).Returns(true);
|
||||
|
||||
// Act
|
||||
ErrorOr<Directory> result = _sut.CreateDirectory(parentPathId, newDirName);
|
||||
Result<Directory> result = _sut.CreateDirectory(parentPathId, newDirName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.DirectoryAlreadyExists, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -476,10 +488,10 @@ public class DirectoryServiceTests
|
||||
.Returns(Errors.FileSystemManagement.InvalidPath);
|
||||
|
||||
// Act
|
||||
ErrorOr<Directory> result = _sut.CreateDirectory(parentPathId, newDirName);
|
||||
Result<Directory> result = _sut.CreateDirectory(parentPathId, newDirName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
|
||||
// Verify that DirectoryExists was not called
|
||||
@@ -498,20 +510,23 @@ public class DirectoryServiceTests
|
||||
s_isUnix ? "/TestDir/NewName" : @"C:\TestDir\NewName"
|
||||
);
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(oldPathId, newName).Returns(Result.From(newPathId));
|
||||
_mockEnvironmentContext.DirectoryProviderService.DirectoryExists(newPathId).Returns(Result.From(false));
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.RenameDirectory(oldPathId, newName)
|
||||
.Returns(ErrorOrFactory.From(newPathId));
|
||||
.Returns(Result.From(newPathId));
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetFileName(newPathId)
|
||||
.Returns(ErrorOrFactory.From(newName));
|
||||
.Returns(Result.From(newName));
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetLastWriteTime(newPathId)
|
||||
.Returns(ErrorOrFactory.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetCreationTime(newPathId)
|
||||
.Returns(ErrorOrFactory.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
|
||||
// Act
|
||||
ErrorOr<Directory> result = _sut.RenameDirectory(oldPath, newName);
|
||||
Result<Directory> result = _sut.RenameDirectory(oldPath, newName);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(newPathId, result.Value.Id);
|
||||
Assert.Equal(newName, result.Value.Name);
|
||||
}
|
||||
@@ -524,10 +539,10 @@ public class DirectoryServiceTests
|
||||
string newName = "NewName";
|
||||
|
||||
// Act
|
||||
ErrorOr<Directory> result = _sut.RenameDirectory(invalidPath, newName);
|
||||
Result<Directory> result = _sut.RenameDirectory(invalidPath, newName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -543,20 +558,23 @@ public class DirectoryServiceTests
|
||||
s_isUnix ? "/TestDir/NewName" : @"C:\TestDir\NewName"
|
||||
);
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(oldPathId, newName).Returns(Result.From(newPathId));
|
||||
_mockEnvironmentContext.DirectoryProviderService.DirectoryExists(newPathId).Returns(Result.From(false));
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.RenameDirectory(oldPathId, newName)
|
||||
.Returns(ErrorOrFactory.From(newPathId));
|
||||
.Returns(Result.From(newPathId));
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetFileName(newPathId)
|
||||
.Returns(ErrorOrFactory.From(newName));
|
||||
.Returns(Result.From(newName));
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetLastWriteTime(newPathId)
|
||||
.Returns(ErrorOrFactory.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetCreationTime(newPathId)
|
||||
.Returns(ErrorOrFactory.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
|
||||
// Act
|
||||
ErrorOr<Directory> result = _sut.RenameDirectory(oldPathId, newName);
|
||||
Result<Directory> result = _sut.RenameDirectory(oldPathId, newName);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(newPathId, result.Value.Id);
|
||||
Assert.Equal(newName, result.Value.Name);
|
||||
}
|
||||
@@ -569,15 +587,21 @@ public class DirectoryServiceTests
|
||||
s_isUnix ? "/TestDir/OldName" : @"C:\TestDir\OldName"
|
||||
);
|
||||
string newName = "NewName";
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isUnix ? "/TestDir/NewName" : @"C:\TestDir\NewName"
|
||||
);
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(oldPathId, newName).Returns(Result.From(newPathId));
|
||||
_mockEnvironmentContext.DirectoryProviderService.DirectoryExists(newPathId).Returns(Result.From(false));
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.RenameDirectory(oldPathId, newName)
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<Directory> result = _sut.RenameDirectory(oldPathId, newName);
|
||||
Result<Directory> result = _sut.RenameDirectory(oldPathId, newName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -593,8 +617,11 @@ public class DirectoryServiceTests
|
||||
s_isUnix ? "/TestDir/NewName" : @"C:\TestDir\NewName"
|
||||
);
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(oldPathId, newName).Returns(Result.From(newPathId));
|
||||
_mockEnvironmentContext.DirectoryProviderService.DirectoryExists(newPathId).Returns(Result.From(false));
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.RenameDirectory(oldPathId, newName)
|
||||
.Returns(ErrorOrFactory.From(newPathId));
|
||||
.Returns(Result.From(newPathId));
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetFileName(newPathId)
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
@@ -604,10 +631,10 @@ public class DirectoryServiceTests
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<Directory> result = _sut.RenameDirectory(oldPathId, newName);
|
||||
Result<Directory> result = _sut.RenameDirectory(oldPathId, newName);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.Status);
|
||||
Assert.Equal(newPathId, result.Value.Id);
|
||||
Assert.False(result.Value.DateCreated.HasValue);
|
||||
@@ -627,15 +654,15 @@ public class DirectoryServiceTests
|
||||
);
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
.Returns(ErrorOrFactory.From(newPathId));
|
||||
.Returns(Result.From(newPathId));
|
||||
_mockEnvironmentContext.DirectoryProviderService.DirectoryExists(newPathId)
|
||||
.Returns(ErrorOrFactory.From(true));
|
||||
.Returns(Result.From(true));
|
||||
|
||||
// Act
|
||||
ErrorOr<Directory> result = _sut.RenameDirectory(oldPathId, newName);
|
||||
Result<Directory> result = _sut.RenameDirectory(oldPathId, newName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.DirectoryAlreadyExists, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -652,10 +679,10 @@ public class DirectoryServiceTests
|
||||
.Returns(Errors.FileSystemManagement.InvalidPath);
|
||||
|
||||
// Act
|
||||
ErrorOr<Directory> result = _sut.RenameDirectory(oldPathId, newName);
|
||||
Result<Directory> result = _sut.RenameDirectory(oldPathId, newName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
|
||||
// Verify that DirectoryExists and RenameDirectory were not called
|
||||
@@ -675,16 +702,16 @@ public class DirectoryServiceTests
|
||||
s_isUnix ? "/TestDir/NewName" : @"C:\TestDir\NewName"
|
||||
);
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
.Returns(ErrorOrFactory.From(newPathId));
|
||||
.Returns(Result.From(newPathId));
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.DirectoryExists(newPathId)
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<Directory> result = _sut.RenameDirectory(oldPathId, newName);
|
||||
Result<Directory> result = _sut.RenameDirectory(oldPathId, newName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
|
||||
// Verify that RenameDirectory was not called
|
||||
@@ -702,10 +729,10 @@ public class DirectoryServiceTests
|
||||
.Returns(Result.Deleted);
|
||||
|
||||
// Act
|
||||
ErrorOr<Deleted> result = _sut.DeleteDirectory(path);
|
||||
Result<Deleted> result = _sut.DeleteDirectory(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(Result.Deleted, result.Value);
|
||||
}
|
||||
|
||||
@@ -716,10 +743,10 @@ public class DirectoryServiceTests
|
||||
string invalidPath = string.Empty;
|
||||
|
||||
// Act
|
||||
ErrorOr<Deleted> result = _sut.DeleteDirectory(invalidPath);
|
||||
Result<Deleted> result = _sut.DeleteDirectory(invalidPath);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -735,10 +762,10 @@ public class DirectoryServiceTests
|
||||
.Returns(Result.Deleted);
|
||||
|
||||
// Act
|
||||
ErrorOr<Deleted> result = _sut.DeleteDirectory(pathId);
|
||||
Result<Deleted> result = _sut.DeleteDirectory(pathId);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(Result.Deleted, result.Value);
|
||||
}
|
||||
|
||||
@@ -754,10 +781,10 @@ public class DirectoryServiceTests
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<Deleted> result = _sut.DeleteDirectory(pathId);
|
||||
Result<Deleted> result = _sut.DeleteDirectory(pathId);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -773,10 +800,10 @@ public class DirectoryServiceTests
|
||||
.Returns(Errors.FileSystemManagement.DirectoryNotFound);
|
||||
|
||||
// Act
|
||||
ErrorOr<Deleted> result = _sut.DeleteDirectory(pathId);
|
||||
Result<Deleted> result = _sut.DeleteDirectory(pathId);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.DirectoryNotFound, result.FirstError);
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -1,10 +1,10 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
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.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using NSubstitute;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -44,10 +44,10 @@ public class DriveServiceTests
|
||||
_mockPlatformContext.Platform.Returns(PlatformType.Unix);
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<FileSystemItem>> result = _sut.GetDrives();
|
||||
Result<IEnumerable<FileSystemItem>> result = _sut.GetDrives();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Single(result.Value);
|
||||
Assert.IsType<UnixRootItem>(result.Value.First());
|
||||
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.First().Status);
|
||||
@@ -67,10 +67,10 @@ public class DriveServiceTests
|
||||
_mockFileSystem.DriveInfo.GetDrives().Returns(mockDrives);
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<FileSystemItem>> result = _sut.GetDrives();
|
||||
Result<IEnumerable<FileSystemItem>> result = _sut.GetDrives();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(2, result.Value.Count()); // Only ready drives
|
||||
Assert.All(result.Value, item => Assert.IsType<WindowsRootItem>(item));
|
||||
Assert.Equal(["C:\\", "D:\\"], result.Value.Select(d => d.Name));
|
||||
|
||||
+83
-84
@@ -1,12 +1,11 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using AutoFixture;
|
||||
using AutoFixture.AutoNSubstitute;
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using Lumina.Domain.SharedKernel.Common.Errors;
|
||||
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.SharedKernel.Common.Enums.FileSystem;
|
||||
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.ValueObjects.Fixtures;
|
||||
using NSubstitute;
|
||||
using NSubstitute.ExceptionExtensions;
|
||||
@@ -62,10 +61,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ListDirectory).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetFilePaths(path, false);
|
||||
Result<IEnumerable<FileSystemPathId>> result = _sut.GetFilePaths(path, false);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -79,10 +78,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.Directory.GetFiles(path.Path).Returns(files);
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetFilePaths(path, false);
|
||||
Result<IEnumerable<FileSystemPathId>> result = _sut.GetFilePaths(path, false);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(3, result.Value.Count());
|
||||
Assert.Equal(
|
||||
files.OrderBy(f => f),
|
||||
@@ -102,10 +101,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.File.GetAttributes(_pathHidden1).Returns(FileAttributes.Hidden);
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetFilePaths(path, false);
|
||||
Result<IEnumerable<FileSystemPathId>> result = _sut.GetFilePaths(path, false);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Single(result.Value);
|
||||
Assert.Equal(_pathVisible1, result.Value.First().Path);
|
||||
}
|
||||
@@ -122,10 +121,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.File.GetAttributes(_pathHidden1).Returns(FileAttributes.Hidden);
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetFilePaths(path, true);
|
||||
Result<IEnumerable<FileSystemPathId>> result = _sut.GetFilePaths(path, true);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(2, result.Value.Count());
|
||||
Assert.Equal(
|
||||
new[] { _pathVisible1, _pathHidden1 }.OrderBy(p => p),
|
||||
@@ -145,10 +144,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.File.GetAttributes(_pathInvalid1).Throws(new Exception("Access denied"));
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetFilePaths(path, false);
|
||||
Result<IEnumerable<FileSystemPathId>> result = _sut.GetFilePaths(path, false);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(2, result.Value.Count());
|
||||
Assert.Equal([_pathInvalid1, _pathValid1], result.Value.Select(x => x.Path));
|
||||
}
|
||||
@@ -169,10 +168,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.File.GetAttributes(Arg.Any<string>()).Returns(FileAttributes.Normal);
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetFilePaths(path, false);
|
||||
Result<IEnumerable<FileSystemPathId>> result = _sut.GetFilePaths(path, false);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(expectedFiles, result.Value.Select(x => x.Path));
|
||||
}
|
||||
|
||||
@@ -185,10 +184,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.Directory.GetFiles(path.Path).Returns([]);
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetFilePaths(path, false);
|
||||
Result<IEnumerable<FileSystemPathId>> result = _sut.GetFilePaths(path, false);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Empty(result.Value);
|
||||
}
|
||||
|
||||
@@ -200,10 +199,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.File.Exists(path.Path).Returns(true);
|
||||
|
||||
// Act
|
||||
ErrorOr<bool> result = _sut.FileExists(path);
|
||||
Result<bool> result = _sut.FileExists(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.True(result.Value);
|
||||
}
|
||||
|
||||
@@ -215,10 +214,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.File.Exists(path.Path).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<bool> result = _sut.FileExists(path);
|
||||
Result<bool> result = _sut.FileExists(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.False(result.Value);
|
||||
}
|
||||
|
||||
@@ -231,10 +230,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.Path.GetFileName(path.Path).Returns(expectedFileName);
|
||||
|
||||
// Act
|
||||
ErrorOr<string> result = _sut.GetFileName(path);
|
||||
Result<string> result = _sut.GetFileName(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(expectedFileName, result.Value);
|
||||
}
|
||||
|
||||
@@ -246,10 +245,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.Path.GetFileName(path.Path).Returns(string.Empty);
|
||||
|
||||
// Act
|
||||
ErrorOr<string> result = _sut.GetFileName(path);
|
||||
Result<string> result = _sut.GetFileName(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Empty(result.Value);
|
||||
}
|
||||
|
||||
@@ -270,10 +269,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.File.ReadAllBytes(tempFilePath).Returns(x => File.ReadAllBytes(x.Arg<string>()));
|
||||
|
||||
// Act
|
||||
ErrorOr<byte[]> result = _sut.GetFileAsync(path);
|
||||
Result<byte[]> result = _sut.GetFileAsync(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(expectedContents, result.Value);
|
||||
}
|
||||
finally
|
||||
@@ -291,10 +290,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadContents).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<byte[]> result = _sut.GetFileAsync(path);
|
||||
Result<byte[]> result = _sut.GetFileAsync(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -309,10 +308,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadContents).Returns(true);
|
||||
|
||||
// Act
|
||||
ErrorOr<byte[]> result = _sut.GetFileAsync(path);
|
||||
Result<byte[]> result = _sut.GetFileAsync(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Empty(result.Value);
|
||||
}
|
||||
finally
|
||||
@@ -337,10 +336,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.File.GetLastWriteTime(path.Path).Returns(expectedDateTime);
|
||||
|
||||
// Act
|
||||
ErrorOr<Optional<DateTime>> result = _sut.GetLastWriteTime(path);
|
||||
Result<Optional<DateTime>> result = _sut.GetLastWriteTime(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.True(result.Value.HasValue);
|
||||
Assert.Equal(expectedDateTime, result.Value.Value, TimeSpan.FromSeconds(1));
|
||||
}
|
||||
@@ -358,10 +357,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<Optional<DateTime>> result = _sut.GetLastWriteTime(path);
|
||||
Result<Optional<DateTime>> result = _sut.GetLastWriteTime(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -380,10 +379,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.File.GetCreationTime(path.Path).Returns(expectedDateTime);
|
||||
|
||||
// Act
|
||||
ErrorOr<Optional<DateTime>> result = _sut.GetCreationTime(path);
|
||||
Result<Optional<DateTime>> result = _sut.GetCreationTime(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.True(result.Value.HasValue);
|
||||
Assert.Equal(expectedDateTime, result.Value.Value, TimeSpan.FromSeconds(1));
|
||||
}
|
||||
@@ -401,10 +400,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<Optional<DateTime>> result = _sut.GetCreationTime(path);
|
||||
Result<Optional<DateTime>> result = _sut.GetCreationTime(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -424,10 +423,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.FileInfo.New(path.Path).Returns(new FileInfoWrapper(_mockFileSystem, new FileInfo(tempFilePath)));
|
||||
|
||||
// Act
|
||||
ErrorOr<long?> result = _sut.GetSize(path);
|
||||
Result<long?> result = _sut.GetSize(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(expectedSize, result.Value);
|
||||
}
|
||||
@@ -445,10 +444,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<long?> result = _sut.GetSize(path);
|
||||
Result<long?> result = _sut.GetSize(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -463,10 +462,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.FileInfo.New(path.Path).Returns((IFileInfo)null!);
|
||||
|
||||
// Act
|
||||
ErrorOr<long?> result = _sut.GetSize(path);
|
||||
Result<long?> result = _sut.GetSize(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(0, result.Value);
|
||||
}
|
||||
|
||||
@@ -485,10 +484,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.Path.Combine(destinationPath.Path, "file.txt").Returns(_pathDestinationFile);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
|
||||
Result<FileSystemPathId> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(_pathDestinationFile, result.Value.Path);
|
||||
_mockFileSystem.File.Received(1).Copy(sourcePath.Path, _pathDestinationFile, overrideExisting);
|
||||
}
|
||||
@@ -504,10 +503,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.File.Exists(sourcePath.Path).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
|
||||
Result<FileSystemPathId> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.FileNotFound, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -530,10 +529,10 @@ public class FileProviderServiceTests
|
||||
.Returns(callInfo => Path.Combine(callInfo.ArgAt<string>(0), callInfo.ArgAt<string>(1)));
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
|
||||
Result<FileSystemPathId> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.FileAlreadyExists, result.FirstError);
|
||||
_mockFileSystem.File.DidNotReceive().Copy(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<bool>());
|
||||
}
|
||||
@@ -553,10 +552,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.Path.Combine(destinationPath.Path, "file.txt").Returns(_pathDestinationFile);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
|
||||
Result<FileSystemPathId> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(_pathDestinationFile, result.Value.Path);
|
||||
_mockFileSystem.File.Received(1).Copy(sourcePath.Path, _pathDestinationFile, overrideExisting);
|
||||
}
|
||||
@@ -574,10 +573,10 @@ public class FileProviderServiceTests
|
||||
.Do(x => { throw new Exception("Simulated error"); });
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
|
||||
Result<FileSystemPathId> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.FileCopyError, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -616,10 +615,10 @@ public class FileProviderServiceTests
|
||||
});
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
|
||||
Result<FileSystemPathId> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(expectedNewFilePath, result.Value.Path);
|
||||
_mockFileSystem.File.Received(1).Copy(sourcePath.Path, expectedNewFilePath, overrideExisting);
|
||||
}
|
||||
@@ -637,10 +636,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.File.Exists(sourcePath.Path).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
|
||||
Result<FileSystemPathId> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.FileNotFound, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -659,10 +658,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.Path.Combine(destinationPath.Path, "file.txt").Returns(destinationFilePath);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
|
||||
Result<FileSystemPathId> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(destinationFilePath, result.Value.Path);
|
||||
_mockFileSystem.File.Received(1).Move(sourcePath.Path, destinationFilePath);
|
||||
}
|
||||
@@ -682,10 +681,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.Path.Combine(destinationPath.Path, "file.txt").Returns(destinationFilePath);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
|
||||
Result<FileSystemPathId> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(destinationFilePath, result.Value.Path);
|
||||
_mockFileSystem.File.Received(1).Move(sourcePath.Path, destinationFilePath, overrideExisting);
|
||||
}
|
||||
@@ -705,10 +704,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.Path.Combine(destinationPath.Path, "file.txt").Returns(destinationFilePath);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
|
||||
Result<FileSystemPathId> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.FileAlreadyExists, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -729,10 +728,10 @@ public class FileProviderServiceTests
|
||||
.Do(x => throw new IOException("Simulated IO error"));
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
|
||||
Result<FileSystemPathId> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.FileMoveError, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -755,10 +754,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.Execute).Returns(true);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.RenameFile(path, newName);
|
||||
Result<FileSystemPathId> result = _sut.RenameFile(path, newName);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(newPath, result.Value.Path);
|
||||
_mockFileSystem.File.Received(1).Move(path.Path, newPath);
|
||||
}
|
||||
@@ -781,10 +780,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(Arg.Any<FileSystemPathId>(), FileAccessMode.Write).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.RenameFile(path, newName);
|
||||
Result<FileSystemPathId> result = _sut.RenameFile(path, newName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
_mockFileSystem.File.DidNotReceive().Move(Arg.Any<string>(), Arg.Any<string>());
|
||||
}
|
||||
@@ -808,10 +807,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.Execute).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.RenameFile(path, newName);
|
||||
Result<FileSystemPathId> result = _sut.RenameFile(path, newName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
_mockFileSystem.File.DidNotReceive().Move(Arg.Any<string>(), Arg.Any<string>());
|
||||
}
|
||||
@@ -828,10 +827,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.FileInfo.New(path.Path).Returns((IFileInfo)null!);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.RenameFile(path, newName);
|
||||
Result<FileSystemPathId> result = _sut.RenameFile(path, newName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.CannotNavigateUp, result.FirstError);
|
||||
_mockFileSystem.File.DidNotReceive().Move(Arg.Any<string>(), Arg.Any<string>());
|
||||
}
|
||||
@@ -852,10 +851,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.Path.Combine(parentPath, newName).Returns((string)null!);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.RenameFile(path, newName);
|
||||
Result<FileSystemPathId> result = _sut.RenameFile(path, newName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
_mockFileSystem.File.DidNotReceive().Move(Arg.Any<string>(), Arg.Any<string>());
|
||||
}
|
||||
@@ -877,7 +876,7 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.Path.Combine(parentPath, newName).Returns(newPath);
|
||||
|
||||
// Mock successful creation of parent directory FileSystemPathId
|
||||
ErrorOr<FileSystemPathId> parentDirectoryPathId = FileSystemPathId.Create(parentPath);
|
||||
Result<FileSystemPathId> parentDirectoryPathId = FileSystemPathId.Create(parentPath);
|
||||
_mockFileSystem.Path.GetDirectoryName(path.Path).Returns(parentPath);
|
||||
|
||||
// Mock permissions: executable for the file, but not writable for the parent directory
|
||||
@@ -885,10 +884,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(Arg.Is<FileSystemPathId>(x => x.Path == parentPath), FileAccessMode.Write).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.RenameFile(path, newName);
|
||||
Result<FileSystemPathId> result = _sut.RenameFile(path, newName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
_mockFileSystem.File.DidNotReceive().Move(Arg.Any<string>(), Arg.Any<string>());
|
||||
}
|
||||
@@ -904,10 +903,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.File.Exists(path.Path).Returns(true);
|
||||
|
||||
// Act
|
||||
ErrorOr<Deleted> result = _sut.DeleteFile(path);
|
||||
Result<Deleted> result = _sut.DeleteFile(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(Result.Deleted, result.Value);
|
||||
_mockFileSystem.File.Received(1).Delete(path.Path);
|
||||
}
|
||||
@@ -922,10 +921,10 @@ public class FileProviderServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.Delete).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<Deleted> result = _sut.DeleteFile(path);
|
||||
Result<Deleted> result = _sut.DeleteFile(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
_mockFileSystem.File.DidNotReceive().Delete(Arg.Any<string>());
|
||||
}
|
||||
|
||||
+153
-154
@@ -1,13 +1,12 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using Lumina.Domain.SharedKernel.Common.Errors;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
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.Strategies.Environment;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
|
||||
using Lumina.Domain.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;
|
||||
@@ -76,25 +75,25 @@ public class FileServiceTests
|
||||
];
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.GetFilePaths(pathId, includeHiddenElements)
|
||||
.Returns(ErrorOrFactory.From(filePaths.AsEnumerable()));
|
||||
.Returns(Result.From(filePaths.AsEnumerable()));
|
||||
|
||||
foreach (FileSystemPathId filePath in filePaths)
|
||||
{
|
||||
_mockEnvironmentContext.FileProviderService.GetFileName(filePath)
|
||||
.Returns(ErrorOrFactory.From(System.IO.Path.GetFileName(filePath.Path)));
|
||||
.Returns(Result.From(System.IO.Path.GetFileName(filePath.Path)));
|
||||
_mockEnvironmentContext.FileProviderService.GetLastWriteTime(filePath)
|
||||
.Returns(ErrorOrFactory.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
_mockEnvironmentContext.FileProviderService.GetCreationTime(filePath)
|
||||
.Returns(ErrorOrFactory.From(Optional<DateTime>.FromNullable(DateTime.Now.AddDays(-1))));
|
||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now.AddDays(-1))));
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(filePath)
|
||||
.Returns(ErrorOrFactory.From((long?)1024));
|
||||
.Returns(Result.From((long?)1024));
|
||||
}
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<File>> result = _sut.GetFiles(path, includeHiddenElements);
|
||||
Result<IEnumerable<File>> result = _sut.GetFiles(path, includeHiddenElements);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(2, result.Value.Count());
|
||||
Assert.Equal(["File1.txt", "File2.txt"], result.Value.Select(f => f.Name));
|
||||
}
|
||||
@@ -107,10 +106,10 @@ public class FileServiceTests
|
||||
bool includeHiddenElements = false;
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<File>> result = _sut.GetFiles(invalidPath, includeHiddenElements);
|
||||
Result<IEnumerable<File>> result = _sut.GetFiles(invalidPath, includeHiddenElements);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -126,10 +125,10 @@ public class FileServiceTests
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<File>> result = _sut.GetFiles(path, includeHiddenElements);
|
||||
Result<IEnumerable<File>> result = _sut.GetFiles(path, includeHiddenElements);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -143,7 +142,7 @@ public class FileServiceTests
|
||||
FileSystemPathId filePath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathTestDirInaccessible);
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.GetFilePaths(pathId, includeHiddenElements)
|
||||
.Returns(ErrorOrFactory.From(new[] { filePath }.AsEnumerable()));
|
||||
.Returns(Result.From(new[] { filePath }.AsEnumerable()));
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.GetFileName(filePath)
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
@@ -152,13 +151,13 @@ public class FileServiceTests
|
||||
_mockEnvironmentContext.FileProviderService.GetCreationTime(filePath)
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(filePath)
|
||||
.Returns(ErrorOrFactory.From((long?)null));
|
||||
.Returns(Result.From((long?)null));
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<File>> result = _sut.GetFiles(path, includeHiddenElements);
|
||||
Result<IEnumerable<File>> result = _sut.GetFiles(path, includeHiddenElements);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Single(result.Value);
|
||||
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.First().Status);
|
||||
}
|
||||
@@ -176,25 +175,25 @@ public class FileServiceTests
|
||||
];
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.GetFilePaths(parentFile.Id, includeHiddenElements)
|
||||
.Returns(ErrorOrFactory.From(filePaths.AsEnumerable()));
|
||||
.Returns(Result.From(filePaths.AsEnumerable()));
|
||||
|
||||
foreach (FileSystemPathId filePath in filePaths)
|
||||
{
|
||||
_mockEnvironmentContext.FileProviderService.GetFileName(filePath)
|
||||
.Returns(ErrorOrFactory.From(System.IO.Path.GetFileName(filePath.Path)));
|
||||
.Returns(Result.From(System.IO.Path.GetFileName(filePath.Path)));
|
||||
_mockEnvironmentContext.FileProviderService.GetLastWriteTime(filePath)
|
||||
.Returns(ErrorOrFactory.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
_mockEnvironmentContext.FileProviderService.GetCreationTime(filePath)
|
||||
.Returns(ErrorOrFactory.From(Optional<DateTime>.FromNullable(DateTime.Now.AddDays(-1))));
|
||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now.AddDays(-1))));
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(filePath)
|
||||
.Returns(ErrorOrFactory.From((long?)1024));
|
||||
.Returns(Result.From((long?)1024));
|
||||
}
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<File>> result = _sut.GetFiles(parentFile, includeHiddenElements);
|
||||
Result<IEnumerable<File>> result = _sut.GetFiles(parentFile, includeHiddenElements);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(2, result.Value.Count());
|
||||
Assert.Equal(["File1.txt", "File2.txt"], result.Value.Select(f => f.Name));
|
||||
}
|
||||
@@ -210,10 +209,10 @@ public class FileServiceTests
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<File>> result = _sut.GetFiles(parentFile, includeHiddenElements);
|
||||
Result<IEnumerable<File>> result = _sut.GetFiles(parentFile, includeHiddenElements);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -226,7 +225,7 @@ public class FileServiceTests
|
||||
FileSystemPathId filePath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathTestDirInaccessible);
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.GetFilePaths(parentFile.Id, includeHiddenElements)
|
||||
.Returns(ErrorOrFactory.From(new[] { filePath }.AsEnumerable()));
|
||||
.Returns(Result.From(new[] { filePath }.AsEnumerable()));
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.GetFileName(filePath)
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
@@ -235,13 +234,13 @@ public class FileServiceTests
|
||||
_mockEnvironmentContext.FileProviderService.GetCreationTime(filePath)
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(filePath)
|
||||
.Returns(ErrorOrFactory.From((long?)null));
|
||||
.Returns(Result.From((long?)null));
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<File>> result = _sut.GetFiles(parentFile, includeHiddenElements);
|
||||
Result<IEnumerable<File>> result = _sut.GetFiles(parentFile, includeHiddenElements);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Single(result.Value);
|
||||
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.First().Status);
|
||||
}
|
||||
@@ -259,25 +258,25 @@ public class FileServiceTests
|
||||
];
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.GetFilePaths(pathId, includeHiddenElements)
|
||||
.Returns(ErrorOrFactory.From(filePaths.AsEnumerable()));
|
||||
.Returns(Result.From(filePaths.AsEnumerable()));
|
||||
|
||||
foreach (FileSystemPathId filePath in filePaths)
|
||||
{
|
||||
_mockEnvironmentContext.FileProviderService.GetFileName(filePath)
|
||||
.Returns(ErrorOrFactory.From(System.IO.Path.GetFileName(filePath.Path)));
|
||||
.Returns(Result.From(System.IO.Path.GetFileName(filePath.Path)));
|
||||
_mockEnvironmentContext.FileProviderService.GetLastWriteTime(filePath)
|
||||
.Returns(ErrorOrFactory.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
_mockEnvironmentContext.FileProviderService.GetCreationTime(filePath)
|
||||
.Returns(ErrorOrFactory.From(Optional<DateTime>.FromNullable(DateTime.Now.AddDays(-1))));
|
||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now.AddDays(-1))));
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(filePath)
|
||||
.Returns(ErrorOrFactory.From((long?)1024));
|
||||
.Returns(Result.From((long?)1024));
|
||||
}
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<File>> result = _sut.GetFiles(pathId, includeHiddenElements);
|
||||
Result<IEnumerable<File>> result = _sut.GetFiles(pathId, includeHiddenElements);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(2, result.Value.Count());
|
||||
Assert.Equal(["File1.txt", "File2.txt"], result.Value.Select(f => f.Name));
|
||||
}
|
||||
@@ -293,10 +292,10 @@ public class FileServiceTests
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<File>> result = _sut.GetFiles(pathId, includeHiddenElements);
|
||||
Result<IEnumerable<File>> result = _sut.GetFiles(pathId, includeHiddenElements);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -309,7 +308,7 @@ public class FileServiceTests
|
||||
FileSystemPathId filePath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathTestDirInaccessible);
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.GetFilePaths(pathId, includeHiddenElements)
|
||||
.Returns(ErrorOrFactory.From(new[] { filePath }.AsEnumerable()));
|
||||
.Returns(Result.From(new[] { filePath }.AsEnumerable()));
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.GetFileName(filePath)
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
@@ -318,13 +317,13 @@ public class FileServiceTests
|
||||
_mockEnvironmentContext.FileProviderService.GetCreationTime(filePath)
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(filePath)
|
||||
.Returns(ErrorOrFactory.From((long?)null));
|
||||
.Returns(Result.From((long?)null));
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<File>> result = _sut.GetFiles(pathId, includeHiddenElements);
|
||||
Result<IEnumerable<File>> result = _sut.GetFiles(pathId, includeHiddenElements);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Single(result.Value);
|
||||
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.First().Status);
|
||||
}
|
||||
@@ -354,10 +353,10 @@ public class FileServiceTests
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(copiedFilePathId).Returns((long?)1024);
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
|
||||
Result<File> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal("file.txt", result.Value.Name);
|
||||
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
|
||||
@@ -372,13 +371,13 @@ public class FileServiceTests
|
||||
bool overrideExisting = true;
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(sourcePath);
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(sourcePathId).Returns(ErrorOrFactory.From(false));
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(sourcePathId).Returns(Result.From(false));
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
|
||||
Result<File> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.FileNotFound, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -393,15 +392,15 @@ public class FileServiceTests
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(destinationPath);
|
||||
|
||||
_mockPlatformContext.PathStrategy.PathSeparator.Returns(_dirSeparator);
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(sourcePathId).Returns(ErrorOrFactory.From(true));
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(sourcePathId).Returns(Result.From(true));
|
||||
_mockEnvironmentContext.FileProviderService.CopyFile(sourcePathId, destinationPathId, overrideExisting)
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
|
||||
Result<File> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -417,20 +416,20 @@ public class FileServiceTests
|
||||
FileSystemPathId copiedFilePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestinationFile);
|
||||
|
||||
_mockPlatformContext.PathStrategy.PathSeparator.Returns(_dirSeparator);
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(sourcePathId).Returns(ErrorOrFactory.From(true));
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(sourcePathId).Returns(Result.From(true));
|
||||
_mockEnvironmentContext.FileProviderService.CopyFile(sourcePathId, destinationPathId, overrideExisting)
|
||||
.Returns(ErrorOrFactory.From(copiedFilePathId));
|
||||
.Returns(Result.From(copiedFilePathId));
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.GetFileName(copiedFilePathId).Returns(Errors.Permission.UnauthorizedAccess);
|
||||
_mockEnvironmentContext.FileProviderService.GetLastWriteTime(copiedFilePathId).Returns(Errors.Permission.UnauthorizedAccess);
|
||||
_mockEnvironmentContext.FileProviderService.GetCreationTime(copiedFilePathId).Returns(Errors.Permission.UnauthorizedAccess);
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(copiedFilePathId).Returns(ErrorOrFactory.From((long?)null));
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(copiedFilePathId).Returns(Result.From((long?)null));
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
|
||||
Result<File> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.Status);
|
||||
}
|
||||
@@ -444,10 +443,10 @@ public class FileServiceTests
|
||||
bool overrideExisting = true;
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.CopyFile(invalidSourcePath, destinationPath, overrideExisting);
|
||||
Result<File> result = _sut.CopyFile(invalidSourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -461,10 +460,10 @@ public class FileServiceTests
|
||||
_mockPlatformContext.PathStrategy.PathSeparator.Returns(_dirSeparator);
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.CopyFile(sourcePath, invalidDestinationPath, overrideExisting);
|
||||
Result<File> result = _sut.CopyFile(sourcePath, invalidDestinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -488,10 +487,10 @@ public class FileServiceTests
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(copiedFilePathId).Returns((long?)1024);
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.CopyFile(sourcePathId, destinationPathId, overrideExisting);
|
||||
Result<File> result = _sut.CopyFile(sourcePathId, destinationPathId, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal("file.txt", result.Value.Name);
|
||||
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
|
||||
@@ -508,10 +507,10 @@ public class FileServiceTests
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(sourcePathId).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.CopyFile(sourcePathId, destinationPathId, overrideExisting);
|
||||
Result<File> result = _sut.CopyFile(sourcePathId, destinationPathId, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.FileNotFound, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -528,10 +527,10 @@ public class FileServiceTests
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.CopyFile(sourcePathId, destinationPathId, overrideExisting);
|
||||
Result<File> result = _sut.CopyFile(sourcePathId, destinationPathId, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -551,13 +550,13 @@ public class FileServiceTests
|
||||
_mockEnvironmentContext.FileProviderService.GetFileName(copiedFilePathId).Returns(Errors.Permission.UnauthorizedAccess);
|
||||
_mockEnvironmentContext.FileProviderService.GetLastWriteTime(copiedFilePathId).Returns(Errors.Permission.UnauthorizedAccess);
|
||||
_mockEnvironmentContext.FileProviderService.GetCreationTime(copiedFilePathId).Returns(Errors.Permission.UnauthorizedAccess);
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(copiedFilePathId).Returns(ErrorOrFactory.From((long?)null));
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(copiedFilePathId).Returns(Result.From((long?)null));
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.CopyFile(sourcePathId, destinationPathId, overrideExisting);
|
||||
Result<File> result = _sut.CopyFile(sourcePathId, destinationPathId, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.Status);
|
||||
}
|
||||
@@ -587,10 +586,10 @@ public class FileServiceTests
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(movedFilePathId).Returns((long?)1024);
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
|
||||
Result<File> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal("file.txt", result.Value.Name);
|
||||
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
|
||||
@@ -609,10 +608,10 @@ public class FileServiceTests
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(sourcePathId).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
|
||||
Result<File> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.FileNotFound, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -632,10 +631,10 @@ public class FileServiceTests
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
|
||||
Result<File> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -660,13 +659,13 @@ public class FileServiceTests
|
||||
_mockEnvironmentContext.FileProviderService.GetFileName(movedFilePathId).Returns(Errors.Permission.UnauthorizedAccess);
|
||||
_mockEnvironmentContext.FileProviderService.GetLastWriteTime(movedFilePathId).Returns(Errors.Permission.UnauthorizedAccess);
|
||||
_mockEnvironmentContext.FileProviderService.GetCreationTime(movedFilePathId).Returns(Errors.Permission.UnauthorizedAccess);
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(movedFilePathId).Returns(ErrorOrFactory.From((long?)null));
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(movedFilePathId).Returns(Result.From((long?)null));
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
|
||||
Result<File> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.Status);
|
||||
}
|
||||
@@ -682,10 +681,10 @@ public class FileServiceTests
|
||||
_mockPlatformContext.PathStrategy.PathSeparator.Returns(_dirSeparator);
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.MoveFile(invalidSourcePath, destinationPath, overrideExisting);
|
||||
Result<File> result = _sut.MoveFile(invalidSourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -700,10 +699,10 @@ public class FileServiceTests
|
||||
_mockPlatformContext.PathStrategy.PathSeparator.Returns(_dirSeparator);
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.MoveFile(sourcePath, invalidDestinationPath, overrideExisting);
|
||||
Result<File> result = _sut.MoveFile(sourcePath, invalidDestinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -727,10 +726,10 @@ public class FileServiceTests
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(movedFilePathId).Returns((long?)1024);
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.MoveFile(sourcePathId, destinationPathId, overrideExisting);
|
||||
Result<File> result = _sut.MoveFile(sourcePathId, destinationPathId, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal("file.txt", result.Value.Name);
|
||||
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
|
||||
@@ -749,10 +748,10 @@ public class FileServiceTests
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(sourcePathId).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.MoveFile(sourcePathId, destinationPathId, overrideExisting);
|
||||
Result<File> result = _sut.MoveFile(sourcePathId, destinationPathId, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.FileNotFound, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -769,10 +768,10 @@ public class FileServiceTests
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.MoveFile(sourcePathId, destinationPathId, overrideExisting);
|
||||
Result<File> result = _sut.MoveFile(sourcePathId, destinationPathId, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -792,13 +791,13 @@ public class FileServiceTests
|
||||
_mockEnvironmentContext.FileProviderService.GetFileName(movedFilePathId).Returns(Errors.Permission.UnauthorizedAccess);
|
||||
_mockEnvironmentContext.FileProviderService.GetLastWriteTime(movedFilePathId).Returns(Errors.Permission.UnauthorizedAccess);
|
||||
_mockEnvironmentContext.FileProviderService.GetCreationTime(movedFilePathId).Returns(Errors.Permission.UnauthorizedAccess);
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(movedFilePathId).Returns(ErrorOrFactory.From((long?)null));
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(movedFilePathId).Returns(Result.From((long?)null));
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.MoveFile(sourcePathId, destinationPathId, overrideExisting);
|
||||
Result<File> result = _sut.MoveFile(sourcePathId, destinationPathId, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.Status);
|
||||
}
|
||||
@@ -817,10 +816,10 @@ public class FileServiceTests
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
|
||||
Result<File> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -835,22 +834,22 @@ public class FileServiceTests
|
||||
|
||||
_mockPlatformContext.PathStrategy.PathSeparator.Returns(_dirSeparator);
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
.Returns(ErrorOrFactory.From(newPathId));
|
||||
.Returns(Result.From(newPathId));
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(newPathId).Returns(false);
|
||||
_mockEnvironmentContext.FileProviderService.RenameFile(pathId, newName)
|
||||
.Returns(ErrorOrFactory.From(newPathId));
|
||||
_mockEnvironmentContext.FileProviderService.GetFileName(newPathId).Returns(ErrorOrFactory.From(newName));
|
||||
.Returns(Result.From(newPathId));
|
||||
_mockEnvironmentContext.FileProviderService.GetFileName(newPathId).Returns(Result.From(newName));
|
||||
_mockEnvironmentContext.FileProviderService.GetLastWriteTime(newPathId)
|
||||
.Returns(ErrorOrFactory.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
_mockEnvironmentContext.FileProviderService.GetCreationTime(newPathId)
|
||||
.Returns(ErrorOrFactory.From(Optional<DateTime>.FromNullable(DateTime.Now.AddDays(-1))));
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(newPathId).Returns(ErrorOrFactory.From((long?)1024));
|
||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now.AddDays(-1))));
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(newPathId).Returns(Result.From((long?)1024));
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.RenameFile(path, newName);
|
||||
Result<File> result = _sut.RenameFile(path, newName);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(newName, result.Value.Name);
|
||||
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
|
||||
@@ -866,14 +865,14 @@ public class FileServiceTests
|
||||
|
||||
_mockPlatformContext.PathStrategy.PathSeparator.Returns(_dirSeparator);
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
.Returns(ErrorOrFactory.From(newPathId));
|
||||
.Returns(Result.From(newPathId));
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(newPathId).Returns(true);
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.RenameFile(path, newName);
|
||||
Result<File> result = _sut.RenameFile(path, newName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.FileAlreadyExists, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -888,16 +887,16 @@ public class FileServiceTests
|
||||
|
||||
_mockPlatformContext.PathStrategy.PathSeparator.Returns(_dirSeparator);
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
.Returns(ErrorOrFactory.From(newPathId));
|
||||
.Returns(Result.From(newPathId));
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(newPathId).Returns(false);
|
||||
_mockEnvironmentContext.FileProviderService.RenameFile(pathId, newName)
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.RenameFile(path, newName);
|
||||
Result<File> result = _sut.RenameFile(path, newName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -912,21 +911,21 @@ public class FileServiceTests
|
||||
|
||||
_mockPlatformContext.PathStrategy.PathSeparator.Returns(_dirSeparator);
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
.Returns(ErrorOrFactory.From(newPathId));
|
||||
.Returns(Result.From(newPathId));
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(newPathId).Returns(false);
|
||||
_mockEnvironmentContext.FileProviderService.RenameFile(pathId, newName)
|
||||
.Returns(ErrorOrFactory.From(newPathId));
|
||||
.Returns(Result.From(newPathId));
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.GetFileName(newPathId).Returns(Errors.Permission.UnauthorizedAccess);
|
||||
_mockEnvironmentContext.FileProviderService.GetLastWriteTime(newPathId).Returns(Errors.Permission.UnauthorizedAccess);
|
||||
_mockEnvironmentContext.FileProviderService.GetCreationTime(newPathId).Returns(Errors.Permission.UnauthorizedAccess);
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(newPathId).Returns(ErrorOrFactory.From((long?)null));
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(newPathId).Returns(Result.From((long?)null));
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.RenameFile(path, newName);
|
||||
Result<File> result = _sut.RenameFile(path, newName);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.Status);
|
||||
}
|
||||
@@ -941,10 +940,10 @@ public class FileServiceTests
|
||||
_mockPlatformContext.PathStrategy.PathSeparator.Returns(_dirSeparator);
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.RenameFile(invalidPath, newName);
|
||||
Result<File> result = _sut.RenameFile(invalidPath, newName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -957,22 +956,22 @@ public class FileServiceTests
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceNewFile);
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
.Returns(ErrorOrFactory.From(newPathId));
|
||||
.Returns(Result.From(newPathId));
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(newPathId).Returns(false);
|
||||
_mockEnvironmentContext.FileProviderService.RenameFile(pathId, newName)
|
||||
.Returns(ErrorOrFactory.From(newPathId));
|
||||
_mockEnvironmentContext.FileProviderService.GetFileName(newPathId).Returns(ErrorOrFactory.From(newName));
|
||||
.Returns(Result.From(newPathId));
|
||||
_mockEnvironmentContext.FileProviderService.GetFileName(newPathId).Returns(Result.From(newName));
|
||||
_mockEnvironmentContext.FileProviderService.GetLastWriteTime(newPathId)
|
||||
.Returns(ErrorOrFactory.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||
_mockEnvironmentContext.FileProviderService.GetCreationTime(newPathId)
|
||||
.Returns(ErrorOrFactory.From(Optional<DateTime>.FromNullable(DateTime.Now.AddDays(-1))));
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(newPathId).Returns(ErrorOrFactory.From((long?)1024));
|
||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now.AddDays(-1))));
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(newPathId).Returns(Result.From((long?)1024));
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.RenameFile(pathId, newName);
|
||||
Result<File> result = _sut.RenameFile(pathId, newName);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(newName, result.Value.Name);
|
||||
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
|
||||
@@ -987,14 +986,14 @@ public class FileServiceTests
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceExistingFile);
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
.Returns(ErrorOrFactory.From(newPathId));
|
||||
.Returns(Result.From(newPathId));
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(newPathId).Returns(true);
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.RenameFile(pathId, newName);
|
||||
Result<File> result = _sut.RenameFile(pathId, newName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.FileAlreadyExists, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -1007,16 +1006,16 @@ public class FileServiceTests
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceNewFile);
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
.Returns(ErrorOrFactory.From(newPathId));
|
||||
.Returns(Result.From(newPathId));
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(newPathId).Returns(false);
|
||||
_mockEnvironmentContext.FileProviderService.RenameFile(pathId, newName)
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.RenameFile(pathId, newName);
|
||||
Result<File> result = _sut.RenameFile(pathId, newName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -1029,21 +1028,21 @@ public class FileServiceTests
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceNewFile);
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
.Returns(ErrorOrFactory.From(newPathId));
|
||||
.Returns(Result.From(newPathId));
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(newPathId).Returns(false);
|
||||
_mockEnvironmentContext.FileProviderService.RenameFile(pathId, newName)
|
||||
.Returns(ErrorOrFactory.From(newPathId));
|
||||
.Returns(Result.From(newPathId));
|
||||
|
||||
_mockEnvironmentContext.FileProviderService.GetFileName(newPathId).Returns(Errors.Permission.UnauthorizedAccess);
|
||||
_mockEnvironmentContext.FileProviderService.GetLastWriteTime(newPathId).Returns(Errors.Permission.UnauthorizedAccess);
|
||||
_mockEnvironmentContext.FileProviderService.GetCreationTime(newPathId).Returns(Errors.Permission.UnauthorizedAccess);
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(newPathId).Returns(ErrorOrFactory.From((long?)null));
|
||||
_mockEnvironmentContext.FileProviderService.GetSize(newPathId).Returns(Result.From((long?)null));
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.RenameFile(pathId, newName);
|
||||
Result<File> result = _sut.RenameFile(pathId, newName);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.Status);
|
||||
}
|
||||
@@ -1060,10 +1059,10 @@ public class FileServiceTests
|
||||
.Returns(Errors.FileSystemManagement.InvalidPath);
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.RenameFile(path, newName);
|
||||
Result<File> result = _sut.RenameFile(path, newName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -1077,15 +1076,15 @@ public class FileServiceTests
|
||||
|
||||
_mockPlatformContext.PathStrategy.PathSeparator.Returns(_dirSeparator);
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
.Returns(ErrorOrFactory.From(newPathId));
|
||||
.Returns(Result.From(newPathId));
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(newPathId)
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.RenameFile(path, newName);
|
||||
Result<File> result = _sut.RenameFile(path, newName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -1100,10 +1099,10 @@ public class FileServiceTests
|
||||
.Returns(Errors.FileSystemManagement.InvalidPath);
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.RenameFile(pathId, newName);
|
||||
Result<File> result = _sut.RenameFile(pathId, newName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -1116,15 +1115,15 @@ public class FileServiceTests
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSourceNewFile);
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
.Returns(ErrorOrFactory.From(newPathId));
|
||||
.Returns(Result.From(newPathId));
|
||||
_mockEnvironmentContext.FileProviderService.FileExists(newPathId)
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<File> result = _sut.RenameFile(pathId, newName);
|
||||
Result<File> result = _sut.RenameFile(pathId, newName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -1139,10 +1138,10 @@ public class FileServiceTests
|
||||
.Returns(Result.Deleted);
|
||||
|
||||
// Act
|
||||
ErrorOr<Deleted> result = _sut.DeleteFile(path);
|
||||
Result<Deleted> result = _sut.DeleteFile(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(Result.Deleted, result.Value);
|
||||
}
|
||||
|
||||
@@ -1153,10 +1152,10 @@ public class FileServiceTests
|
||||
string invalidPath = string.Empty;
|
||||
|
||||
// Act
|
||||
ErrorOr<Deleted> result = _sut.DeleteFile(invalidPath);
|
||||
Result<Deleted> result = _sut.DeleteFile(invalidPath);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -1171,10 +1170,10 @@ public class FileServiceTests
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<Deleted> result = _sut.DeleteFile(path);
|
||||
Result<Deleted> result = _sut.DeleteFile(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -1188,10 +1187,10 @@ public class FileServiceTests
|
||||
.Returns(Result.Deleted);
|
||||
|
||||
// Act
|
||||
ErrorOr<Deleted> result = _sut.DeleteFile(pathId);
|
||||
Result<Deleted> result = _sut.DeleteFile(pathId);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(Result.Deleted, result.Value);
|
||||
}
|
||||
|
||||
@@ -1205,10 +1204,10 @@ public class FileServiceTests
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<Deleted> result = _sut.DeleteFile(pathId);
|
||||
Result<Deleted> result = _sut.DeleteFile(pathId);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
}
|
||||
+20
-20
@@ -1,11 +1,11 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.PhotoLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Errors;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
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.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;
|
||||
@@ -55,10 +55,10 @@ public class FileTypeServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(file.Id, FileAccessMode.ReadContents).Returns(true);
|
||||
|
||||
// Act
|
||||
ErrorOr<ImageType> result = await sut.GetImageTypeAsync(file, CancellationToken.None);
|
||||
Result<ImageType> result = await sut.GetImageTypeAsync(file, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(ImageType.PNG, result.Value);
|
||||
}
|
||||
|
||||
@@ -74,10 +74,10 @@ public class FileTypeServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(file.Id, FileAccessMode.ReadContents).Returns(false);
|
||||
|
||||
// Act
|
||||
ErrorOr<ImageType> result = await sut.GetImageTypeAsync(file, CancellationToken.None);
|
||||
Result<ImageType> result = await sut.GetImageTypeAsync(file, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -93,10 +93,10 @@ public class FileTypeServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(pathId, FileAccessMode.ReadContents).Returns(true);
|
||||
|
||||
// Act
|
||||
ErrorOr<ImageType> result = await sut.GetImageTypeAsync(pathId, CancellationToken.None);
|
||||
Result<ImageType> result = await sut.GetImageTypeAsync(pathId, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(ImageType.None, result.Value);
|
||||
}
|
||||
|
||||
@@ -113,10 +113,10 @@ public class FileTypeServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(pathId, FileAccessMode.ReadContents).Returns(true);
|
||||
|
||||
// Act
|
||||
ErrorOr<ImageType> result = await sut.GetImageTypeAsync(pathId, CancellationToken.None);
|
||||
Result<ImageType> result = await sut.GetImageTypeAsync(pathId, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(ImageType.SVG, result.Value);
|
||||
}
|
||||
|
||||
@@ -135,10 +135,10 @@ public class FileTypeServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(pathId, FileAccessMode.ReadContents).Returns(true);
|
||||
|
||||
// Act
|
||||
ErrorOr<ImageType> result = await sut.GetImageTypeAsync(pathId, CancellationToken.None);
|
||||
Result<ImageType> result = await sut.GetImageTypeAsync(pathId, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(ImageType.TGA, result.Value);
|
||||
}
|
||||
|
||||
@@ -154,10 +154,10 @@ public class FileTypeServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(pathId, FileAccessMode.ReadContents).Returns(true);
|
||||
|
||||
// Act
|
||||
ErrorOr<ImageType> result = await sut.GetImageTypeAsync(pathId, CancellationToken.None);
|
||||
Result<ImageType> result = await sut.GetImageTypeAsync(pathId, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(ImageType.None, result.Value);
|
||||
}
|
||||
|
||||
@@ -185,10 +185,10 @@ public class FileTypeServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(pathId, FileAccessMode.ReadContents).Returns(true);
|
||||
|
||||
// Act
|
||||
ErrorOr<ImageType> result = await sut.GetImageTypeAsync(pathId, CancellationToken.None);
|
||||
Result<ImageType> result = await sut.GetImageTypeAsync(pathId, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(ImageType.SVG, result.Value);
|
||||
}
|
||||
|
||||
@@ -221,10 +221,10 @@ public class FileTypeServiceTests
|
||||
_mockFileSystemPermissionsService.CanAccessPath(pathId, FileAccessMode.ReadContents).Returns(true);
|
||||
|
||||
// Act
|
||||
ErrorOr<ImageType> result = await sut.GetImageTypeAsync(pathId, CancellationToken.None);
|
||||
Result<ImageType> result = await sut.GetImageTypeAsync(pathId, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(expectedType, result.Value);
|
||||
}
|
||||
}
|
||||
+41
-41
@@ -1,6 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.SharedKernel.Common.Errors;
|
||||
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.Strategies.Path;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
|
||||
@@ -202,13 +202,13 @@ public class PathServiceTests
|
||||
string name = "SubDir";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId combinedPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\BaseDir\SubDir");
|
||||
_mockPathStrategy.CombinePath(pathId, name).Returns(ErrorOrFactory.From(combinedPathId));
|
||||
_mockPathStrategy.CombinePath(pathId, name).Returns(Result.From(combinedPathId));
|
||||
|
||||
// Act
|
||||
ErrorOr<string> result = _sut.CombinePath(path, name);
|
||||
Result<string> result = _sut.CombinePath(path, name);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(@"C:\BaseDir\SubDir", result.Value);
|
||||
_mockPathStrategy.Received(1).CombinePath(Arg.Is<FileSystemPathId>(id => id.Path == path), name);
|
||||
}
|
||||
@@ -221,10 +221,10 @@ public class PathServiceTests
|
||||
string name = "SubDir";
|
||||
|
||||
// Act
|
||||
ErrorOr<string> result = _sut.CombinePath(invalidPath, name);
|
||||
Result<string> result = _sut.CombinePath(invalidPath, name);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
_mockPathStrategy.DidNotReceive().CombinePath(Arg.Any<FileSystemPathId>(), Arg.Any<string>());
|
||||
}
|
||||
@@ -239,10 +239,10 @@ public class PathServiceTests
|
||||
_mockPathStrategy.CombinePath(pathId, name).Returns(Errors.FileSystemManagement.InvalidPath);
|
||||
|
||||
// Act
|
||||
ErrorOr<string> result = _sut.CombinePath(path, name);
|
||||
Result<string> result = _sut.CombinePath(path, name);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
_mockPathStrategy.Received(1).CombinePath(Arg.Is<FileSystemPathId>(id => id.Path == path), name);
|
||||
}
|
||||
@@ -255,10 +255,10 @@ public class PathServiceTests
|
||||
string? name = null;
|
||||
|
||||
// Act
|
||||
ErrorOr<string> result = _sut.CombinePath(path, name!);
|
||||
Result<string> result = _sut.CombinePath(path, name!);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
_mockPathStrategy.DidNotReceive().CombinePath(Arg.Any<FileSystemPathId>(), Arg.Any<string>());
|
||||
}
|
||||
@@ -270,13 +270,13 @@ public class PathServiceTests
|
||||
string validPath = @"C:\ValidPath\SubDir";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(validPath);
|
||||
List<PathSegment> expectedSegments = _pathSegmentFixture.CreateMany();
|
||||
_mockPathStrategy.ParsePath(pathId).Returns(ErrorOrFactory.From(expectedSegments.AsEnumerable()));
|
||||
_mockPathStrategy.ParsePath(pathId).Returns(Result.From(expectedSegments.AsEnumerable()));
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(validPath);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(validPath);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(expectedSegments, result.Value);
|
||||
_mockPathStrategy.Received(1).ParsePath(Arg.Is<FileSystemPathId>(id => id.Path == validPath));
|
||||
}
|
||||
@@ -288,10 +288,10 @@ public class PathServiceTests
|
||||
string invalidPath = string.Empty;
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(invalidPath);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(invalidPath);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
_mockPathStrategy.DidNotReceive().ParsePath(Arg.Any<FileSystemPathId>());
|
||||
}
|
||||
@@ -305,10 +305,10 @@ public class PathServiceTests
|
||||
_mockPathStrategy.ParsePath(pathId).Returns(Errors.FileSystemManagement.InvalidPath);
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
_mockPathStrategy.Received(1).ParsePath(Arg.Is<FileSystemPathId>(id => id.Path == path));
|
||||
}
|
||||
@@ -320,10 +320,10 @@ public class PathServiceTests
|
||||
string? nullPath = null;
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(nullPath!);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(nullPath!);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
_mockPathStrategy.DidNotReceive().ParsePath(Arg.Any<FileSystemPathId>());
|
||||
}
|
||||
@@ -335,13 +335,13 @@ public class PathServiceTests
|
||||
string validPath = @"C:\ValidPath\SubDir";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(validPath);
|
||||
List<PathSegment> expectedSegments = _pathSegmentFixture.CreateMany(2); // Assuming parent path has 2 segments
|
||||
_mockPathStrategy.GoUpOneLevel(pathId).Returns(ErrorOrFactory.From(expectedSegments.AsEnumerable()));
|
||||
_mockPathStrategy.GoUpOneLevel(pathId).Returns(Result.From(expectedSegments.AsEnumerable()));
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(validPath);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(validPath);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(expectedSegments, result.Value);
|
||||
_mockPathStrategy.Received(1).GoUpOneLevel(Arg.Is<FileSystemPathId>(id => id.Path == validPath));
|
||||
}
|
||||
@@ -353,13 +353,13 @@ public class PathServiceTests
|
||||
string rootPath = @"C:\";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(rootPath);
|
||||
List<PathSegment> emptySegmentList = [];
|
||||
_mockPathStrategy.GoUpOneLevel(pathId).Returns(ErrorOrFactory.From(emptySegmentList.AsEnumerable()));
|
||||
_mockPathStrategy.GoUpOneLevel(pathId).Returns(Result.From(emptySegmentList.AsEnumerable()));
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(rootPath);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(rootPath);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Empty(result.Value);
|
||||
_mockPathStrategy.Received(1).GoUpOneLevel(Arg.Is<FileSystemPathId>(id => id.Path == rootPath));
|
||||
}
|
||||
@@ -371,10 +371,10 @@ public class PathServiceTests
|
||||
string invalidPath = string.Empty;
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(invalidPath);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(invalidPath);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
_mockPathStrategy.DidNotReceive().GoUpOneLevel(Arg.Any<FileSystemPathId>());
|
||||
}
|
||||
@@ -388,10 +388,10 @@ public class PathServiceTests
|
||||
_mockPathStrategy.GoUpOneLevel(pathId).Returns(Errors.FileSystemManagement.InvalidPath);
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
_mockPathStrategy.Received(1).GoUpOneLevel(Arg.Is<FileSystemPathId>(id => id.Path == path));
|
||||
}
|
||||
@@ -403,10 +403,10 @@ public class PathServiceTests
|
||||
string? nullPath = null;
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(nullPath!);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(nullPath!);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
_mockPathStrategy.DidNotReceive().GoUpOneLevel(Arg.Any<FileSystemPathId>());
|
||||
}
|
||||
@@ -465,13 +465,13 @@ public class PathServiceTests
|
||||
string validPath = @"C:\ValidPath\SubDir";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(validPath);
|
||||
PathSegment expectedRootSegment = _pathSegmentFixture.CreatePathSegment(name: "C:", isDirectory: false, isDrive: true);
|
||||
_mockPathStrategy.GetPathRoot(pathId).Returns(ErrorOrFactory.From(expectedRootSegment));
|
||||
_mockPathStrategy.GetPathRoot(pathId).Returns(Result.From(expectedRootSegment));
|
||||
|
||||
// Act
|
||||
ErrorOr<PathSegment> result = _sut.GetPathRoot(validPath);
|
||||
Result<PathSegment> result = _sut.GetPathRoot(validPath);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(expectedRootSegment, result.Value);
|
||||
_mockPathStrategy.Received(1).GetPathRoot(Arg.Is<FileSystemPathId>(id => id.Path == validPath));
|
||||
}
|
||||
@@ -483,10 +483,10 @@ public class PathServiceTests
|
||||
string invalidPath = string.Empty;
|
||||
|
||||
// Act
|
||||
ErrorOr<PathSegment> result = _sut.GetPathRoot(invalidPath);
|
||||
Result<PathSegment> result = _sut.GetPathRoot(invalidPath);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
_mockPathStrategy.DidNotReceive().GetPathRoot(Arg.Any<FileSystemPathId>());
|
||||
}
|
||||
@@ -500,10 +500,10 @@ public class PathServiceTests
|
||||
_mockPathStrategy.GetPathRoot(pathId).Returns(Errors.FileSystemManagement.InvalidPath);
|
||||
|
||||
// Act
|
||||
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
_mockPathStrategy.Received(1).GetPathRoot(Arg.Is<FileSystemPathId>(id => id.Path == path));
|
||||
}
|
||||
@@ -515,10 +515,10 @@ public class PathServiceTests
|
||||
string? nullPath = null;
|
||||
|
||||
// Act
|
||||
ErrorOr<PathSegment> result = _sut.GetPathRoot(nullPath!);
|
||||
Result<PathSegment> result = _sut.GetPathRoot(nullPath!);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
_mockPathStrategy.DidNotReceive().GetPathRoot(Arg.Any<FileSystemPathId>());
|
||||
}
|
||||
|
||||
+22
-22
@@ -1,10 +1,10 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.PhotoLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Errors;
|
||||
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.Strategies.Environment;
|
||||
using Lumina.Domain.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;
|
||||
@@ -57,15 +57,15 @@ public class ThumbnailServiceTests
|
||||
}
|
||||
|
||||
_mockEnvironmentContext.FileTypeService.GetImageTypeAsync(pathId, Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(ImageType.JPEG));
|
||||
.Returns(Result.From(ImageType.JPEG));
|
||||
_mockEnvironmentContext.FileProviderService.GetFileAsync(pathId)
|
||||
.Returns(ErrorOrFactory.From(imageBytes));
|
||||
.Returns(Result.From(imageBytes));
|
||||
|
||||
// Act
|
||||
ErrorOr<Thumbnail> result = await _sut.GetThumbnailAsync(path, quality, CancellationToken.None);
|
||||
Result<Thumbnail> result = await _sut.GetThumbnailAsync(path, quality, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(ImageType.JPEG, result.Value.Type);
|
||||
Assert.NotEmpty(result.Value.Bytes);
|
||||
}
|
||||
@@ -78,10 +78,10 @@ public class ThumbnailServiceTests
|
||||
int quality = 80;
|
||||
|
||||
// Act
|
||||
ErrorOr<Thumbnail> result = await _sut.GetThumbnailAsync(invalidPath, quality, CancellationToken.None);
|
||||
Result<Thumbnail> result = await _sut.GetThumbnailAsync(invalidPath, quality, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -96,10 +96,10 @@ public class ThumbnailServiceTests
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<Thumbnail> result = await _sut.GetThumbnailAsync(pathId, quality, CancellationToken.None);
|
||||
Result<Thumbnail> result = await _sut.GetThumbnailAsync(pathId, quality, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -111,13 +111,13 @@ public class ThumbnailServiceTests
|
||||
int quality = 80;
|
||||
|
||||
_mockEnvironmentContext.FileTypeService.GetImageTypeAsync(pathId, Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(ImageType.None));
|
||||
.Returns(Result.From(ImageType.None));
|
||||
|
||||
// Act
|
||||
ErrorOr<Thumbnail> result = await _sut.GetThumbnailAsync(pathId, quality, CancellationToken.None);
|
||||
Result<Thumbnail> result = await _sut.GetThumbnailAsync(pathId, quality, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Thumbnails.NoThumbnail, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -129,15 +129,15 @@ public class ThumbnailServiceTests
|
||||
int quality = 80;
|
||||
|
||||
_mockEnvironmentContext.FileTypeService.GetImageTypeAsync(pathId, Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(ImageType.JPEG));
|
||||
.Returns(Result.From(ImageType.JPEG));
|
||||
_mockEnvironmentContext.FileProviderService.GetFileAsync(pathId)
|
||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||
|
||||
// Act
|
||||
ErrorOr<Thumbnail> result = await _sut.GetThumbnailAsync(pathId, quality, CancellationToken.None);
|
||||
Result<Thumbnail> result = await _sut.GetThumbnailAsync(pathId, quality, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -150,15 +150,15 @@ public class ThumbnailServiceTests
|
||||
int quality = 80;
|
||||
|
||||
_mockEnvironmentContext.FileTypeService.GetImageTypeAsync(pathId, Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(imageType));
|
||||
.Returns(Result.From(imageType));
|
||||
_mockEnvironmentContext.FileProviderService.GetFileAsync(pathId)
|
||||
.Returns(ErrorOrFactory.From(imageBytes));
|
||||
.Returns(Result.From(imageBytes));
|
||||
|
||||
// Act
|
||||
ErrorOr<Thumbnail> result = await _sut.GetThumbnailAsync(pathId, quality, CancellationToken.None);
|
||||
Result<Thumbnail> result = await _sut.GetThumbnailAsync(pathId, quality, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(imageType, result.Value.Type);
|
||||
Assert.NotEmpty(result.Value.Bytes);
|
||||
|
||||
@@ -179,7 +179,7 @@ public class ThumbnailServiceTests
|
||||
cts.Cancel();
|
||||
|
||||
_mockEnvironmentContext.FileTypeService.GetImageTypeAsync(pathId, cts.Token)
|
||||
.Returns(Task.FromCanceled<ErrorOr<ImageType>>(cts.Token));
|
||||
.Returns(Task.FromCanceled<Result<ImageType>>(cts.Token));
|
||||
|
||||
// Act & Assert
|
||||
await Assert.ThrowsAsync<TaskCanceledException>(() =>
|
||||
|
||||
+40
-40
@@ -1,6 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.SharedKernel.Common.Errors;
|
||||
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;
|
||||
@@ -233,10 +233,10 @@ public class UnixPathStrategyTests
|
||||
string name = "documents";
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CombinePath(path, name);
|
||||
Result<FileSystemPathId> result = _sut.CombinePath(path, name);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal("/home/user/documents/", result.Value.Path);
|
||||
}
|
||||
|
||||
@@ -248,10 +248,10 @@ public class UnixPathStrategyTests
|
||||
string name = "documents";
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CombinePath(path, name);
|
||||
Result<FileSystemPathId> result = _sut.CombinePath(path, name);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal("/home/user/documents/", result.Value.Path);
|
||||
}
|
||||
|
||||
@@ -263,10 +263,10 @@ public class UnixPathStrategyTests
|
||||
string name = "/documents";
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CombinePath(path, name);
|
||||
Result<FileSystemPathId> result = _sut.CombinePath(path, name);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal("/home/user/documents/", result.Value.Path);
|
||||
}
|
||||
|
||||
@@ -278,10 +278,10 @@ public class UnixPathStrategyTests
|
||||
string name = "";
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CombinePath(path, name);
|
||||
Result<FileSystemPathId> result = _sut.CombinePath(path, name);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.NameCannotBeEmpty, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -293,10 +293,10 @@ public class UnixPathStrategyTests
|
||||
string name = null!;
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CombinePath(path, name);
|
||||
Result<FileSystemPathId> result = _sut.CombinePath(path, name);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.NameCannotBeEmpty, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -308,10 +308,10 @@ public class UnixPathStrategyTests
|
||||
string name = "home";
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CombinePath(path, name);
|
||||
Result<FileSystemPathId> result = _sut.CombinePath(path, name);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal("/home/", result.Value.Path);
|
||||
}
|
||||
|
||||
@@ -322,10 +322,10 @@ public class UnixPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/home/user/documents/file.txt");
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
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));
|
||||
@@ -341,10 +341,10 @@ public class UnixPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/");
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Single(result.Value);
|
||||
Assert.Equal(_pathSegmentFixture.CreatePathSegment("/", false, true), result.Value.Single());
|
||||
}
|
||||
@@ -356,10 +356,10 @@ public class UnixPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/home/user/documents/");
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(4, result.Value.Count());
|
||||
Assert.Equal(_pathSegmentFixture.CreatePathSegment("documents", true, false), result.Value.Last());
|
||||
}
|
||||
@@ -371,10 +371,10 @@ public class UnixPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("home/user");
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -385,10 +385,10 @@ public class UnixPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/home/user/file.with.dots.txt");
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(4, result.Value.Count());
|
||||
Assert.Equal(_pathSegmentFixture.CreatePathSegment("file.with.dots.txt", false, false), result.Value.Last());
|
||||
}
|
||||
@@ -400,10 +400,10 @@ public class UnixPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/home/user/documents");
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
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));
|
||||
@@ -417,10 +417,10 @@ public class UnixPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/");
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.CannotNavigateUp, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -431,10 +431,10 @@ public class UnixPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/home/user/");
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
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));
|
||||
@@ -447,10 +447,10 @@ public class UnixPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("invalid/path");
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -461,10 +461,10 @@ public class UnixPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/home");
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Single(result.Value);
|
||||
Assert.Equal(_pathSegmentFixture.CreatePathSegment("/", false, true), result.Value.Single());
|
||||
}
|
||||
@@ -516,10 +516,10 @@ public class UnixPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/home/user/documents");
|
||||
|
||||
// Act
|
||||
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(_pathSegmentFixture.CreatePathSegment("/", false, true), result.Value);
|
||||
}
|
||||
|
||||
@@ -530,10 +530,10 @@ public class UnixPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("/");
|
||||
|
||||
// Act
|
||||
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(_pathSegmentFixture.CreatePathSegment("/", false, true), result.Value);
|
||||
}
|
||||
|
||||
@@ -544,10 +544,10 @@ public class UnixPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId("home/user");
|
||||
|
||||
// Act
|
||||
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
}
|
||||
+64
-64
@@ -1,6 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.SharedKernel.Common.Errors;
|
||||
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;
|
||||
@@ -276,10 +276,10 @@ public class WindowsPathStrategyTests
|
||||
string name = "Documents";
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CombinePath(path, name);
|
||||
Result<FileSystemPathId> result = _sut.CombinePath(path, name);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(@"C:\Users\User\Documents\", result.Value.Path);
|
||||
}
|
||||
|
||||
@@ -291,10 +291,10 @@ public class WindowsPathStrategyTests
|
||||
string name = "Documents";
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CombinePath(path, name);
|
||||
Result<FileSystemPathId> result = _sut.CombinePath(path, name);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(@"C:\Users\User\Documents\", result.Value.Path);
|
||||
}
|
||||
|
||||
@@ -306,10 +306,10 @@ public class WindowsPathStrategyTests
|
||||
string name = @"\Documents";
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CombinePath(path, name);
|
||||
Result<FileSystemPathId> result = _sut.CombinePath(path, name);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(@"C:\Users\User\Documents\", result.Value.Path);
|
||||
}
|
||||
|
||||
@@ -321,10 +321,10 @@ public class WindowsPathStrategyTests
|
||||
string name = null!;
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CombinePath(path, name);
|
||||
Result<FileSystemPathId> result = _sut.CombinePath(path, name);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.NameCannotBeEmpty, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -336,10 +336,10 @@ public class WindowsPathStrategyTests
|
||||
string name = "Users";
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CombinePath(path, name);
|
||||
Result<FileSystemPathId> result = _sut.CombinePath(path, name);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(@"C:\Users\", result.Value.Path);
|
||||
}
|
||||
|
||||
@@ -351,10 +351,10 @@ public class WindowsPathStrategyTests
|
||||
string name = "folder";
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = _sut.CombinePath(path, name);
|
||||
Result<FileSystemPathId> result = _sut.CombinePath(path, name);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(@"\\server\share\folder\", result.Value.Path);
|
||||
}
|
||||
|
||||
@@ -365,10 +365,10 @@ public class WindowsPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\Users\User\Documents\file.txt");
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
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));
|
||||
@@ -384,10 +384,10 @@ public class WindowsPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\");
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Single(result.Value);
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("C:", false, true), result.Value.Single());
|
||||
}
|
||||
@@ -399,10 +399,10 @@ public class WindowsPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\Users\User\Documents\");
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(4, result.Value.Count());
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("Documents", true, false), result.Value.Last());
|
||||
}
|
||||
@@ -414,10 +414,10 @@ public class WindowsPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"Users\User");
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -428,10 +428,10 @@ public class WindowsPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\Users\User\file.with.dots.txt");
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(4, result.Value.Count());
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("file.with.dots.txt", false, false), result.Value.Last());
|
||||
}
|
||||
@@ -443,10 +443,10 @@ public class WindowsPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"\\server\share\folder\file.txt");
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
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));
|
||||
@@ -462,10 +462,10 @@ public class WindowsPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\Users\User\Documents");
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
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));
|
||||
@@ -479,10 +479,10 @@ public class WindowsPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\");
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.CannotNavigateUp, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -493,10 +493,10 @@ public class WindowsPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\Users\User\");
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
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));
|
||||
@@ -509,10 +509,10 @@ public class WindowsPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"invalid\path");
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -523,10 +523,10 @@ public class WindowsPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\Users");
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Single(result.Value);
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("C:", false, true), result.Value.Single());
|
||||
}
|
||||
@@ -538,10 +538,10 @@ public class WindowsPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"\\server\share\folder\subfolder");
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
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));
|
||||
@@ -556,10 +556,10 @@ public class WindowsPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"\\server\share");
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.CannotNavigateUp, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -570,10 +570,10 @@ public class WindowsPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"\\server\share\folder");
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
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));
|
||||
@@ -587,10 +587,10 @@ public class WindowsPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\");
|
||||
|
||||
// Act
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
Result<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.CannotNavigateUp, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -634,10 +634,10 @@ public class WindowsPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\Users\User\Documents");
|
||||
|
||||
// Act
|
||||
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("C:\\", true, true), result.Value);
|
||||
}
|
||||
|
||||
@@ -648,10 +648,10 @@ public class WindowsPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\");
|
||||
|
||||
// Act
|
||||
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("C:\\", true, true), result.Value);
|
||||
}
|
||||
|
||||
@@ -662,10 +662,10 @@ public class WindowsPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"InvalidFolder");
|
||||
|
||||
// Act
|
||||
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -676,10 +676,10 @@ public class WindowsPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"\\server\share\folder");
|
||||
|
||||
// Act
|
||||
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment(@"\\server\share\", true, false), result.Value);
|
||||
}
|
||||
|
||||
@@ -690,10 +690,10 @@ public class WindowsPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"\\");
|
||||
|
||||
// Act
|
||||
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -704,10 +704,10 @@ public class WindowsPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"\\server");
|
||||
|
||||
// Act
|
||||
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -718,10 +718,10 @@ public class WindowsPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"InvalidPath");
|
||||
|
||||
// Act
|
||||
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -732,10 +732,10 @@ public class WindowsPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"\\");
|
||||
|
||||
// Act
|
||||
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -746,10 +746,10 @@ public class WindowsPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"\\server\share");
|
||||
|
||||
// Act
|
||||
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment(@"\\server\share\", true, false), result.Value);
|
||||
}
|
||||
|
||||
@@ -760,10 +760,10 @@ public class WindowsPathStrategyTests
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(@"invalid\path");
|
||||
|
||||
// Act
|
||||
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
|
||||
Result<PathSegment> result = _sut.GetPathRoot(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.SharedKernel.Common.Errors;
|
||||
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 System.Diagnostics.CodeAnalysis;
|
||||
@@ -31,10 +31,10 @@ public class FileSystemPathIdTests
|
||||
string validPath = @"C:\TestDir\file.txt";
|
||||
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = FileSystemPathId.Create(validPath);
|
||||
Result<FileSystemPathId> result = FileSystemPathId.Create(validPath);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(validPath, result.Value.Path);
|
||||
}
|
||||
|
||||
@@ -45,10 +45,10 @@ public class FileSystemPathIdTests
|
||||
public void Create_WithInvalidPath_ShouldReturnError(string? invalidPath)
|
||||
{
|
||||
// Act
|
||||
ErrorOr<FileSystemPathId> result = FileSystemPathId.Create(invalidPath!);
|
||||
Result<FileSystemPathId> result = FileSystemPathId.Create(invalidPath!);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -33,9 +33,9 @@ public class FileSystemPathIdFixture
|
||||
{
|
||||
path ??= _faker.System.FilePath();
|
||||
|
||||
ErrorOr<FileSystemPathId> fileSystemPathIdResult = FileSystemPathId.Create(path);
|
||||
Result<FileSystemPathId> fileSystemPathIdResult = FileSystemPathId.Create(path);
|
||||
|
||||
if (fileSystemPathIdResult.IsError)
|
||||
if (fileSystemPathIdResult.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create FileSystemPathId: " + string.Join(", ", fileSystemPathIdResult.Errors));
|
||||
return fileSystemPathIdResult.Value;
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -39,9 +39,9 @@ public class PathSegmentFixture
|
||||
isDirectory ??= true;
|
||||
isDrive ??= false;
|
||||
|
||||
ErrorOr<PathSegment> pathResult = PathSegment.Create(name, isDirectory.Value, isDrive.Value);
|
||||
Result<PathSegment> pathResult = PathSegment.Create(name, isDirectory.Value, isDrive.Value);
|
||||
|
||||
if (pathResult.IsError)
|
||||
if (pathResult.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create PathSegment: " + string.Join(", ", pathResult.Errors));
|
||||
return pathResult.Value;
|
||||
}
|
||||
@@ -53,6 +53,6 @@ public class PathSegmentFixture
|
||||
/// <returns>The created list.</returns>
|
||||
public List<PathSegment> CreateMany(int count = 3)
|
||||
{
|
||||
return Enumerable.Range(0, count).Select(_ => CreatePathSegment()).ToList();
|
||||
return [.. Enumerable.Range(0, count).Select(_ => CreatePathSegment())];
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using System;
|
||||
@@ -58,10 +57,10 @@ public class StreamInfoFixture
|
||||
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);
|
||||
|
||||
ErrorOr<StreamInfo> streamInfoResult = StreamInfo.Create(
|
||||
Result<StreamInfo> streamInfoResult = StreamInfo.Create(
|
||||
streamId, mimeType, bitrate.Value, codec, resolution.Value, frameRate.Value, sampleRate.Value, channels.Value);
|
||||
|
||||
if (streamInfoResult.IsError)
|
||||
if (streamInfoResult.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create StreamInfo: " + string.Join(", ", streamInfoResult.Errors));
|
||||
return streamInfoResult.Value;
|
||||
}
|
||||
@@ -73,6 +72,6 @@ public class StreamInfoFixture
|
||||
/// <returns>The created list.</returns>
|
||||
public List<StreamInfo> CreateMany(int count = 3)
|
||||
{
|
||||
return Enumerable.Range(0, count).Select(_ => CreateStreamInfo()).ToList();
|
||||
return [.. Enumerable.Range(0, count).Select(_ => CreateStreamInfo())];
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.SharedKernel.Common.Errors;
|
||||
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 System.Diagnostics.CodeAnalysis;
|
||||
@@ -33,10 +33,10 @@ public class PathSegmentTests
|
||||
bool isDrive = false;
|
||||
|
||||
// Act
|
||||
ErrorOr<PathSegment> result = PathSegment.Create(name, isDirectory, isDrive);
|
||||
Result<PathSegment> result = PathSegment.Create(name, isDirectory, isDrive);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(name, result.Value.Name);
|
||||
Assert.Equal(isDirectory, result.Value.IsDirectory);
|
||||
Assert.Equal(isDrive, result.Value.IsDrive);
|
||||
@@ -49,10 +49,10 @@ public class PathSegmentTests
|
||||
public void Create_WithInvalidName_ShouldReturnError(string? invalidName)
|
||||
{
|
||||
// Act
|
||||
ErrorOr<PathSegment> result = PathSegment.Create(invalidName!, true, false);
|
||||
Result<PathSegment> result = PathSegment.Create(invalidName!, true, false);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.NameCannotBeEmpty, result.FirstError);
|
||||
}
|
||||
|
||||
|
||||
+9
-10
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.SharedKernel.Common.Errors;
|
||||
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;
|
||||
@@ -40,10 +39,10 @@ public class StreamInfoTests
|
||||
Optional<int> channels = Optional<int>.Some(2);
|
||||
|
||||
// Act
|
||||
ErrorOr<StreamInfo> result = StreamInfo.Create(streamId, mimeType, bitrate, codec, resolution, frameRate, sampleRate, channels);
|
||||
Result<StreamInfo> result = StreamInfo.Create(streamId, mimeType, bitrate, codec, resolution, frameRate, sampleRate, channels);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(streamId, result.Value.StreamId);
|
||||
Assert.Equal(mimeType, result.Value.MimeType);
|
||||
Assert.Equal(bitrate, result.Value.Bitrate);
|
||||
@@ -64,10 +63,10 @@ public class StreamInfoTests
|
||||
string codec = "h264";
|
||||
|
||||
// Act
|
||||
ErrorOr<StreamInfo> result = StreamInfo.Create(streamId!, mimeType, bitrate, codec, Optional<string>.None(), Optional<float>.None(), Optional<int>.None(), Optional<int>.None());
|
||||
Result<StreamInfo> result = StreamInfo.Create(streamId!, mimeType, bitrate, codec, Optional<string>.None(), Optional<float>.None(), Optional<int>.None(), Optional<int>.None());
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.StreamIdCannotBeEmpty, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -81,10 +80,10 @@ public class StreamInfoTests
|
||||
string? codec = null;
|
||||
|
||||
// Act
|
||||
ErrorOr<StreamInfo> result = StreamInfo.Create(streamId, mimeType, bitrate, codec!, Optional<string>.None(), Optional<float>.None(), Optional<int>.None(), Optional<int>.None());
|
||||
Result<StreamInfo> result = StreamInfo.Create(streamId, mimeType, bitrate, codec!, Optional<string>.None(), Optional<float>.None(), Optional<int>.None(), Optional<int>.None());
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.CodecCannotBeEmpty, result.FirstError);
|
||||
}
|
||||
|
||||
@@ -98,10 +97,10 @@ public class StreamInfoTests
|
||||
string codec = "h264";
|
||||
|
||||
// Act
|
||||
ErrorOr<StreamInfo> result = StreamInfo.Create(streamId, mimeType, bitrate, codec, Optional<string>.None(), Optional<float>.None(), Optional<int>.None(), Optional<int>.None());
|
||||
Result<StreamInfo> result = StreamInfo.Create(streamId, mimeType, bitrate, codec, Optional<string>.None(), Optional<float>.None(), Optional<int>.None(), Optional<int>.None());
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsError);
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.BitrateMustBeAPositiveNumber, result.FirstError);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user