Removes FluentAssertions library from test projects, due to licensing changes

This commit is contained in:
BinaryAlley committed 2025-02-03 00:31:15 +02:00
1 parent c1100e5398
commit d46bfae4fc
235 files changed
+4468 -4725

No files matched your search

@@ -1,6 +1,5 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FluentAssertions;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Common.Primitives;
@@ -33,12 +32,12 @@ public class DirectoryTests
ErrorOr<Directory> result = Directory.Create(path, name, dateCreated, dateModified);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().NotBeNull();
result.Value.Name.Should().Be(name);
result.Value.DateCreated.Should().Be(dateCreated);
result.Value.DateModified.Should().Be(dateModified);
result.Value.Status.Should().Be(FileSystemItemStatus.Accessible);
Assert.False(result.IsError);
Assert.NotNull(result.Value);
Assert.Equal(name, result.Value.Name);
Assert.Equal(dateCreated, result.Value.DateCreated);
Assert.Equal(dateModified, result.Value.DateModified);
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
}
[Fact]
@@ -54,8 +53,8 @@ public class DirectoryTests
ErrorOr<Directory> result = Directory.Create(invalidPath, name, dateCreated, dateModified);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -63,7 +62,7 @@ public class DirectoryTests
{
// Arrange
ErrorOr<FileSystemPathId> pathIdResult = FileSystemPathId.Create("/valid/path");
pathIdResult.IsError.Should().BeFalse();
Assert.False(pathIdResult.IsError);
FileSystemPathId pathId = pathIdResult.Value;
string name = "TestDirectory";
Optional<DateTime> dateCreated = DateTime.Now;
@@ -73,13 +72,13 @@ public class DirectoryTests
ErrorOr<Directory> result = Directory.Create(pathId, name, dateCreated, dateModified);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().NotBeNull();
result.Value.Id.Should().Be(pathId);
result.Value.Name.Should().Be(name);
result.Value.DateCreated.Should().Be(dateCreated);
result.Value.DateModified.Should().Be(dateModified);
result.Value.Status.Should().Be(FileSystemItemStatus.Accessible);
Assert.False(result.IsError);
Assert.NotNull(result.Value);
Assert.Equal(pathId, result.Value.Id);
Assert.Equal(name, result.Value.Name);
Assert.Equal(dateCreated, result.Value.DateCreated);
Assert.Equal(dateModified, result.Value.DateModified);
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
}
[Fact]
@@ -87,7 +86,7 @@ public class DirectoryTests
{
// Arrange
ErrorOr<Directory> directoryResult = Directory.Create("/valid/path", "TestDirectory", Optional<DateTime>.None(), Optional<DateTime>.None());
directoryResult.IsError.Should().BeFalse();
Assert.False(directoryResult.IsError);
Directory directory = directoryResult.Value;
DateTime newDate = DateTime.Now;
@@ -95,8 +94,8 @@ public class DirectoryTests
ErrorOr<Updated> result = directory.UpdateLastModified(newDate);
// Assert
result.IsError.Should().BeFalse();
directory.DateModified.Value.Should().Be(newDate);
Assert.False(result.IsError);
Assert.Equal(newDate, directory.DateModified.Value);
}
[Fact]
@@ -104,7 +103,7 @@ public class DirectoryTests
{
// Arrange
ErrorOr<Directory> directoryResult = Directory.Create("/valid/path", "TestDirectory", Optional<DateTime>.None(), Optional<DateTime>.None());
directoryResult.IsError.Should().BeFalse();
Assert.False(directoryResult.IsError);
Directory directory = directoryResult.Value;
FileSystemItem item = new FileSystemItemFixture(FileSystemPathId.Create("/mock/path").Value, "MockItem", FileSystemItemType.File);
@@ -112,8 +111,8 @@ public class DirectoryTests
ErrorOr<Updated> result = directory.AddItem(item);
// Assert
result.IsError.Should().BeFalse();
directory.Items.Should().Contain(item);
Assert.False(result.IsError);
Assert.Contains(item, directory.Items);
}
[Fact]
@@ -121,7 +120,7 @@ public class DirectoryTests
{
// Arrange
ErrorOr<Directory> directoryResult = Directory.Create("/valid/path", "TestDirectory", Optional<DateTime>.None(), Optional<DateTime>.None());
directoryResult.IsError.Should().BeFalse();
Assert.False(directoryResult.IsError);
Directory directory = directoryResult.Value;
FileSystemItem item = new FileSystemItemFixture(FileSystemPathId.Create("/mock/path").Value, "MockItem", FileSystemItemType.File);
directory.AddItem(item);
@@ -130,7 +129,7 @@ public class DirectoryTests
ErrorOr<Updated> result = directory.RemoveItem(item);
// Assert
result.IsError.Should().BeFalse();
directory.Items.Should().NotContain(item);
Assert.False(result.IsError);
Assert.DoesNotContain(item, directory.Items);
}
}
@@ -1,6 +1,5 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FluentAssertions;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Common.Primitives;
@@ -32,13 +31,13 @@ public class FileTests
ErrorOr<File> result = File.Create(path, name, dateCreated, dateModified, size);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().NotBeNull();
result.Value.Name.Should().Be(name);
result.Value.DateCreated.Should().Be(dateCreated);
result.Value.DateModified.Should().Be(dateModified);
result.Value.Size.Should().Be(size);
result.Value.Status.Should().Be(FileSystemItemStatus.Accessible);
Assert.False(result.IsError);
Assert.NotNull(result.Value);
Assert.Equal(name, result.Value.Name);
Assert.Equal(dateCreated, result.Value.DateCreated);
Assert.Equal(dateModified, result.Value.DateModified);
Assert.Equal(size, result.Value.Size);
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
}
[Fact]
@@ -55,8 +54,8 @@ public class FileTests
ErrorOr<File> result = File.Create(invalidPath, name, dateCreated, dateModified, size);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -64,7 +63,7 @@ public class FileTests
{
// Arrange
ErrorOr<FileSystemPathId> pathIdResult = FileSystemPathId.Create("/valid/path/file.txt");
pathIdResult.IsError.Should().BeFalse();
Assert.False(pathIdResult.IsError);
FileSystemPathId pathId = pathIdResult.Value;
string name = "file.txt";
Optional<DateTime> dateCreated = DateTime.Now;
@@ -75,14 +74,14 @@ public class FileTests
ErrorOr<File> result = File.Create(pathId, name, dateCreated, dateModified, size);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().NotBeNull();
result.Value.Id.Should().Be(pathId);
result.Value.Name.Should().Be(name);
result.Value.DateCreated.Should().Be(dateCreated);
result.Value.DateModified.Should().Be(dateModified);
result.Value.Size.Should().Be(size);
result.Value.Status.Should().Be(FileSystemItemStatus.Accessible);
Assert.False(result.IsError);
Assert.NotNull(result.Value);
Assert.Equal(pathId, result.Value.Id);
Assert.Equal(name, result.Value.Name);
Assert.Equal(dateCreated, result.Value.DateCreated);
Assert.Equal(dateModified, result.Value.DateModified);
Assert.Equal(size, result.Value.Size);
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
}
[Fact]
@@ -90,7 +89,7 @@ public class FileTests
{
// Arrange
ErrorOr<File> fileResult = File.Create("/valid/path/file.txt", "file.txt", Optional<DateTime>.None(), Optional<DateTime>.None(), 1024);
fileResult.IsError.Should().BeFalse();
Assert.False(fileResult.IsError);
File file = fileResult.Value;
DateTime newDate = DateTime.Now;
@@ -98,8 +97,8 @@ public class FileTests
ErrorOr<Updated> result = file.UpdateLastModified(newDate);
// Assert
result.IsError.Should().BeFalse();
file.DateModified.Value.Should().Be(newDate);
Assert.False(result.IsError);
Assert.Equal(newDate, file.DateModified.Value);
}
[Fact]
@@ -107,7 +106,7 @@ public class FileTests
{
// Arrange
ErrorOr<File> fileResult = File.Create("/valid/path/file.txt", "file.txt", Optional<DateTime>.None(), Optional<DateTime>.None(), 1024);
fileResult.IsError.Should().BeFalse();
Assert.False(fileResult.IsError);
File file = fileResult.Value;
long newSize = 2048;
@@ -115,8 +114,8 @@ public class FileTests
ErrorOr<Updated> result = file.UpdateSize(newSize);
// Assert
result.IsError.Should().BeFalse();
file.Size.Should().Be(newSize);
Assert.False(result.IsError);
Assert.Equal(newSize, file.Size);
}
[Fact]
@@ -124,7 +123,7 @@ public class FileTests
{
// Arrange
ErrorOr<File> fileResult = File.Create("/valid/path/file.txt", "file.txt", Optional<DateTime>.None(), Optional<DateTime>.None(), 1024);
fileResult.IsError.Should().BeFalse();
Assert.False(fileResult.IsError);
File file = fileResult.Value;
string newName = "newfile.txt";
@@ -132,8 +131,8 @@ public class FileTests
ErrorOr<Updated> result = file.Rename(newName);
// Assert
result.IsError.Should().BeFalse();
file.Name.Should().Be(newName);
Assert.False(result.IsError);
Assert.Equal(newName, file.Name);
}
[Fact]
@@ -141,7 +140,7 @@ public class FileTests
{
// Arrange
ErrorOr<File> fileResult = File.Create("/valid/path/file.txt", "file.txt", Optional<DateTime>.None(), Optional<DateTime>.None(), 1024);
fileResult.IsError.Should().BeFalse();
Assert.False(fileResult.IsError);
File file = fileResult.Value;
string emptyName = "";
@@ -149,8 +148,8 @@ public class FileTests
ErrorOr<Updated> result = file.Rename(emptyName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.NameCannotBeEmpty);
file.Name.Should().Be("file.txt");
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.NameCannotBeEmpty, result.FirstError);
Assert.Equal("file.txt", file.Name);
}
}
@@ -1,6 +1,5 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FluentAssertions;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
@@ -24,13 +23,13 @@ public class UnixRootItemTests
ErrorOr<UnixRootItem> result = UnixRootItem.Create();
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().NotBeNull();
result.Value.Name.Should().Be("/");
result.Value.Id.Path.Should().Be("/");
result.Value.Type.Should().Be(FileSystemItemType.Root);
result.Value.Status.Should().Be(FileSystemItemStatus.Accessible);
result.Value.Items.Should().BeEmpty();
Assert.False(result.IsError);
Assert.NotNull(result.Value);
Assert.Equal("/", result.Value.Name);
Assert.Equal("/", result.Value.Id.Path);
Assert.Equal(FileSystemItemType.Root, result.Value.Type);
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
Assert.Empty(result.Value.Items);
}
[Fact]
@@ -43,13 +42,13 @@ public class UnixRootItemTests
ErrorOr<UnixRootItem> result = UnixRootItem.Create(customStatus);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().NotBeNull();
result.Value.Name.Should().Be("/");
result.Value.Id.Path.Should().Be("/");
result.Value.Type.Should().Be(FileSystemItemType.Root);
result.Value.Status.Should().Be(customStatus);
result.Value.Items.Should().BeEmpty();
Assert.False(result.IsError);
Assert.NotNull(result.Value);
Assert.Equal("/", result.Value.Name);
Assert.Equal("/", result.Value.Id.Path);
Assert.Equal(FileSystemItemType.Root, result.Value.Type);
Assert.Equal(customStatus, result.Value.Status);
Assert.Empty(result.Value.Items);
}
[Fact]
@@ -57,15 +56,15 @@ public class UnixRootItemTests
{
// Arrange
ErrorOr<UnixRootItem> createResult = UnixRootItem.Create();
createResult.IsError.Should().BeFalse();
Assert.False(createResult.IsError);
UnixRootItem unixRootItem = createResult.Value;
// Act
IReadOnlyCollection<FileSystemItem> items = unixRootItem.Items;
// Assert
items.Should().BeEmpty();
items.Should().BeAssignableTo<IReadOnlyCollection<FileSystemItem>>();
Assert.Empty(items);
Assert.IsAssignableFrom<IReadOnlyCollection<FileSystemItem>>(items);
}
[Fact]
@@ -73,7 +72,7 @@ public class UnixRootItemTests
{
// Arrange
ErrorOr<UnixRootItem> createResult = UnixRootItem.Create();
createResult.IsError.Should().BeFalse();
Assert.False(createResult.IsError);
UnixRootItem unixRootItem = createResult.Value;
FileSystemItemStatus newStatus = FileSystemItemStatus.Accessible;
@@ -81,8 +80,8 @@ public class UnixRootItemTests
ErrorOr<Updated> result = unixRootItem.SetStatus(newStatus);
// Assert
result.IsError.Should().BeFalse();
unixRootItem.Status.Should().Be(newStatus);
Assert.False(result.IsError);
Assert.Equal(newStatus, unixRootItem.Status);
}
[Fact]
@@ -90,15 +89,15 @@ public class UnixRootItemTests
{
// Arrange
ErrorOr<UnixRootItem> createResult = UnixRootItem.Create();
createResult.IsError.Should().BeFalse();
Assert.False(createResult.IsError);
UnixRootItem unixRootItem = createResult.Value;
// Act
ErrorOr<Updated> result = unixRootItem.SetParent(null!);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.ParentNodeCannotBeNull);
unixRootItem.Parent.HasValue.Should().BeFalse();
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.ParentNodeCannotBeNull, result.FirstError);
Assert.False(unixRootItem.Parent.HasValue);
}
}
@@ -1,6 +1,5 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FluentAssertions;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
@@ -29,13 +28,13 @@ public class WindowsRootItemTests
ErrorOr<WindowsRootItem> result = WindowsRootItem.Create(path, name);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().NotBeNull();
result.Value.Name.Should().Be(name);
result.Value.Id.Path.Should().Be(path);
result.Value.Type.Should().Be(FileSystemItemType.Root);
result.Value.Status.Should().Be(FileSystemItemStatus.Accessible);
result.Value.Items.Should().BeEmpty();
Assert.False(result.IsError);
Assert.NotNull(result.Value);
Assert.Equal(name, result.Value.Name);
Assert.Equal(path, result.Value.Id.Path);
Assert.Equal(FileSystemItemType.Root, result.Value.Type);
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
Assert.Empty(result.Value.Items);
}
[Fact]
@@ -49,8 +48,8 @@ public class WindowsRootItemTests
ErrorOr<WindowsRootItem> result = WindowsRootItem.Create(invalidPath, name);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -65,12 +64,12 @@ public class WindowsRootItemTests
ErrorOr<WindowsRootItem> result = WindowsRootItem.Create(path, name, customStatus);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().NotBeNull();
result.Value.Name.Should().Be(name);
result.Value.Id.Path.Should().Be(path);
result.Value.Type.Should().Be(FileSystemItemType.Root);
result.Value.Status.Should().Be(customStatus);
Assert.False(result.IsError);
Assert.NotNull(result.Value);
Assert.Equal(name, result.Value.Name);
Assert.Equal(path, result.Value.Id.Path);
Assert.Equal(FileSystemItemType.Root, result.Value.Type);
Assert.Equal(customStatus, result.Value.Status);
}
[Fact]
@@ -78,7 +77,7 @@ public class WindowsRootItemTests
{
// Arrange
ErrorOr<FileSystemPathId> pathIdResult = FileSystemPathId.Create("E:\\");
pathIdResult.IsError.Should().BeFalse();
Assert.False(pathIdResult.IsError);
FileSystemPathId pathId = pathIdResult.Value;
string name = "E:";
@@ -86,12 +85,12 @@ public class WindowsRootItemTests
ErrorOr<WindowsRootItem> result = WindowsRootItem.Create(pathId, name);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().NotBeNull();
result.Value.Id.Should().Be(pathId);
result.Value.Name.Should().Be(name);
result.Value.Type.Should().Be(FileSystemItemType.Root);
result.Value.Status.Should().Be(FileSystemItemStatus.Accessible);
Assert.False(result.IsError);
Assert.NotNull(result.Value);
Assert.Equal(pathId, result.Value.Id);
Assert.Equal(name, result.Value.Name);
Assert.Equal(FileSystemItemType.Root, result.Value.Type);
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
}
[Fact]
@@ -99,15 +98,15 @@ public class WindowsRootItemTests
{
// Arrange
ErrorOr<WindowsRootItem> createResult = WindowsRootItem.Create("F:\\", "F:");
createResult.IsError.Should().BeFalse();
Assert.False(createResult.IsError);
WindowsRootItem windowsRootItem = createResult.Value;
// Act
IReadOnlyCollection<FileSystemItem> items = windowsRootItem.Items;
// Assert
items.Should().BeEmpty();
items.Should().BeAssignableTo<IReadOnlyCollection<FileSystemItem>>();
Assert.Empty(items);
Assert.IsAssignableFrom<IReadOnlyCollection<FileSystemItem>>(items);
}
[Fact]
@@ -115,7 +114,7 @@ public class WindowsRootItemTests
{
// Arrange
ErrorOr<WindowsRootItem> createResult = WindowsRootItem.Create("G:\\", "G:");
createResult.IsError.Should().BeFalse();
Assert.False(createResult.IsError);
WindowsRootItem windowsRootItem = createResult.Value;
FileSystemItemStatus newStatus = FileSystemItemStatus.Accessible;
@@ -123,8 +122,8 @@ public class WindowsRootItemTests
ErrorOr<Updated> result = windowsRootItem.SetStatus(newStatus);
// Assert
result.IsError.Should().BeFalse();
windowsRootItem.Status.Should().Be(newStatus);
Assert.False(result.IsError);
Assert.Equal(newStatus, windowsRootItem.Status);
}
[Fact]
@@ -132,15 +131,15 @@ public class WindowsRootItemTests
{
// Arrange
ErrorOr<WindowsRootItem> createResult = WindowsRootItem.Create("H:\\", "H:");
createResult.IsError.Should().BeFalse();
Assert.False(createResult.IsError);
WindowsRootItem windowsRootItem = createResult.Value;
// Act
ErrorOr<Updated> result = windowsRootItem.SetParent(null!);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.ParentNodeCannotBeNull);
windowsRootItem.Parent.HasValue.Should().BeFalse();
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.ParentNodeCannotBeNull, result.FirstError);
Assert.False(windowsRootItem.Parent.HasValue);
}
}
@@ -2,7 +2,6 @@
using AutoFixture;
using AutoFixture.AutoNSubstitute;
using ErrorOr;
using FluentAssertions;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Common.Primitives;
@@ -45,11 +44,11 @@ public class FileSystemItemTests
FileSystemItemFixture item = new(id, name, type);
// Assert
item.Id.Should().Be(id);
item.Name.Should().Be(name);
item.Type.Should().Be(type);
item.Status.Should().Be(FileSystemItemStatus.Accessible);
item.Parent.Should().Be(Optional<FileSystemItem>.None());
Assert.Equal(id, item.Id);
Assert.Equal(name, item.Name);
Assert.Equal(type, item.Type);
Assert.Equal(FileSystemItemStatus.Accessible, item.Status);
Assert.Equal(Optional<FileSystemItem>.None(), item.Parent);
}
[Fact]
@@ -63,9 +62,9 @@ public class FileSystemItemTests
ErrorOr<Updated> result = item.SetStatus(newStatus);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().Be(Result.Updated);
item.Status.Should().Be(newStatus);
Assert.False(result.IsError);
Assert.Equal(Result.Updated, result.Value);
Assert.Equal(newStatus, item.Status);
}
[Fact]
@@ -79,9 +78,9 @@ public class FileSystemItemTests
ErrorOr<Updated> result = item.SetParent(parent);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().Be(Result.Updated);
item.Parent.Should().Be(Optional<FileSystemItem>.Some(parent));
Assert.False(result.IsError);
Assert.Equal(Result.Updated, result.Value);
Assert.Equal(Optional<FileSystemItem>.Some(parent), item.Parent);
}
[Fact]
@@ -94,9 +93,9 @@ public class FileSystemItemTests
ErrorOr<Updated> result = item.SetParent(null!);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.ParentNodeCannotBeNull);
item.Parent.Should().Be(Optional<FileSystemItem>.None());
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.ParentNodeCannotBeNull, result.FirstError);
Assert.Equal(Optional<FileSystemItem>.None(), item.Parent);
}
[Fact]
@@ -111,7 +110,7 @@ public class FileSystemItemTests
bool result = item1.Equals(item2);
// Assert
result.Should().BeTrue();
Assert.True(result);
}
[Fact]
@@ -125,7 +124,7 @@ public class FileSystemItemTests
bool result = item1.Equals(item2);
// Assert
result.Should().BeFalse();
Assert.False(result);
}
[Fact]
@@ -141,7 +140,7 @@ public class FileSystemItemTests
int hashCode2 = item2.GetHashCode();
// Assert
hashCode1.Should().Be(hashCode2);
Assert.Equal(hashCode1, hashCode2);
}
[Fact]
@@ -156,7 +155,7 @@ public class FileSystemItemTests
int hashCode2 = item2.GetHashCode();
// Assert
hashCode1.Should().NotBe(hashCode2);
Assert.NotEqual(hashCode1, hashCode2);
}
private FileSystemItemFixture CreateFileSystemItemFixture(FileSystemPathId? id = null)
@@ -2,7 +2,6 @@
using AutoFixture;
using AutoFixture.AutoNSubstitute;
using ErrorOr;
using FluentAssertions;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Common.Primitives;
@@ -80,8 +79,8 @@ public class DirectoryProviderServiceTests
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetSubdirectoryPaths(path, false);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -98,9 +97,12 @@ public class DirectoryProviderServiceTests
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetSubdirectoryPaths(path, false);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(3);
result.Value.Select(x => x.Path).Should().BeEquivalentTo(subdirectories.Select(x => x + _dirSeparator));
Assert.False(result.IsError);
Assert.Equal(3, result.Value.Count());
Assert.Equal(
subdirectories.Select(x => x + _dirSeparator).OrderBy(x => x),
result.Value.Select(x => x.Path).OrderBy(x => x)
);
}
[Fact]
@@ -119,9 +121,9 @@ public class DirectoryProviderServiceTests
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetSubdirectoryPaths(path, false);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(1);
result.Value.First().Path.Should().Be(_pathVisible2);
Assert.False(result.IsError);
Assert.Single(result.Value);
Assert.Equal(_pathVisible2, result.Value.First().Path);
}
[Fact]
@@ -140,9 +142,12 @@ public class DirectoryProviderServiceTests
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetSubdirectoryPaths(path, true);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(2);
result.Value.Select(x => x.Path).Should().BeEquivalentTo([_pathVisible2, _pathHidden2]);
Assert.False(result.IsError);
Assert.Equal(2, result.Value.Count());
Assert.Equal(
new[] { _pathVisible2, _pathHidden2 }.OrderBy(p => p),
result.Value.Select(x => x.Path).OrderBy(p => p)
);
}
[Fact]
@@ -161,14 +166,14 @@ public class DirectoryProviderServiceTests
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetSubdirectoryPaths(path, false);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(2);
result.Value.First().Path.Should().Be(_pathInvalid2);
result.Value.Last().Path.Should().Be(_pathValid2);
Assert.False(result.IsError);
Assert.Equal(2, result.Value.Count());
Assert.Equal(_pathInvalid2, result.Value.First().Path);
Assert.Equal(_pathValid2, result.Value.Last().Path);
}
[Fact]
public void GetSubdirectoryPaths_ShouldOrderDirectoriesAlphabetically()
public void GetSubdirectoryPaths_WhenCalled_ShouldOrderDirectoriesAlphabetically()
{
// Arrange
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
@@ -187,8 +192,8 @@ public class DirectoryProviderServiceTests
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetSubdirectoryPaths(path, false);
// Assert
result.IsError.Should().BeFalse();
result.Value.Select(x => x.Path).Should().BeEquivalentTo(expectedPaths, options => options.WithStrictOrdering());
Assert.False(result.IsError);
Assert.Equal(expectedPaths, result.Value.Select(x => x.Path));
}
[Fact]
@@ -203,8 +208,8 @@ public class DirectoryProviderServiceTests
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetSubdirectoryPaths(path, false);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().BeEmpty();
Assert.False(result.IsError);
Assert.Empty(result.Value);
}
[Fact]
@@ -218,8 +223,8 @@ public class DirectoryProviderServiceTests
ErrorOr<bool> result = _sut.DirectoryExists(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().BeTrue();
Assert.False(result.IsError);
Assert.True(result.Value);
}
[Fact]
@@ -233,8 +238,8 @@ public class DirectoryProviderServiceTests
ErrorOr<bool> result = _sut.DirectoryExists(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().BeFalse();
Assert.False(result.IsError);
Assert.False(result.Value);
}
[Fact]
@@ -251,8 +256,8 @@ public class DirectoryProviderServiceTests
ErrorOr<string> result = _sut.GetFileName(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().Be("file.txt");
Assert.False(result.IsError);
Assert.Equal("file.txt", result.Value);
}
[Fact]
@@ -270,8 +275,8 @@ public class DirectoryProviderServiceTests
ErrorOr<string> result = _sut.GetFileName(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().Be("subfolder");
Assert.False(result.IsError);
Assert.Equal("subfolder", result.Value);
}
[Fact]
@@ -289,8 +294,8 @@ public class DirectoryProviderServiceTests
ErrorOr<string> result = _sut.GetFileName(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().BeEmpty();
Assert.False(result.IsError);
Assert.Empty(result.Value);
}
[Fact]
@@ -306,9 +311,9 @@ public class DirectoryProviderServiceTests
ErrorOr<Optional<DateTime>> result = _sut.GetLastWriteTime(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.HasValue.Should().BeTrue();
result.Value.Value.Should().Be(expectedDateTime);
Assert.False(result.IsError);
Assert.True(result.Value.HasValue);
Assert.Equal(expectedDateTime, result.Value.Value);
}
[Fact]
@@ -322,8 +327,8 @@ public class DirectoryProviderServiceTests
ErrorOr<Optional<DateTime>> result = _sut.GetLastWriteTime(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -339,9 +344,9 @@ public class DirectoryProviderServiceTests
ErrorOr<Optional<DateTime>> result = _sut.GetCreationTime(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.HasValue.Should().BeTrue();
result.Value.Value.Should().Be(expectedDateTime);
Assert.False(result.IsError);
Assert.True(result.Value.HasValue);
Assert.Equal(expectedDateTime, result.Value.Value);
}
[Fact]
@@ -355,8 +360,8 @@ public class DirectoryProviderServiceTests
ErrorOr<Optional<DateTime>> result = _sut.GetCreationTime(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -380,8 +385,8 @@ public class DirectoryProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.CreateDirectory(parentPath, directoryName);
// Assert
result.IsError.Should().BeFalse();
result.Value.Path.Should().Be(fullPath);
Assert.False(result.IsError);
Assert.Equal(fullPath, result.Value.Path);
_mockFileSystem.Directory.Received(1).CreateDirectory(fullPath);
}
@@ -398,8 +403,8 @@ public class DirectoryProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.CreateDirectory(parentPath, directoryName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
_mockFileSystem.Directory.DidNotReceive().CreateDirectory(Arg.Any<string>());
}
@@ -414,8 +419,8 @@ public class DirectoryProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.CreateDirectory(parentPath, directoryName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Type.Should().Be(ErrorType.Failure);
Assert.True(result.IsError);
Assert.Equal(ErrorType.Failure, result.FirstError.Type);
}
[Fact]
@@ -434,8 +439,8 @@ public class DirectoryProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.CreateDirectory(parentPath, directoryName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Type.Should().Be(ErrorType.Validation);
Assert.True(result.IsError);
Assert.Equal(ErrorType.Validation, result.FirstError.Type);
}
[Fact]
@@ -462,8 +467,8 @@ public class DirectoryProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.CopyDirectory(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeFalse();
result.Value.Path.Should().Be(destinationPath.Path);
Assert.False(result.IsError);
Assert.Equal(destinationPath.Path, result.Value.Path);
_mockFileSystem.Directory.Received(1).CreateDirectory(destinationPath.Path);
}
@@ -481,8 +486,8 @@ public class DirectoryProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.CopyDirectory(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.DirectoryNotFound);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.DirectoryNotFound, result.FirstError);
}
[Fact]
@@ -514,8 +519,8 @@ public class DirectoryProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.CopyDirectory(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeFalse();
result.Value.Path.Should().Be(expectedNewDirectoryPath);
Assert.False(result.IsError);
Assert.Equal(expectedNewDirectoryPath, result.Value.Path);
_mockFileSystem.Directory.Received(1).CreateDirectory(expectedNewDirectoryPath);
}
@@ -566,8 +571,8 @@ public class DirectoryProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.CopyDirectory(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeFalse();
result.Value.Path.Should().Be(_pathDestination);
Assert.False(result.IsError);
Assert.Equal(_pathDestination, result.Value.Path);
_mockFileSystem.Directory.Received(1).CreateDirectory(_pathDestination);
_mockFileSystem.Directory.Received(1).CreateDirectory(_pathDestinationSubDir);
mockFile.Received(1).CopyTo(_pathDestinationFile, overrideExisting);
@@ -589,8 +594,8 @@ public class DirectoryProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.CopyDirectory(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.DirectoryCopyError);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.DirectoryCopyError, result.FirstError);
}
[Fact]
@@ -609,8 +614,8 @@ public class DirectoryProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.MoveDirectory(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.DirectoryNotFound);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.DirectoryNotFound, result.FirstError);
}
[Fact]
@@ -628,8 +633,8 @@ public class DirectoryProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.MoveDirectory(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeFalse();
result.Value.Path.Should().Be(destinationPath.Path);
Assert.False(result.IsError);
Assert.Equal(destinationPath.Path, result.Value.Path);
_mockFileSystem.Directory.Received(1).Move(sourcePath.Path, destinationPath.Path);
}
@@ -662,8 +667,8 @@ public class DirectoryProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.MoveDirectory(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeFalse();
result.Value.Path.Should().Be(destinationPath.Path);
Assert.False(result.IsError);
Assert.Equal(destinationPath.Path, result.Value.Path);
_mockFileSystem.File.Received(1).Move(_pathSourceFile1, _pathDestinationFile1);
_mockFileSystem.Directory.Received(1).Move(
_pathSourceSubDir,
@@ -689,8 +694,8 @@ public class DirectoryProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.MoveDirectory(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.DirectoryMoveError);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.DirectoryMoveError, result.FirstError);
}
[Fact]
@@ -727,8 +732,8 @@ public class DirectoryProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.MoveDirectory(sourcePath, destPath, overwrite);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().Be(destPath);
Assert.False(result.IsError);
Assert.Equal(destPath, result.Value);
_mockFileSystem.File.Received(1).Delete(_pathDestinationFile1);
_mockFileSystem.File.Received(1).Move(_pathSourceFile1, _pathDestinationFile1);
_mockFileSystem.File.Received(1).Move(_pathSourceFile2, _pathDestinationFile2);
@@ -765,8 +770,8 @@ public class DirectoryProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.MoveDirectory(sourcePath, destPath, overwrite);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().Be(destPath);
Assert.False(result.IsError);
Assert.Equal(destPath, result.Value);
_mockFileSystem.File.DidNotReceive().Delete(Arg.Any<string>());
_mockFileSystem.File.DidNotReceive().Move(_pathSourceFile1, _pathDestinationFile1);
_mockFileSystem.File.Received(1).Move(_pathSourceFile2, _pathDestinationFile2);
@@ -831,8 +836,8 @@ public class DirectoryProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.MoveDirectory(sourcePath, destPath, overwrite);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().Be(destPath);
Assert.False(result.IsError);
Assert.Equal(destPath, result.Value);
_mockFileSystem.File.Received(1).Move(
s_isUnix ? "/Source/SubDir/file.txt" : @"C:\Source\SubDir\file.txt",
s_isUnix ? "/Destination/SubDir/file.txt" : @"C:\Destination\SubDir\file.txt"
@@ -863,8 +868,8 @@ public class DirectoryProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.RenameDirectory(path, newName);
// Assert
result.IsError.Should().BeFalse();
result.Value.Path.Should().Be(newPath);
Assert.False(result.IsError);
Assert.Equal(newPath, result.Value.Path);
_mockFileSystem.Directory.Received(1).Move(path.Path, newPath);
}
@@ -889,8 +894,8 @@ public class DirectoryProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.RenameDirectory(path, newName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
_mockFileSystem.Directory.DidNotReceive().Move(Arg.Any<string>(), Arg.Any<string>());
}
@@ -916,8 +921,8 @@ public class DirectoryProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.RenameDirectory(path, newName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
_mockFileSystem.Directory.DidNotReceive().Move(Arg.Any<string>(), Arg.Any<string>());
}
@@ -936,8 +941,8 @@ public class DirectoryProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.RenameDirectory(path, newName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
_mockFileSystem.Directory.DidNotReceive().Move(Arg.Any<string>(), Arg.Any<string>());
}
@@ -960,8 +965,8 @@ public class DirectoryProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.RenameDirectory(path, newName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
_mockFileSystem.Directory.DidNotReceive().Move(Arg.Any<string>(), Arg.Any<string>());
}
@@ -980,8 +985,8 @@ public class DirectoryProviderServiceTests
ErrorOr<Deleted> result = _sut.DeleteDirectory(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().Be(Result.Deleted);
Assert.False(result.IsError);
Assert.Equal(Result.Deleted, result.Value);
mockDirectoryInfo.Received(1).Delete(true);
}
@@ -998,8 +1003,8 @@ public class DirectoryProviderServiceTests
ErrorOr<Deleted> result = _sut.DeleteDirectory(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
_mockFileSystem.DirectoryInfo.DidNotReceive().New(Arg.Any<string>());
}
}
@@ -1,6 +1,5 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FluentAssertions;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Common.Primitives;
@@ -83,9 +82,9 @@ public class DirectoryServiceTests
ErrorOr<IEnumerable<Directory>> result = _sut.GetSubdirectories(path, includeHiddenElements);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(2);
result.Value.Select(d => d.Name).Should().BeEquivalentTo(["Sub1", "Sub2"]);
Assert.False(result.IsError);
Assert.Equal(2, result.Value.Count());
Assert.Equal(["Sub1", "Sub2"], result.Value.Select(d => d.Name));
}
[Fact]
@@ -99,8 +98,8 @@ public class DirectoryServiceTests
ErrorOr<IEnumerable<Directory>> result = _sut.GetSubdirectories(invalidPath, includeHiddenElements);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -118,8 +117,8 @@ public class DirectoryServiceTests
ErrorOr<IEnumerable<Directory>> result = _sut.GetSubdirectories(path, includeHiddenElements);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -147,9 +146,9 @@ public class DirectoryServiceTests
ErrorOr<IEnumerable<Directory>> result = _sut.GetSubdirectories(path, includeHiddenElements);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(1);
result.Value.First().Status.Should().Be(FileSystemItemStatus.Inaccessible);
Assert.False(result.IsError);
Assert.Single(result.Value);
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.First().Status);
}
[Fact]
@@ -181,9 +180,9 @@ public class DirectoryServiceTests
ErrorOr<IEnumerable<Directory>> result = _sut.GetSubdirectories(parentDirectory, includeHiddenElements);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(2);
result.Value.Select(d => d.Name).Should().BeEquivalentTo(["Sub1", "Sub2"]);
Assert.False(result.IsError);
Assert.Equal(2, result.Value.Count());
Assert.Equal(["Sub1", "Sub2"], result.Value.Select(d => d.Name));
}
[Fact]
@@ -200,8 +199,8 @@ public class DirectoryServiceTests
ErrorOr<IEnumerable<Directory>> result = _sut.GetSubdirectories(parentDirectory, includeHiddenElements);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -228,9 +227,9 @@ public class DirectoryServiceTests
ErrorOr<IEnumerable<Directory>> result = _sut.GetSubdirectories(parentDirectory, includeHiddenElements);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(1);
result.Value.First().Status.Should().Be(FileSystemItemStatus.Inaccessible);
Assert.False(result.IsError);
Assert.Single(result.Value);
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.First().Status);
}
[Fact]
@@ -262,9 +261,9 @@ public class DirectoryServiceTests
ErrorOr<IEnumerable<Directory>> result = _sut.GetSubdirectories(pathId, includeHiddenElements);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(2);
result.Value.Select(d => d.Name).Should().BeEquivalentTo(["Sub1", "Sub2"]);
Assert.False(result.IsError);
Assert.Equal(2, result.Value.Count());
Assert.Equal(["Sub1", "Sub2"], result.Value.Select(d => d.Name));
}
[Fact]
@@ -281,8 +280,8 @@ public class DirectoryServiceTests
ErrorOr<IEnumerable<Directory>> result = _sut.GetSubdirectories(pathId, includeHiddenElements);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -309,9 +308,9 @@ public class DirectoryServiceTests
ErrorOr<IEnumerable<Directory>> result = _sut.GetSubdirectories(pathId, includeHiddenElements);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(1);
result.Value.First().Status.Should().Be(FileSystemItemStatus.Inaccessible);
Assert.False(result.IsError);
Assert.Single(result.Value);
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.First().Status);
}
[Fact]
@@ -336,8 +335,8 @@ public class DirectoryServiceTests
ErrorOr<Directory> result = _sut.CreateDirectory(parentPath, newDirName);
// Assert
result.IsError.Should().BeFalse();
result.Value.Id.Should().Be(newDirPathId);
Assert.False(result.IsError);
Assert.Equal(newDirPathId, result.Value.Id);
}
[Fact]
@@ -351,8 +350,8 @@ public class DirectoryServiceTests
ErrorOr<Directory> result = _sut.CreateDirectory(invalidPath, newDirName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -376,8 +375,8 @@ public class DirectoryServiceTests
ErrorOr<Directory> result = _sut.CreateDirectory(parentPathId, newDirName);
// Assert
result.IsError.Should().BeFalse();
result.Value.Id.Should().Be(newDirPathId);
Assert.False(result.IsError);
Assert.Equal(newDirPathId, result.Value.Id);
}
[Fact]
@@ -394,8 +393,8 @@ public class DirectoryServiceTests
ErrorOr<Directory> result = _sut.CreateDirectory(parentPathId, newDirName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -420,11 +419,11 @@ public class DirectoryServiceTests
ErrorOr<Directory> result = _sut.CreateDirectory(parentPathId, newDirName);
// Assert
result.IsError.Should().BeFalse();
result.Value.Status.Should().Be(FileSystemItemStatus.Inaccessible);
result.Value.Id.Should().Be(newDirPathId);
result.Value.DateCreated.HasValue.Should().BeFalse();
result.Value.DateModified.HasValue.Should().BeFalse();
Assert.False(result.IsError);
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.Status);
Assert.Equal(newDirPathId, result.Value.Id);
Assert.False(result.Value.DateCreated.HasValue);
Assert.False(result.Value.DateModified.HasValue);
}
[Fact]
@@ -443,8 +442,8 @@ public class DirectoryServiceTests
ErrorOr<Directory> result = _sut.CreateDirectory(parentPathId, newDirName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -462,8 +461,8 @@ public class DirectoryServiceTests
ErrorOr<Directory> result = _sut.CreateDirectory(parentPathId, newDirName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.DirectoryAlreadyExists);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.DirectoryAlreadyExists, result.FirstError);
}
[Fact]
@@ -480,8 +479,8 @@ public class DirectoryServiceTests
ErrorOr<Directory> result = _sut.CreateDirectory(parentPathId, newDirName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
// Verify that DirectoryExists was not called
_mockEnvironmentContext.DirectoryProviderService.DidNotReceive().DirectoryExists(Arg.Any<FileSystemPathId>());
@@ -512,9 +511,9 @@ public class DirectoryServiceTests
ErrorOr<Directory> result = _sut.RenameDirectory(oldPath, newName);
// Assert
result.IsError.Should().BeFalse();
result.Value.Id.Should().Be(newPathId);
result.Value.Name.Should().Be(newName);
Assert.False(result.IsError);
Assert.Equal(newPathId, result.Value.Id);
Assert.Equal(newName, result.Value.Name);
}
[Fact]
@@ -528,8 +527,8 @@ public class DirectoryServiceTests
ErrorOr<Directory> result = _sut.RenameDirectory(invalidPath, newName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -557,9 +556,9 @@ public class DirectoryServiceTests
ErrorOr<Directory> result = _sut.RenameDirectory(oldPathId, newName);
// Assert
result.IsError.Should().BeFalse();
result.Value.Id.Should().Be(newPathId);
result.Value.Name.Should().Be(newName);
Assert.False(result.IsError);
Assert.Equal(newPathId, result.Value.Id);
Assert.Equal(newName, result.Value.Name);
}
[Fact]
@@ -578,8 +577,8 @@ public class DirectoryServiceTests
ErrorOr<Directory> result = _sut.RenameDirectory(oldPathId, newName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -608,11 +607,11 @@ public class DirectoryServiceTests
ErrorOr<Directory> result = _sut.RenameDirectory(oldPathId, newName);
// Assert
result.IsError.Should().BeFalse();
result.Value.Status.Should().Be(FileSystemItemStatus.Inaccessible);
result.Value.Id.Should().Be(newPathId);
result.Value.DateCreated.HasValue.Should().BeFalse();
result.Value.DateModified.HasValue.Should().BeFalse();
Assert.False(result.IsError);
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.Status);
Assert.Equal(newPathId, result.Value.Id);
Assert.False(result.Value.DateCreated.HasValue);
Assert.False(result.Value.DateModified.HasValue);
}
[Fact]
@@ -636,8 +635,8 @@ public class DirectoryServiceTests
ErrorOr<Directory> result = _sut.RenameDirectory(oldPathId, newName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.DirectoryAlreadyExists);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.DirectoryAlreadyExists, result.FirstError);
}
[Fact]
@@ -656,8 +655,8 @@ public class DirectoryServiceTests
ErrorOr<Directory> result = _sut.RenameDirectory(oldPathId, newName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
// Verify that DirectoryExists and RenameDirectory were not called
_mockEnvironmentContext.DirectoryProviderService.DidNotReceive().DirectoryExists(Arg.Any<FileSystemPathId>());
@@ -685,8 +684,8 @@ public class DirectoryServiceTests
ErrorOr<Directory> result = _sut.RenameDirectory(oldPathId, newName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
// Verify that RenameDirectory was not called
_mockEnvironmentContext.DirectoryProviderService.DidNotReceive().RenameDirectory(Arg.Any<FileSystemPathId>(), Arg.Any<string>());
@@ -706,8 +705,8 @@ public class DirectoryServiceTests
ErrorOr<Deleted> result = _sut.DeleteDirectory(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().Be(Result.Deleted);
Assert.False(result.IsError);
Assert.Equal(Result.Deleted, result.Value);
}
[Fact]
@@ -720,8 +719,8 @@ public class DirectoryServiceTests
ErrorOr<Deleted> result = _sut.DeleteDirectory(invalidPath);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -739,8 +738,8 @@ public class DirectoryServiceTests
ErrorOr<Deleted> result = _sut.DeleteDirectory(pathId);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().Be(Result.Deleted);
Assert.False(result.IsError);
Assert.Equal(Result.Deleted, result.Value);
}
[Fact]
@@ -758,8 +757,8 @@ public class DirectoryServiceTests
ErrorOr<Deleted> result = _sut.DeleteDirectory(pathId);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -777,7 +776,7 @@ public class DirectoryServiceTests
ErrorOr<Deleted> result = _sut.DeleteDirectory(pathId);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.DirectoryNotFound);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.DirectoryNotFound, result.FirstError);
}
}
@@ -1,6 +1,5 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FluentAssertions;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
@@ -48,10 +47,10 @@ public class DriveServiceTests
ErrorOr<IEnumerable<FileSystemItem>> result = _sut.GetDrives();
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(1);
result.Value.First().Should().BeOfType<UnixRootItem>();
result.Value.First().Status.Should().Be(FileSystemItemStatus.Accessible);
Assert.False(result.IsError);
Assert.Single(result.Value);
Assert.IsType<UnixRootItem>(result.Value.First());
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.First().Status);
}
[Fact]
@@ -71,10 +70,10 @@ public class DriveServiceTests
ErrorOr<IEnumerable<FileSystemItem>> result = _sut.GetDrives();
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(2); // Only ready drives
result.Value.Should().AllBeOfType<WindowsRootItem>();
result.Value.Select(d => d.Name).Should().BeEquivalentTo("C:\\", "D:\\");
Assert.False(result.IsError);
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));
}
private static IDriveInfo CreateMockDriveInfo(string name, bool isReady)
@@ -2,7 +2,6 @@
using AutoFixture;
using AutoFixture.AutoNSubstitute;
using ErrorOr;
using FluentAssertions;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Common.Primitives;
@@ -18,7 +17,6 @@ using System.IO;
using System.IO.Abstractions;
using System.Linq;
using System.Runtime.InteropServices;
#endregion
namespace Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.Services;
@@ -67,8 +65,8 @@ public class FileProviderServiceTests
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetFilePaths(path, false);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -84,9 +82,12 @@ public class FileProviderServiceTests
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetFilePaths(path, false);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(3);
result.Value.Select(x => x.Path).Should().BeEquivalentTo(files);
Assert.False(result.IsError);
Assert.Equal(3, result.Value.Count());
Assert.Equal(
files.OrderBy(f => f),
result.Value.Select(x => x.Path).OrderBy(f => f)
);
}
[Fact]
@@ -104,9 +105,9 @@ public class FileProviderServiceTests
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetFilePaths(path, false);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(1);
result.Value.First().Path.Should().Be(_pathVisible1);
Assert.False(result.IsError);
Assert.Single(result.Value);
Assert.Equal(_pathVisible1, result.Value.First().Path);
}
[Fact]
@@ -124,9 +125,12 @@ public class FileProviderServiceTests
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetFilePaths(path, true);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(2);
result.Value.Select(x => x.Path).Should().BeEquivalentTo([_pathVisible1, _pathHidden1]);
Assert.False(result.IsError);
Assert.Equal(2, result.Value.Count());
Assert.Equal(
new[] { _pathVisible1, _pathHidden1 }.OrderBy(p => p),
result.Value.Select(x => x.Path).OrderBy(p => p)
);
}
[Fact]
@@ -144,9 +148,9 @@ public class FileProviderServiceTests
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetFilePaths(path, false);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(2);
result.Value.Select(x => x.Path).Should().BeEquivalentTo([_pathInvalid1, _pathValid1]);
Assert.False(result.IsError);
Assert.Equal(2, result.Value.Count());
Assert.Equal([_pathInvalid1, _pathValid1], result.Value.Select(x => x.Path));
}
[Fact]
@@ -168,8 +172,8 @@ public class FileProviderServiceTests
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetFilePaths(path, false);
// Assert
result.IsError.Should().BeFalse();
result.Value.Select(x => x.Path).Should().BeEquivalentTo(expectedFiles, options => options.WithStrictOrdering());
Assert.False(result.IsError);
Assert.Equal(expectedFiles, result.Value.Select(x => x.Path));
}
[Fact]
@@ -184,8 +188,8 @@ public class FileProviderServiceTests
ErrorOr<IEnumerable<FileSystemPathId>> result = _sut.GetFilePaths(path, false);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().BeEmpty();
Assert.False(result.IsError);
Assert.Empty(result.Value);
}
[Fact]
@@ -199,8 +203,8 @@ public class FileProviderServiceTests
ErrorOr<bool> result = _sut.FileExists(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().BeTrue();
Assert.False(result.IsError);
Assert.True(result.Value);
}
[Fact]
@@ -214,8 +218,8 @@ public class FileProviderServiceTests
ErrorOr<bool> result = _sut.FileExists(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().BeFalse();
Assert.False(result.IsError);
Assert.False(result.Value);
}
[Fact]
@@ -230,8 +234,8 @@ public class FileProviderServiceTests
ErrorOr<string> result = _sut.GetFileName(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().Be(expectedFileName);
Assert.False(result.IsError);
Assert.Equal(expectedFileName, result.Value);
}
[Fact]
@@ -245,8 +249,8 @@ public class FileProviderServiceTests
ErrorOr<string> result = _sut.GetFileName(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().BeEmpty();
Assert.False(result.IsError);
Assert.Empty(result.Value);
}
[Fact]
@@ -269,12 +273,12 @@ public class FileProviderServiceTests
ErrorOr<byte[]> result = _sut.GetFileAsync(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().BeEquivalentTo(expectedContents);
Assert.False(result.IsError);
Assert.Equal(expectedContents, result.Value);
}
finally
{
// Clean up
// clean up
File.Delete(tempFilePath);
}
}
@@ -290,8 +294,8 @@ public class FileProviderServiceTests
ErrorOr<byte[]> result = _sut.GetFileAsync(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -308,12 +312,12 @@ public class FileProviderServiceTests
ErrorOr<byte[]> result = _sut.GetFileAsync(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().BeEmpty();
Assert.False(result.IsError);
Assert.Empty(result.Value);
}
finally
{
// Clean up
// clean up
File.Delete(tempFilePath);
}
}
@@ -336,9 +340,9 @@ public class FileProviderServiceTests
ErrorOr<Optional<DateTime>> result = _sut.GetLastWriteTime(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.HasValue.Should().BeTrue();
result.Value.Value.Should().BeCloseTo(expectedDateTime, TimeSpan.FromSeconds(1));
Assert.False(result.IsError);
Assert.True(result.Value.HasValue);
Assert.Equal(expectedDateTime, result.Value.Value, TimeSpan.FromSeconds(1));
}
finally
{
@@ -357,8 +361,8 @@ public class FileProviderServiceTests
ErrorOr<Optional<DateTime>> result = _sut.GetLastWriteTime(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -379,9 +383,9 @@ public class FileProviderServiceTests
ErrorOr<Optional<DateTime>> result = _sut.GetCreationTime(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.HasValue.Should().BeTrue();
result.Value.Value.Should().BeCloseTo(expectedDateTime, TimeSpan.FromSeconds(1));
Assert.False(result.IsError);
Assert.True(result.Value.HasValue);
Assert.Equal(expectedDateTime, result.Value.Value, TimeSpan.FromSeconds(1));
}
finally
{
@@ -400,8 +404,8 @@ public class FileProviderServiceTests
ErrorOr<Optional<DateTime>> result = _sut.GetCreationTime(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -423,9 +427,9 @@ public class FileProviderServiceTests
ErrorOr<long?> result = _sut.GetSize(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().NotBeNull();
result.Value.Should().Be(expectedSize);
Assert.False(result.IsError);
Assert.NotNull(result.Value);
Assert.Equal(expectedSize, result.Value);
}
finally
{
@@ -444,8 +448,8 @@ public class FileProviderServiceTests
ErrorOr<long?> result = _sut.GetSize(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -462,8 +466,8 @@ public class FileProviderServiceTests
ErrorOr<long?> result = _sut.GetSize(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().Be(0);
Assert.False(result.IsError);
Assert.Equal(0, result.Value);
}
[Fact]
@@ -484,8 +488,8 @@ public class FileProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeFalse();
result.Value.Path.Should().Be(_pathDestinationFile);
Assert.False(result.IsError);
Assert.Equal(_pathDestinationFile, result.Value.Path);
_mockFileSystem.File.Received(1).Copy(sourcePath.Path, _pathDestinationFile, overrideExisting);
}
@@ -503,8 +507,8 @@ public class FileProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.FileNotFound);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.FileNotFound, result.FirstError);
}
[Fact]
@@ -529,8 +533,8 @@ public class FileProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.FileAlreadyExists);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.FileAlreadyExists, result.FirstError);
_mockFileSystem.File.DidNotReceive().Copy(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<bool>());
}
@@ -552,8 +556,8 @@ public class FileProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeFalse();
result.Value.Path.Should().Be(_pathDestinationFile);
Assert.False(result.IsError);
Assert.Equal(_pathDestinationFile, result.Value.Path);
_mockFileSystem.File.Received(1).Copy(sourcePath.Path, _pathDestinationFile, overrideExisting);
}
@@ -573,8 +577,8 @@ public class FileProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.FileCopyError);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.FileCopyError, result.FirstError);
}
[Fact]
@@ -615,8 +619,8 @@ public class FileProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeFalse();
result.Value.Path.Should().Be(expectedNewFilePath);
Assert.False(result.IsError);
Assert.Equal(expectedNewFilePath, result.Value.Path);
_mockFileSystem.File.Received(1).Copy(sourcePath.Path, expectedNewFilePath, overrideExisting);
}
@@ -636,8 +640,8 @@ public class FileProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.FileNotFound);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.FileNotFound, result.FirstError);
}
[Fact]
@@ -658,8 +662,8 @@ public class FileProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeFalse();
result.Value.Path.Should().Be(destinationFilePath);
Assert.False(result.IsError);
Assert.Equal(destinationFilePath, result.Value.Path);
_mockFileSystem.File.Received(1).Move(sourcePath.Path, destinationFilePath);
}
@@ -681,8 +685,8 @@ public class FileProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeFalse();
result.Value.Path.Should().Be(destinationFilePath);
Assert.False(result.IsError);
Assert.Equal(destinationFilePath, result.Value.Path);
_mockFileSystem.File.Received(1).Move(sourcePath.Path, destinationFilePath, overrideExisting);
}
@@ -704,8 +708,8 @@ public class FileProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.FileAlreadyExists);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.FileAlreadyExists, result.FirstError);
}
[Fact]
@@ -728,8 +732,8 @@ public class FileProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.FileMoveError);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.FileMoveError, result.FirstError);
}
[Fact]
@@ -754,8 +758,8 @@ public class FileProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.RenameFile(path, newName);
// Assert
result.IsError.Should().BeFalse();
result.Value.Path.Should().Be(newPath);
Assert.False(result.IsError);
Assert.Equal(newPath, result.Value.Path);
_mockFileSystem.File.Received(1).Move(path.Path, newPath);
}
@@ -780,8 +784,8 @@ public class FileProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.RenameFile(path, newName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
_mockFileSystem.File.DidNotReceive().Move(Arg.Any<string>(), Arg.Any<string>());
}
@@ -807,8 +811,8 @@ public class FileProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.RenameFile(path, newName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
_mockFileSystem.File.DidNotReceive().Move(Arg.Any<string>(), Arg.Any<string>());
}
@@ -827,8 +831,8 @@ public class FileProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.RenameFile(path, newName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.CannotNavigateUp);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.CannotNavigateUp, result.FirstError);
_mockFileSystem.File.DidNotReceive().Move(Arg.Any<string>(), Arg.Any<string>());
}
@@ -851,8 +855,8 @@ public class FileProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.RenameFile(path, newName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
_mockFileSystem.File.DidNotReceive().Move(Arg.Any<string>(), Arg.Any<string>());
}
@@ -884,8 +888,8 @@ public class FileProviderServiceTests
ErrorOr<FileSystemPathId> result = _sut.RenameFile(path, newName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
_mockFileSystem.File.DidNotReceive().Move(Arg.Any<string>(), Arg.Any<string>());
}
@@ -903,8 +907,8 @@ public class FileProviderServiceTests
ErrorOr<Deleted> result = _sut.DeleteFile(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().Be(Result.Deleted);
Assert.False(result.IsError);
Assert.Equal(Result.Deleted, result.Value);
_mockFileSystem.File.Received(1).Delete(path.Path);
}
@@ -921,8 +925,8 @@ public class FileProviderServiceTests
ErrorOr<Deleted> result = _sut.DeleteFile(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
_mockFileSystem.File.DidNotReceive().Delete(Arg.Any<string>());
}
}
@@ -1,6 +1,5 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FluentAssertions;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Common.Primitives;
@@ -95,9 +94,9 @@ public class FileServiceTests
ErrorOr<IEnumerable<File>> result = _sut.GetFiles(path, includeHiddenElements);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(2);
result.Value.Select(f => f.Name).Should().BeEquivalentTo(["File1.txt", "File2.txt"]);
Assert.False(result.IsError);
Assert.Equal(2, result.Value.Count());
Assert.Equal(["File1.txt", "File2.txt"], result.Value.Select(f => f.Name));
}
[Fact]
@@ -111,8 +110,8 @@ public class FileServiceTests
ErrorOr<IEnumerable<File>> result = _sut.GetFiles(invalidPath, includeHiddenElements);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -130,8 +129,8 @@ public class FileServiceTests
ErrorOr<IEnumerable<File>> result = _sut.GetFiles(path, includeHiddenElements);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -159,9 +158,9 @@ public class FileServiceTests
ErrorOr<IEnumerable<File>> result = _sut.GetFiles(path, includeHiddenElements);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(1);
result.Value.First().Status.Should().Be(FileSystemItemStatus.Inaccessible);
Assert.False(result.IsError);
Assert.Single(result.Value);
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.First().Status);
}
[Fact]
@@ -195,9 +194,9 @@ public class FileServiceTests
ErrorOr<IEnumerable<File>> result = _sut.GetFiles(parentFile, includeHiddenElements);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(2);
result.Value.Select(f => f.Name).Should().BeEquivalentTo(["File1.txt", "File2.txt"]);
Assert.False(result.IsError);
Assert.Equal(2, result.Value.Count());
Assert.Equal(["File1.txt", "File2.txt"], result.Value.Select(f => f.Name));
}
[Fact]
@@ -214,8 +213,8 @@ public class FileServiceTests
ErrorOr<IEnumerable<File>> result = _sut.GetFiles(parentFile, includeHiddenElements);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -242,9 +241,9 @@ public class FileServiceTests
ErrorOr<IEnumerable<File>> result = _sut.GetFiles(parentFile, includeHiddenElements);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(1);
result.Value.First().Status.Should().Be(FileSystemItemStatus.Inaccessible);
Assert.False(result.IsError);
Assert.Single(result.Value);
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.First().Status);
}
[Fact]
@@ -278,9 +277,9 @@ public class FileServiceTests
ErrorOr<IEnumerable<File>> result = _sut.GetFiles(pathId, includeHiddenElements);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(2);
result.Value.Select(f => f.Name).Should().BeEquivalentTo(["File1.txt", "File2.txt"]);
Assert.False(result.IsError);
Assert.Equal(2, result.Value.Count());
Assert.Equal(["File1.txt", "File2.txt"], result.Value.Select(f => f.Name));
}
[Fact]
@@ -297,8 +296,8 @@ public class FileServiceTests
ErrorOr<IEnumerable<File>> result = _sut.GetFiles(pathId, includeHiddenElements);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -325,9 +324,9 @@ public class FileServiceTests
ErrorOr<IEnumerable<File>> result = _sut.GetFiles(pathId, includeHiddenElements);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(1);
result.Value.First().Status.Should().Be(FileSystemItemStatus.Inaccessible);
Assert.False(result.IsError);
Assert.Single(result.Value);
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.First().Status);
}
[Fact]
@@ -358,10 +357,10 @@ public class FileServiceTests
ErrorOr<File> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().NotBeNull();
result.Value.Name.Should().Be("file.txt");
result.Value.Status.Should().Be(FileSystemItemStatus.Accessible);
Assert.False(result.IsError);
Assert.NotNull(result.Value);
Assert.Equal("file.txt", result.Value.Name);
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
}
[Fact]
@@ -379,8 +378,8 @@ public class FileServiceTests
ErrorOr<File> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.FileNotFound);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.FileNotFound, result.FirstError);
}
[Fact]
@@ -402,8 +401,8 @@ public class FileServiceTests
ErrorOr<File> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -431,9 +430,9 @@ public class FileServiceTests
ErrorOr<File> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().NotBeNull();
result.Value.Status.Should().Be(FileSystemItemStatus.Inaccessible);
Assert.False(result.IsError);
Assert.NotNull(result.Value);
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.Status);
}
[Fact]
@@ -448,8 +447,8 @@ public class FileServiceTests
ErrorOr<File> result = _sut.CopyFile(invalidSourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -465,8 +464,8 @@ public class FileServiceTests
ErrorOr<File> result = _sut.CopyFile(sourcePath, invalidDestinationPath, overrideExisting);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -492,10 +491,10 @@ public class FileServiceTests
ErrorOr<File> result = _sut.CopyFile(sourcePathId, destinationPathId, overrideExisting);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().NotBeNull();
result.Value.Name.Should().Be("file.txt");
result.Value.Status.Should().Be(FileSystemItemStatus.Accessible);
Assert.False(result.IsError);
Assert.NotNull(result.Value);
Assert.Equal("file.txt", result.Value.Name);
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
}
[Fact]
@@ -512,8 +511,8 @@ public class FileServiceTests
ErrorOr<File> result = _sut.CopyFile(sourcePathId, destinationPathId, overrideExisting);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.FileNotFound);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.FileNotFound, result.FirstError);
}
[Fact]
@@ -532,8 +531,8 @@ public class FileServiceTests
ErrorOr<File> result = _sut.CopyFile(sourcePathId, destinationPathId, overrideExisting);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -558,9 +557,9 @@ public class FileServiceTests
ErrorOr<File> result = _sut.CopyFile(sourcePathId, destinationPathId, overrideExisting);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().NotBeNull();
result.Value.Status.Should().Be(FileSystemItemStatus.Inaccessible);
Assert.False(result.IsError);
Assert.NotNull(result.Value);
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.Status);
}
[Fact]
@@ -591,10 +590,10 @@ public class FileServiceTests
ErrorOr<File> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().NotBeNull();
result.Value.Name.Should().Be("file.txt");
result.Value.Status.Should().Be(FileSystemItemStatus.Accessible);
Assert.False(result.IsError);
Assert.NotNull(result.Value);
Assert.Equal("file.txt", result.Value.Name);
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
}
[Fact]
@@ -613,8 +612,8 @@ public class FileServiceTests
ErrorOr<File> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.FileNotFound);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.FileNotFound, result.FirstError);
}
[Fact]
@@ -636,8 +635,8 @@ public class FileServiceTests
ErrorOr<File> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -667,9 +666,9 @@ public class FileServiceTests
ErrorOr<File> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().NotBeNull();
result.Value.Status.Should().Be(FileSystemItemStatus.Inaccessible);
Assert.False(result.IsError);
Assert.NotNull(result.Value);
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.Status);
}
[Fact]
@@ -686,8 +685,8 @@ public class FileServiceTests
ErrorOr<File> result = _sut.MoveFile(invalidSourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -704,8 +703,8 @@ public class FileServiceTests
ErrorOr<File> result = _sut.MoveFile(sourcePath, invalidDestinationPath, overrideExisting);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -731,10 +730,10 @@ public class FileServiceTests
ErrorOr<File> result = _sut.MoveFile(sourcePathId, destinationPathId, overrideExisting);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().NotBeNull();
result.Value.Name.Should().Be("file.txt");
result.Value.Status.Should().Be(FileSystemItemStatus.Accessible);
Assert.False(result.IsError);
Assert.NotNull(result.Value);
Assert.Equal("file.txt", result.Value.Name);
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
}
[Fact]
@@ -753,8 +752,8 @@ public class FileServiceTests
ErrorOr<File> result = _sut.MoveFile(sourcePathId, destinationPathId, overrideExisting);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.FileNotFound);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.FileNotFound, result.FirstError);
}
[Fact]
@@ -773,8 +772,8 @@ public class FileServiceTests
ErrorOr<File> result = _sut.MoveFile(sourcePathId, destinationPathId, overrideExisting);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -799,9 +798,9 @@ public class FileServiceTests
ErrorOr<File> result = _sut.MoveFile(sourcePathId, destinationPathId, overrideExisting);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().NotBeNull();
result.Value.Status.Should().Be(FileSystemItemStatus.Inaccessible);
Assert.False(result.IsError);
Assert.NotNull(result.Value);
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.Status);
}
[Fact]
@@ -821,8 +820,8 @@ public class FileServiceTests
ErrorOr<File> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -851,10 +850,10 @@ public class FileServiceTests
ErrorOr<File> result = _sut.RenameFile(path, newName);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().NotBeNull();
result.Value.Name.Should().Be(newName);
result.Value.Status.Should().Be(FileSystemItemStatus.Accessible);
Assert.False(result.IsError);
Assert.NotNull(result.Value);
Assert.Equal(newName, result.Value.Name);
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
}
[Fact]
@@ -874,8 +873,8 @@ public class FileServiceTests
ErrorOr<File> result = _sut.RenameFile(path, newName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.FileAlreadyExists);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.FileAlreadyExists, result.FirstError);
}
[Fact]
@@ -898,8 +897,8 @@ public class FileServiceTests
ErrorOr<File> result = _sut.RenameFile(path, newName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -927,9 +926,9 @@ public class FileServiceTests
ErrorOr<File> result = _sut.RenameFile(path, newName);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().NotBeNull();
result.Value.Status.Should().Be(FileSystemItemStatus.Inaccessible);
Assert.False(result.IsError);
Assert.NotNull(result.Value);
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.Status);
}
[Fact]
@@ -945,8 +944,8 @@ public class FileServiceTests
ErrorOr<File> result = _sut.RenameFile(invalidPath, newName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -973,10 +972,10 @@ public class FileServiceTests
ErrorOr<File> result = _sut.RenameFile(pathId, newName);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().NotBeNull();
result.Value.Name.Should().Be(newName);
result.Value.Status.Should().Be(FileSystemItemStatus.Accessible);
Assert.False(result.IsError);
Assert.NotNull(result.Value);
Assert.Equal(newName, result.Value.Name);
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
}
[Fact]
@@ -995,8 +994,8 @@ public class FileServiceTests
ErrorOr<File> result = _sut.RenameFile(pathId, newName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.FileAlreadyExists);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.FileAlreadyExists, result.FirstError);
}
[Fact]
@@ -1017,8 +1016,8 @@ public class FileServiceTests
ErrorOr<File> result = _sut.RenameFile(pathId, newName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -1044,9 +1043,9 @@ public class FileServiceTests
ErrorOr<File> result = _sut.RenameFile(pathId, newName);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().NotBeNull();
result.Value.Status.Should().Be(FileSystemItemStatus.Inaccessible);
Assert.False(result.IsError);
Assert.NotNull(result.Value);
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.Status);
}
[Fact]
@@ -1064,8 +1063,8 @@ public class FileServiceTests
ErrorOr<File> result = _sut.RenameFile(path, newName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -1086,8 +1085,8 @@ public class FileServiceTests
ErrorOr<File> result = _sut.RenameFile(path, newName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -1104,8 +1103,8 @@ public class FileServiceTests
ErrorOr<File> result = _sut.RenameFile(pathId, newName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -1125,8 +1124,8 @@ public class FileServiceTests
ErrorOr<File> result = _sut.RenameFile(pathId, newName);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -1143,8 +1142,8 @@ public class FileServiceTests
ErrorOr<Deleted> result = _sut.DeleteFile(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().Be(Result.Deleted);
Assert.False(result.IsError);
Assert.Equal(Result.Deleted, result.Value);
}
[Fact]
@@ -1157,8 +1156,8 @@ public class FileServiceTests
ErrorOr<Deleted> result = _sut.DeleteFile(invalidPath);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -1175,8 +1174,8 @@ public class FileServiceTests
ErrorOr<Deleted> result = _sut.DeleteFile(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -1192,8 +1191,8 @@ public class FileServiceTests
ErrorOr<Deleted> result = _sut.DeleteFile(pathId);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().Be(Result.Deleted);
Assert.False(result.IsError);
Assert.Equal(Result.Deleted, result.Value);
}
[Fact]
@@ -1209,7 +1208,7 @@ public class FileServiceTests
ErrorOr<Deleted> result = _sut.DeleteFile(pathId);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
}
@@ -1,6 +1,5 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FluentAssertions;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Common.Enums.PhotoLibrary;
using Lumina.Domain.Common.Errors;
@@ -59,8 +58,8 @@ public class FileTypeServiceTests
ErrorOr<ImageType> result = await sut.GetImageTypeAsync(file, CancellationToken.None);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().Be(ImageType.PNG);
Assert.False(result.IsError);
Assert.Equal(ImageType.PNG, result.Value);
}
[Fact]
@@ -78,8 +77,8 @@ public class FileTypeServiceTests
ErrorOr<ImageType> result = await sut.GetImageTypeAsync(file, CancellationToken.None);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -97,8 +96,8 @@ public class FileTypeServiceTests
ErrorOr<ImageType> result = await sut.GetImageTypeAsync(pathId, CancellationToken.None);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().Be(ImageType.None);
Assert.False(result.IsError);
Assert.Equal(ImageType.None, result.Value);
}
[Fact]
@@ -117,8 +116,8 @@ public class FileTypeServiceTests
ErrorOr<ImageType> result = await sut.GetImageTypeAsync(pathId, CancellationToken.None);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().Be(ImageType.SVG);
Assert.False(result.IsError);
Assert.Equal(ImageType.SVG, result.Value);
}
[Fact]
@@ -139,8 +138,8 @@ public class FileTypeServiceTests
ErrorOr<ImageType> result = await sut.GetImageTypeAsync(pathId, CancellationToken.None);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().Be(ImageType.TGA);
Assert.False(result.IsError);
Assert.Equal(ImageType.TGA, result.Value);
}
[Fact]
@@ -158,8 +157,8 @@ public class FileTypeServiceTests
ErrorOr<ImageType> result = await sut.GetImageTypeAsync(pathId, CancellationToken.None);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().Be(ImageType.None);
Assert.False(result.IsError);
Assert.Equal(ImageType.None, result.Value);
}
private void SetupMockFileSystem(FileSystemPathId pathId, byte[] fileContent)
@@ -189,8 +188,8 @@ public class FileTypeServiceTests
ErrorOr<ImageType> result = await sut.GetImageTypeAsync(pathId, CancellationToken.None);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().Be(ImageType.SVG);
Assert.False(result.IsError);
Assert.Equal(ImageType.SVG, result.Value);
}
[Theory]
@@ -225,7 +224,7 @@ public class FileTypeServiceTests
ErrorOr<ImageType> result = await sut.GetImageTypeAsync(pathId, CancellationToken.None);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().Be(expectedType, because: $"the file header matches {testName}");
Assert.False(result.IsError);
Assert.Equal(expectedType, result.Value);
}
}
@@ -1,6 +1,5 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FluentAssertions;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Path;
@@ -55,7 +54,7 @@ public class PathServiceTests
bool result = _sut.IsValidPath(validPath);
// Assert
result.Should().BeTrue();
Assert.True(result);
_mockPathStrategy.Received(1).IsValidPath(Arg.Is<FileSystemPathId>(id => id.Path == validPath));
}
@@ -71,7 +70,7 @@ public class PathServiceTests
bool result = _sut.IsValidPath(invalidPath);
// Assert
result.Should().BeFalse();
Assert.False(result);
_mockPathStrategy.Received(1).IsValidPath(Arg.Is<FileSystemPathId>(id => id.Path == invalidPath));
}
@@ -85,7 +84,7 @@ public class PathServiceTests
bool result = _sut.IsValidPath(emptyPath);
// Assert
result.Should().BeFalse();
Assert.False(result);
_mockPathStrategy.DidNotReceive().IsValidPath(Arg.Any<FileSystemPathId>());
}
@@ -99,7 +98,7 @@ public class PathServiceTests
bool result = _sut.IsValidPath(nullPath!);
// Assert
result.Should().BeFalse();
Assert.False(result);
_mockPathStrategy.DidNotReceive().IsValidPath(Arg.Any<FileSystemPathId>());
}
@@ -115,7 +114,7 @@ public class PathServiceTests
bool result = _sut.Exists(existingPath);
// Assert
result.Should().BeTrue();
Assert.True(result);
_mockPathStrategy.Received(1).Exists(Arg.Is<FileSystemPathId>(id => id.Path == existingPath));
}
@@ -131,7 +130,7 @@ public class PathServiceTests
bool result = _sut.Exists(existingPath, true);
// Assert
result.Should().BeTrue();
Assert.True(result);
_mockPathStrategy.Received(1).Exists(Arg.Is<FileSystemPathId>(id => id.Path == existingPath));
}
@@ -147,7 +146,7 @@ public class PathServiceTests
bool result = _sut.Exists(existingPath, false);
// Assert
result.Should().BeFalse();
Assert.False(result);
_mockPathStrategy.Received(1).Exists(Arg.Is<FileSystemPathId>(id => id.Path == existingPath), false);
}
@@ -163,7 +162,7 @@ public class PathServiceTests
bool result = _sut.Exists(nonExistingPath);
// Assert
result.Should().BeFalse();
Assert.False(result);
_mockPathStrategy.Received(1).Exists(Arg.Is<FileSystemPathId>(id => id.Path == nonExistingPath));
}
@@ -177,7 +176,7 @@ public class PathServiceTests
bool result = _sut.Exists(emptyPath);
// Assert
result.Should().BeFalse();
Assert.False(result);
_mockPathStrategy.DidNotReceive().Exists(Arg.Any<FileSystemPathId>());
}
@@ -191,7 +190,7 @@ public class PathServiceTests
bool result = _sut.Exists(nullPath!);
// Assert
result.Should().BeFalse();
Assert.False(result);
_mockPathStrategy.DidNotReceive().Exists(Arg.Any<FileSystemPathId>());
}
@@ -209,8 +208,8 @@ public class PathServiceTests
ErrorOr<string> result = _sut.CombinePath(path, name);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().Be(@"C:\BaseDir\SubDir");
Assert.False(result.IsError);
Assert.Equal(@"C:\BaseDir\SubDir", result.Value);
_mockPathStrategy.Received(1).CombinePath(Arg.Is<FileSystemPathId>(id => id.Path == path), name);
}
@@ -225,8 +224,8 @@ public class PathServiceTests
ErrorOr<string> result = _sut.CombinePath(invalidPath, name);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
_mockPathStrategy.DidNotReceive().CombinePath(Arg.Any<FileSystemPathId>(), Arg.Any<string>());
}
@@ -243,8 +242,8 @@ public class PathServiceTests
ErrorOr<string> result = _sut.CombinePath(path, name);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
_mockPathStrategy.Received(1).CombinePath(Arg.Is<FileSystemPathId>(id => id.Path == path), name);
}
@@ -259,8 +258,8 @@ public class PathServiceTests
ErrorOr<string> result = _sut.CombinePath(path, name!);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
_mockPathStrategy.DidNotReceive().CombinePath(Arg.Any<FileSystemPathId>(), Arg.Any<string>());
}
@@ -277,8 +276,8 @@ public class PathServiceTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(validPath);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().BeEquivalentTo(expectedSegments);
Assert.False(result.IsError);
Assert.Equal(expectedSegments, result.Value);
_mockPathStrategy.Received(1).ParsePath(Arg.Is<FileSystemPathId>(id => id.Path == validPath));
}
@@ -292,8 +291,8 @@ public class PathServiceTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(invalidPath);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
_mockPathStrategy.DidNotReceive().ParsePath(Arg.Any<FileSystemPathId>());
}
@@ -309,8 +308,8 @@ public class PathServiceTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
_mockPathStrategy.Received(1).ParsePath(Arg.Is<FileSystemPathId>(id => id.Path == path));
}
@@ -324,8 +323,8 @@ public class PathServiceTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(nullPath!);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
_mockPathStrategy.DidNotReceive().ParsePath(Arg.Any<FileSystemPathId>());
}
@@ -342,8 +341,8 @@ public class PathServiceTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(validPath);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().BeEquivalentTo(expectedSegments);
Assert.False(result.IsError);
Assert.Equal(expectedSegments, result.Value);
_mockPathStrategy.Received(1).GoUpOneLevel(Arg.Is<FileSystemPathId>(id => id.Path == validPath));
}
@@ -360,8 +359,8 @@ public class PathServiceTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(rootPath);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().BeEmpty();
Assert.False(result.IsError);
Assert.Empty(result.Value);
_mockPathStrategy.Received(1).GoUpOneLevel(Arg.Is<FileSystemPathId>(id => id.Path == rootPath));
}
@@ -375,8 +374,8 @@ public class PathServiceTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(invalidPath);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
_mockPathStrategy.DidNotReceive().GoUpOneLevel(Arg.Any<FileSystemPathId>());
}
@@ -392,8 +391,8 @@ public class PathServiceTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
_mockPathStrategy.Received(1).GoUpOneLevel(Arg.Is<FileSystemPathId>(id => id.Path == path));
}
@@ -407,8 +406,8 @@ public class PathServiceTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(nullPath!);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
_mockPathStrategy.DidNotReceive().GoUpOneLevel(Arg.Any<FileSystemPathId>());
}
@@ -423,7 +422,7 @@ public class PathServiceTests
char[] result = _sut.GetInvalidPathCharsForPlatform();
// Assert
result.Should().BeEquivalentTo(expectedInvalidChars);
Assert.Equal(expectedInvalidChars, result);
_mockPathStrategy.Received(1).GetInvalidPathCharsForPlatform();
}
@@ -438,7 +437,7 @@ public class PathServiceTests
char[] result = _sut.GetInvalidPathCharsForPlatform();
// Assert
result.Should().BeEmpty();
Assert.Empty(result);
_mockPathStrategy.Received(1).GetInvalidPathCharsForPlatform();
}
@@ -455,7 +454,7 @@ public class PathServiceTests
// Assert
char[] secondResult = _sut.GetInvalidPathCharsForPlatform();
secondResult.Should().BeEquivalentTo(originalInvalidChars);
Assert.Equal(secondResult, originalInvalidChars);
_mockPathStrategy.Received(2).GetInvalidPathCharsForPlatform();
}
@@ -472,8 +471,8 @@ public class PathServiceTests
ErrorOr<PathSegment> result = _sut.GetPathRoot(validPath);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().BeEquivalentTo(expectedRootSegment);
Assert.False(result.IsError);
Assert.Equal(expectedRootSegment, result.Value);
_mockPathStrategy.Received(1).GetPathRoot(Arg.Is<FileSystemPathId>(id => id.Path == validPath));
}
@@ -487,8 +486,8 @@ public class PathServiceTests
ErrorOr<PathSegment> result = _sut.GetPathRoot(invalidPath);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
_mockPathStrategy.DidNotReceive().GetPathRoot(Arg.Any<FileSystemPathId>());
}
@@ -504,8 +503,8 @@ public class PathServiceTests
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
_mockPathStrategy.Received(1).GetPathRoot(Arg.Is<FileSystemPathId>(id => id.Path == path));
}
@@ -519,8 +518,8 @@ public class PathServiceTests
ErrorOr<PathSegment> result = _sut.GetPathRoot(nullPath!);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
_mockPathStrategy.DidNotReceive().GetPathRoot(Arg.Any<FileSystemPathId>());
}
}
@@ -1,6 +1,5 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FluentAssertions;
using Lumina.Domain.Common.Enums.PhotoLibrary;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
@@ -66,9 +65,9 @@ public class ThumbnailServiceTests
ErrorOr<Thumbnail> result = await _sut.GetThumbnailAsync(path, quality, CancellationToken.None);
// Assert
result.IsError.Should().BeFalse();
result.Value.Type.Should().Be(ImageType.JPEG);
result.Value.Bytes.Should().NotBeEmpty();
Assert.False(result.IsError);
Assert.Equal(ImageType.JPEG, result.Value.Type);
Assert.NotEmpty(result.Value.Bytes);
}
[Fact]
@@ -82,8 +81,8 @@ public class ThumbnailServiceTests
ErrorOr<Thumbnail> result = await _sut.GetThumbnailAsync(invalidPath, quality, CancellationToken.None);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -100,8 +99,8 @@ public class ThumbnailServiceTests
ErrorOr<Thumbnail> result = await _sut.GetThumbnailAsync(pathId, quality, CancellationToken.None);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Fact]
@@ -118,8 +117,8 @@ public class ThumbnailServiceTests
ErrorOr<Thumbnail> result = await _sut.GetThumbnailAsync(pathId, quality, CancellationToken.None);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Thumbnails.NoThumbnail);
Assert.True(result.IsError);
Assert.Equal(Errors.Thumbnails.NoThumbnail, result.FirstError);
}
[Fact]
@@ -138,8 +137,8 @@ public class ThumbnailServiceTests
ErrorOr<Thumbnail> result = await _sut.GetThumbnailAsync(pathId, quality, CancellationToken.None);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
Assert.True(result.IsError);
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
}
[Theory]
@@ -159,14 +158,14 @@ public class ThumbnailServiceTests
ErrorOr<Thumbnail> result = await _sut.GetThumbnailAsync(pathId, quality, CancellationToken.None);
// Assert
result.IsError.Should().BeFalse();
result.Value.Type.Should().Be(imageType);
result.Value.Bytes.Should().NotBeEmpty();
Assert.False(result.IsError);
Assert.Equal(imageType, result.Value.Type);
Assert.NotEmpty(result.Value.Bytes);
using (MemoryStream ms = new(result.Value.Bytes))
{
Image loadedImage = Image.Load(ms);
loadedImage.Should().NotBeNull();
Assert.NotNull(loadedImage);
}
}
@@ -1,5 +1,4 @@
#region ========================================================================= USING =====================================================================================
using FluentAssertions;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
using NSubstitute;
@@ -38,9 +37,9 @@ public class EnvironmentContextTests
_mockFileTypeService);
// Assert
environmentContext.DirectoryProviderService.Should().Be(_mockDirectoryProviderService);
environmentContext.FileProviderService.Should().Be(_mockFileProviderService);
environmentContext.FileTypeService.Should().Be(_mockFileTypeService);
Assert.Same(_mockDirectoryProviderService, environmentContext.DirectoryProviderService);
Assert.Same(_mockFileProviderService, environmentContext.FileProviderService);
Assert.Same(_mockFileTypeService, environmentContext.FileTypeService);
}
[Fact]
@@ -56,7 +55,7 @@ public class EnvironmentContextTests
IFileTypeService result = environmentContext.FileTypeService;
// Assert
result.Should().Be(_mockFileTypeService);
Assert.Same(_mockFileTypeService, result);
}
[Fact]
@@ -72,7 +71,7 @@ public class EnvironmentContextTests
IFileProviderService result = environmentContext.FileProviderService;
// Assert
result.Should().Be(_mockFileProviderService);
Assert.Same(_mockFileProviderService, result);
}
[Fact]
@@ -88,6 +87,6 @@ public class EnvironmentContextTests
IDirectoryProviderService result = environmentContext.DirectoryProviderService;
// Assert
result.Should().Be(_mockDirectoryProviderService);
Assert.Same(_mockDirectoryProviderService, result);
}
}
@@ -1,6 +1,5 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FluentAssertions;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Path;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
@@ -51,7 +50,7 @@ public class UnixPathStrategyTests
bool result = _sut.IsValidPath(pathId);
// Assert
result.Should().BeTrue();
Assert.True(result);
}
[Theory]
@@ -68,7 +67,7 @@ public class UnixPathStrategyTests
bool result = _sut.IsValidPath(pathId);
// Assert
result.Should().BeFalse();
Assert.False(result);
}
[Fact]
@@ -82,7 +81,7 @@ public class UnixPathStrategyTests
bool result = _sut.IsValidPath(pathId);
// Assert
result.Should().BeFalse();
Assert.False(result);
}
[Theory]
@@ -105,7 +104,7 @@ public class UnixPathStrategyTests
bool result = _sut.IsValidPath(pathId);
// Assert
result.Should().BeTrue();
Assert.True(result);
}
[Fact]
@@ -119,7 +118,7 @@ public class UnixPathStrategyTests
bool result = _sut.IsValidPath(pathId);
// Assert
result.Should().BeTrue();
Assert.True(result);
}
[Fact]
@@ -136,7 +135,7 @@ public class UnixPathStrategyTests
bool result = _sut.Exists(pathId, true);
// Assert
result.Should().BeTrue();
Assert.True(result);
_mockFileSystem.Path.Received(1).Exists(existingPath);
}
@@ -156,7 +155,7 @@ public class UnixPathStrategyTests
bool result = _sut.Exists(pathId, false);
// Assert
result.Should().BeFalse();
Assert.False(result);
_mockFileSystem.Path.Received(1).Exists(existingPath);
}
@@ -172,7 +171,7 @@ public class UnixPathStrategyTests
bool result = _sut.Exists(pathId);
// Assert
result.Should().BeFalse();
Assert.False(result);
_mockFileSystem.Path.Received(1).Exists(nonExistingPath);
}
@@ -188,7 +187,7 @@ public class UnixPathStrategyTests
bool result = _sut.Exists(pathId, true);
// Assert
result.Should().BeTrue();
Assert.True(result);
_mockFileSystem.Path.Received(1).Exists(rootPath);
}
@@ -205,7 +204,7 @@ public class UnixPathStrategyTests
bool result = _sut.Exists(pathId, true);
// Assert
result.Should().BeTrue();
Assert.True(result);
_mockFileSystem.Path.Received(1).Exists(directoryPath);
}
@@ -222,7 +221,7 @@ public class UnixPathStrategyTests
bool result = _sut.Exists(pathId, true);
// Assert
result.Should().BeTrue();
Assert.True(result);
_mockFileSystem.Path.Received(1).Exists(filePath);
}
@@ -237,8 +236,8 @@ public class UnixPathStrategyTests
ErrorOr<FileSystemPathId> result = _sut.CombinePath(path, name);
// Assert
result.IsError.Should().BeFalse();
result.Value.Path.Should().Be("/home/user/documents/");
Assert.False(result.IsError);
Assert.Equal("/home/user/documents/", result.Value.Path);
}
[Fact]
@@ -252,8 +251,8 @@ public class UnixPathStrategyTests
ErrorOr<FileSystemPathId> result = _sut.CombinePath(path, name);
// Assert
result.IsError.Should().BeFalse();
result.Value.Path.Should().Be("/home/user/documents/");
Assert.False(result.IsError);
Assert.Equal("/home/user/documents/", result.Value.Path);
}
[Fact]
@@ -267,8 +266,8 @@ public class UnixPathStrategyTests
ErrorOr<FileSystemPathId> result = _sut.CombinePath(path, name);
// Assert
result.IsError.Should().BeFalse();
result.Value.Path.Should().Be("/home/user/documents/");
Assert.False(result.IsError);
Assert.Equal("/home/user/documents/", result.Value.Path);
}
[Fact]
@@ -282,8 +281,8 @@ public class UnixPathStrategyTests
ErrorOr<FileSystemPathId> result = _sut.CombinePath(path, name);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.NameCannotBeEmpty);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.NameCannotBeEmpty, result.FirstError);
}
[Fact]
@@ -297,8 +296,8 @@ public class UnixPathStrategyTests
ErrorOr<FileSystemPathId> result = _sut.CombinePath(path, name);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.NameCannotBeEmpty);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.NameCannotBeEmpty, result.FirstError);
}
[Fact]
@@ -312,8 +311,8 @@ public class UnixPathStrategyTests
ErrorOr<FileSystemPathId> result = _sut.CombinePath(path, name);
// Assert
result.IsError.Should().BeFalse();
result.Value.Path.Should().Be("/home/");
Assert.False(result.IsError);
Assert.Equal("/home/", result.Value.Path);
}
[Fact]
@@ -326,13 +325,13 @@ public class UnixPathStrategyTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(5);
result.Value.ElementAt(0).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("/", false, true));
result.Value.ElementAt(1).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("home", true, false));
result.Value.ElementAt(2).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("user", true, false));
result.Value.ElementAt(3).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("documents", true, false));
result.Value.ElementAt(4).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("file.txt", false, false));
Assert.False(result.IsError);
Assert.Equal(5, result.Value.Count());
Assert.Equal(_pathSegmentFixture.CreatePathSegment("/", false, true), result.Value.ElementAt(0));
Assert.Equal(_pathSegmentFixture.CreatePathSegment("home", true, false), result.Value.ElementAt(1));
Assert.Equal(_pathSegmentFixture.CreatePathSegment("user", true, false), result.Value.ElementAt(2));
Assert.Equal(_pathSegmentFixture.CreatePathSegment("documents", true, false), result.Value.ElementAt(3));
Assert.Equal(_pathSegmentFixture.CreatePathSegment("file.txt", false, false), result.Value.ElementAt(4));
}
[Fact]
@@ -345,9 +344,9 @@ public class UnixPathStrategyTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(1);
result.Value.Single().Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("/", false, true));
Assert.False(result.IsError);
Assert.Single(result.Value);
Assert.Equal(_pathSegmentFixture.CreatePathSegment("/", false, true), result.Value.Single());
}
[Fact]
@@ -360,9 +359,9 @@ public class UnixPathStrategyTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(4);
result.Value.Last().Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("documents", true, false));
Assert.False(result.IsError);
Assert.Equal(4, result.Value.Count());
Assert.Equal(_pathSegmentFixture.CreatePathSegment("documents", true, false), result.Value.Last());
}
[Fact]
@@ -375,8 +374,8 @@ public class UnixPathStrategyTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -389,9 +388,9 @@ public class UnixPathStrategyTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(4);
result.Value.Last().Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("file.with.dots.txt", false, false));
Assert.False(result.IsError);
Assert.Equal(4, result.Value.Count());
Assert.Equal(_pathSegmentFixture.CreatePathSegment("file.with.dots.txt", false, false), result.Value.Last());
}
[Fact]
@@ -404,11 +403,11 @@ public class UnixPathStrategyTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(3);
result.Value.ElementAt(0).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("/", false, true));
result.Value.ElementAt(1).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("home", true, false));
result.Value.ElementAt(2).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("user", true, false));
Assert.False(result.IsError);
Assert.Equal(3, result.Value.Count());
Assert.Equal(_pathSegmentFixture.CreatePathSegment("/", false, true), result.Value.ElementAt(0));
Assert.Equal(_pathSegmentFixture.CreatePathSegment("home", true, false), result.Value.ElementAt(1));
Assert.Equal(_pathSegmentFixture.CreatePathSegment("user", true, false), result.Value.ElementAt(2));
}
[Fact]
@@ -421,8 +420,8 @@ public class UnixPathStrategyTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.CannotNavigateUp);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.CannotNavigateUp, result.FirstError);
}
[Fact]
@@ -435,10 +434,10 @@ public class UnixPathStrategyTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(2);
result.Value.ElementAt(0).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("/", false, true));
result.Value.ElementAt(1).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("home", true, false));
Assert.False(result.IsError);
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));
}
[Fact]
@@ -451,8 +450,8 @@ public class UnixPathStrategyTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -465,9 +464,9 @@ public class UnixPathStrategyTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(1);
result.Value.Single().Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("/", false, true));
Assert.False(result.IsError);
Assert.Single(result.Value);
Assert.Equal(_pathSegmentFixture.CreatePathSegment("/", false, true), result.Value.Single());
}
[Fact]
@@ -477,8 +476,8 @@ public class UnixPathStrategyTests
char[] result = _sut.GetInvalidPathCharsForPlatform();
// Assert
result.Should().HaveCount(1);
result.Should().Contain('\0');
Assert.Single(result);
Assert.Contains('\0', result);
}
[Fact]
@@ -488,15 +487,15 @@ public class UnixPathStrategyTests
char[] result = _sut.GetInvalidPathCharsForPlatform();
// Assert
result.Should().NotContain('/');
result.Should().NotContain('\\');
result.Should().NotContain(':');
result.Should().NotContain('*');
result.Should().NotContain('?');
result.Should().NotContain('"');
result.Should().NotContain('<');
result.Should().NotContain('>');
result.Should().NotContain('|');
Assert.DoesNotContain('/', result);
Assert.DoesNotContain('\\', result);
Assert.DoesNotContain(':', result);
Assert.DoesNotContain('*', result);
Assert.DoesNotContain('?', result);
Assert.DoesNotContain('"', result);
Assert.DoesNotContain('<', result);
Assert.DoesNotContain('>', result);
Assert.DoesNotContain('|', result);
}
[Fact]
@@ -507,7 +506,7 @@ public class UnixPathStrategyTests
char[] result2 = _sut.GetInvalidPathCharsForPlatform();
// Assert
result1.Should().BeEquivalentTo(result2);
Assert.Equal(result1, result2);
}
[Fact]
@@ -520,8 +519,8 @@ public class UnixPathStrategyTests
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("/", false, true));
Assert.False(result.IsError);
Assert.Equal(_pathSegmentFixture.CreatePathSegment("/", false, true), result.Value);
}
[Fact]
@@ -534,8 +533,8 @@ public class UnixPathStrategyTests
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("/", false, true));
Assert.False(result.IsError);
Assert.Equal(_pathSegmentFixture.CreatePathSegment("/", false, true), result.Value);
}
[Fact]
@@ -548,7 +547,7 @@ public class UnixPathStrategyTests
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
}
@@ -1,6 +1,5 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FluentAssertions;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Path;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
@@ -51,7 +50,7 @@ public class WindowsPathStrategyTests
bool result = _sut.IsValidPath(pathId);
// Assert
result.Should().BeTrue();
Assert.True(result);
}
[Theory]
@@ -69,7 +68,7 @@ public class WindowsPathStrategyTests
bool result = _sut.IsValidPath(pathId);
// Assert
result.Should().BeFalse();
Assert.False(result);
}
[Fact]
@@ -83,7 +82,7 @@ public class WindowsPathStrategyTests
bool result = _sut.IsValidPath(pathId);
// Assert
result.Should().BeFalse();
Assert.False(result);
}
[Theory]
@@ -101,7 +100,7 @@ public class WindowsPathStrategyTests
bool result = _sut.IsValidPath(pathId);
// Assert
result.Should().BeTrue();
Assert.True(result);
}
[Fact]
@@ -115,7 +114,7 @@ public class WindowsPathStrategyTests
bool result = _sut.IsValidPath(pathId);
// Assert
result.Should().BeTrue();
Assert.True(result);
}
[Theory]
@@ -131,7 +130,7 @@ public class WindowsPathStrategyTests
bool result = _sut.IsValidPath(pathId);
// Assert
result.Should().BeTrue();
Assert.True(result);
}
[Theory]
@@ -147,7 +146,7 @@ public class WindowsPathStrategyTests
bool result = _sut.IsValidPath(pathId);
// Assert
result.Should().BeFalse();
Assert.False(result);
}
[Fact]
@@ -163,7 +162,7 @@ public class WindowsPathStrategyTests
bool result = _sut.Exists(pathId, true);
// Assert
result.Should().BeTrue();
Assert.True(result);
_mockFileSystem.Path.Received(1).Exists(existingPath);
}
@@ -183,7 +182,7 @@ public class WindowsPathStrategyTests
bool result = _sut.Exists(pathId, false);
// Assert
result.Should().BeFalse();
Assert.False(result);
_mockFileSystem.Path.Received(1).Exists(existingPath);
}
@@ -199,7 +198,7 @@ public class WindowsPathStrategyTests
bool result = _sut.Exists(pathId);
// Assert
result.Should().BeFalse();
Assert.False(result);
_mockFileSystem.Path.Received(1).Exists(nonExistingPath);
}
@@ -215,7 +214,7 @@ public class WindowsPathStrategyTests
bool result = _sut.Exists(pathId);
// Assert
result.Should().BeTrue();
Assert.True(result);
_mockFileSystem.Path.Received(1).Exists(rootPath);
}
@@ -232,7 +231,7 @@ public class WindowsPathStrategyTests
bool result = _sut.Exists(pathId, true);
// Assert
result.Should().BeTrue();
Assert.True(result);
_mockFileSystem.Path.Received(1).Exists(directoryPath);
}
@@ -249,7 +248,7 @@ public class WindowsPathStrategyTests
bool result = _sut.Exists(pathId, true);
// Assert
result.Should().BeTrue();
Assert.True(result);
_mockFileSystem.Path.Received(1).Exists(filePath);
}
@@ -265,7 +264,7 @@ public class WindowsPathStrategyTests
bool result = _sut.Exists(pathId, true);
// Assert
result.Should().BeTrue();
Assert.True(result);
_mockFileSystem.Path.Received(1).Exists(uncPath);
}
@@ -280,8 +279,8 @@ public class WindowsPathStrategyTests
ErrorOr<FileSystemPathId> result = _sut.CombinePath(path, name);
// Assert
result.IsError.Should().BeFalse();
result.Value.Path.Should().Be(@"C:\Users\User\Documents\");
Assert.False(result.IsError);
Assert.Equal(@"C:\Users\User\Documents\", result.Value.Path);
}
[Fact]
@@ -295,8 +294,8 @@ public class WindowsPathStrategyTests
ErrorOr<FileSystemPathId> result = _sut.CombinePath(path, name);
// Assert
result.IsError.Should().BeFalse();
result.Value.Path.Should().Be(@"C:\Users\User\Documents\");
Assert.False(result.IsError);
Assert.Equal(@"C:\Users\User\Documents\", result.Value.Path);
}
[Fact]
@@ -310,8 +309,8 @@ public class WindowsPathStrategyTests
ErrorOr<FileSystemPathId> result = _sut.CombinePath(path, name);
// Assert
result.IsError.Should().BeFalse();
result.Value.Path.Should().Be(@"C:\Users\User\Documents\");
Assert.False(result.IsError);
Assert.Equal(@"C:\Users\User\Documents\", result.Value.Path);
}
[Fact]
@@ -325,8 +324,8 @@ public class WindowsPathStrategyTests
ErrorOr<FileSystemPathId> result = _sut.CombinePath(path, name);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.NameCannotBeEmpty);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.NameCannotBeEmpty, result.FirstError);
}
[Fact]
@@ -340,8 +339,8 @@ public class WindowsPathStrategyTests
ErrorOr<FileSystemPathId> result = _sut.CombinePath(path, name);
// Assert
result.IsError.Should().BeFalse();
result.Value.Path.Should().Be(@"C:\Users\");
Assert.False(result.IsError);
Assert.Equal(@"C:\Users\", result.Value.Path);
}
[Fact]
@@ -355,8 +354,8 @@ public class WindowsPathStrategyTests
ErrorOr<FileSystemPathId> result = _sut.CombinePath(path, name);
// Assert
result.IsError.Should().BeFalse();
result.Value.Path.Should().Be(@"\\server\share\folder\");
Assert.False(result.IsError);
Assert.Equal(@"\\server\share\folder\", result.Value.Path);
}
[Fact]
@@ -369,13 +368,13 @@ public class WindowsPathStrategyTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(5);
result.Value.ElementAt(0).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("C:", false, true));
result.Value.ElementAt(1).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("Users", true, false));
result.Value.ElementAt(2).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("User", true, false));
result.Value.ElementAt(3).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("Documents", true, false));
result.Value.ElementAt(4).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("file.txt", false, false));
Assert.False(result.IsError);
Assert.Equal(5, result.Value.Count());
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("C:", false, true), result.Value.ElementAt(0));
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("Users", true, false), result.Value.ElementAt(1));
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("User", true, false), result.Value.ElementAt(2));
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("Documents", true, false), result.Value.ElementAt(3));
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("file.txt", false, false), result.Value.ElementAt(4));
}
[Fact]
@@ -388,9 +387,9 @@ public class WindowsPathStrategyTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(1);
result.Value.Single().Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("C:", false, true));
Assert.False(result.IsError);
Assert.Single(result.Value);
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("C:", false, true), result.Value.Single());
}
[Fact]
@@ -403,9 +402,9 @@ public class WindowsPathStrategyTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(4);
result.Value.Last().Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("Documents", true, false));
Assert.False(result.IsError);
Assert.Equal(4, result.Value.Count());
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("Documents", true, false), result.Value.Last());
}
[Fact]
@@ -418,8 +417,8 @@ public class WindowsPathStrategyTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -432,9 +431,9 @@ public class WindowsPathStrategyTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(4);
result.Value.Last().Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("file.with.dots.txt", false, false));
Assert.False(result.IsError);
Assert.Equal(4, result.Value.Count());
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("file.with.dots.txt", false, false), result.Value.Last());
}
[Fact]
@@ -447,13 +446,13 @@ public class WindowsPathStrategyTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.ParsePath(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(5);
result.Value.ElementAt(0).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment(@"\\", false, true));
result.Value.ElementAt(1).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("server", true, false));
result.Value.ElementAt(2).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("share", true, false));
result.Value.ElementAt(3).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("folder", true, false));
result.Value.ElementAt(4).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("file.txt", false, false));
Assert.False(result.IsError);
Assert.Equal(5, result.Value.Count());
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment(@"\\", false, true), result.Value.ElementAt(0));
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("server", true, false), result.Value.ElementAt(1));
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("share", true, false), result.Value.ElementAt(2));
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("folder", true, false), result.Value.ElementAt(3));
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("file.txt", false, false), result.Value.ElementAt(4));
}
[Fact]
@@ -466,11 +465,11 @@ public class WindowsPathStrategyTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(3);
result.Value.ElementAt(0).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("C:", false, true));
result.Value.ElementAt(1).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("Users", true, false));
result.Value.ElementAt(2).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("User", true, false));
Assert.False(result.IsError);
Assert.Equal(3, result.Value.Count());
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("C:", false, true), result.Value.ElementAt(0));
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("Users", true, false), result.Value.ElementAt(1));
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("User", true, false), result.Value.ElementAt(2));
}
[Fact]
@@ -483,8 +482,8 @@ public class WindowsPathStrategyTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.CannotNavigateUp);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.CannotNavigateUp, result.FirstError);
}
[Fact]
@@ -497,10 +496,10 @@ public class WindowsPathStrategyTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(2);
result.Value.ElementAt(0).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("C:", false, true));
result.Value.ElementAt(1).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("Users", true, false));
Assert.False(result.IsError);
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));
}
[Fact]
@@ -513,8 +512,8 @@ public class WindowsPathStrategyTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -527,9 +526,9 @@ public class WindowsPathStrategyTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(1);
result.Value.Single().Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("C:", false, true));
Assert.False(result.IsError);
Assert.Single(result.Value);
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("C:", false, true), result.Value.Single());
}
[Fact]
@@ -542,12 +541,12 @@ public class WindowsPathStrategyTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(4);
result.Value.ElementAt(0).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment(@"\\", false, true));
result.Value.ElementAt(1).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("server", true, false));
result.Value.ElementAt(2).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("share", true, false));
result.Value.ElementAt(3).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("folder", true, false));
Assert.False(result.IsError);
Assert.Equal(4, result.Value.Count());
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment(@"\\", false, true), result.Value.ElementAt(0));
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("server", true, false), result.Value.ElementAt(1));
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("share", true, false), result.Value.ElementAt(2));
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("folder", true, false), result.Value.ElementAt(3));
}
[Fact]
@@ -560,8 +559,8 @@ public class WindowsPathStrategyTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.CannotNavigateUp);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.CannotNavigateUp, result.FirstError);
}
[Fact]
@@ -574,11 +573,11 @@ public class WindowsPathStrategyTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().HaveCount(3);
result.Value.ElementAt(0).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment(@"\\", false, true));
result.Value.ElementAt(1).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("server", true, false));
result.Value.ElementAt(2).Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("share", true, false));
Assert.False(result.IsError);
Assert.Equal(3, result.Value.Count());
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment(@"\\", false, true), result.Value.ElementAt(0));
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("server", true, false), result.Value.ElementAt(1));
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("share", true, false), result.Value.ElementAt(2));
}
[Fact]
@@ -591,8 +590,8 @@ public class WindowsPathStrategyTests
ErrorOr<IEnumerable<PathSegment>> result = _sut.GoUpOneLevel(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.CannotNavigateUp);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.CannotNavigateUp, result.FirstError);
}
[Fact]
@@ -602,7 +601,7 @@ public class WindowsPathStrategyTests
char[] result = _sut.GetInvalidPathCharsForPlatform();
// Assert
result.Should().BeEquivalentTo(['<', '>', '"', '/', '|', '?', '*']);
Assert.Equal(['<', '>', '"', '/', '|', '?', '*'], result);
}
[Fact]
@@ -612,9 +611,9 @@ public class WindowsPathStrategyTests
char[] result = _sut.GetInvalidPathCharsForPlatform();
// Assert
result.Should().NotContain('\\');
result.Should().NotContain(':');
result.Should().NotContain('\0');
Assert.DoesNotContain('\\', result);
Assert.DoesNotContain(':', result);
Assert.DoesNotContain('\0', result);
}
[Fact]
@@ -625,7 +624,7 @@ public class WindowsPathStrategyTests
char[] result2 = _sut.GetInvalidPathCharsForPlatform();
// Assert
result1.Should().BeEquivalentTo(result2);
Assert.Equal(result1, result2);
}
[Fact]
@@ -638,8 +637,8 @@ public class WindowsPathStrategyTests
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("C:\\", true, true));
Assert.False(result.IsError);
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("C:\\", true, true), result.Value);
}
[Fact]
@@ -652,8 +651,8 @@ public class WindowsPathStrategyTests
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment("C:\\", true, true));
Assert.False(result.IsError);
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment("C:\\", true, true), result.Value);
}
[Fact]
@@ -666,8 +665,8 @@ public class WindowsPathStrategyTests
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -680,8 +679,8 @@ public class WindowsPathStrategyTests
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment(@"\\server\share\", true, false));
Assert.False(result.IsError);
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment(@"\\server\share\", true, false), result.Value);
}
[Fact]
@@ -694,8 +693,8 @@ public class WindowsPathStrategyTests
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -708,8 +707,8 @@ public class WindowsPathStrategyTests
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -722,8 +721,8 @@ public class WindowsPathStrategyTests
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -736,8 +735,8 @@ public class WindowsPathStrategyTests
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -750,8 +749,8 @@ public class WindowsPathStrategyTests
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
// Assert
result.IsError.Should().BeFalse();
result.Value.Should().BeEquivalentTo(_pathSegmentFixture.CreatePathSegment(@"\\server\share\", true, false));
Assert.False(result.IsError);
Assert.Equivalent(_pathSegmentFixture.CreatePathSegment(@"\\server\share\", true, false), result.Value);
}
[Fact]
@@ -764,7 +763,7 @@ public class WindowsPathStrategyTests
ErrorOr<PathSegment> result = _sut.GetPathRoot(path);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
}
@@ -1,5 +1,4 @@
#region ========================================================================= USING =====================================================================================
using FluentAssertions;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Path;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.Strategies.Platform.Fixtures;
@@ -42,8 +41,8 @@ public class PlatformContextFactoryTests
IWindowsPlatformContext result = _sut.CreateStrategy<IWindowsPlatformContext>();
// Assert
result.Should().NotBeNull();
result.Should().BeOfType<WindowsPlatformContext>();
Assert.NotNull(result);
Assert.IsType<WindowsPlatformContext>(result);
}
[Fact]
@@ -53,8 +52,8 @@ public class PlatformContextFactoryTests
IUnixPlatformContext result = _sut.CreateStrategy<IUnixPlatformContext>();
// Assert
result.Should().NotBeNull();
result.Should().BeOfType<UnixPlatformContext>();
Assert.NotNull(result);
Assert.IsType<UnixPlatformContext>(result);
}
[Fact]
@@ -1,5 +1,4 @@
#region ========================================================================= USING =====================================================================================
using FluentAssertions;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
using NSubstitute;
@@ -41,7 +40,7 @@ public class PlatformContextManagerTests
IPlatformContext result = sut.GetCurrentContext();
// Assert
result.Should().Be(mockWindowsContext);
Assert.Same(mockWindowsContext, result);
_mockPlatformContextFactory.Received(1).CreateStrategy<IWindowsPlatformContext>();
}
@@ -59,7 +58,7 @@ public class PlatformContextManagerTests
IPlatformContext result = sut.GetCurrentContext();
// Assert
result.Should().Be(mockUnixContext);
Assert.Same(mockUnixContext, result);
_mockPlatformContextFactory.Received(1).CreateStrategy<IUnixPlatformContext>();
}
@@ -78,7 +77,7 @@ public class PlatformContextManagerTests
IPlatformContext result = sut.GetCurrentContext();
// Assert
result.Should().Be(mockUnixContext);
Assert.Same(mockUnixContext, result);
_mockPlatformContextFactory.Received(1).CreateStrategy<IUnixPlatformContext>();
}
@@ -97,7 +96,7 @@ public class PlatformContextManagerTests
IPlatformContext result = sut.GetCurrentContext();
// Assert
result.Should().Be(mockWindowsContext);
Assert.Same(mockWindowsContext, result);
_mockPlatformContextFactory.Received(1).CreateStrategy<IWindowsPlatformContext>();
}
@@ -110,9 +109,7 @@ public class PlatformContextManagerTests
sut = new(_mockPlatformContextFactory, mockOsInfo);
// Act & Assert
Action act = () => sut.SetCurrentPlatform(unsupportedPlatform);
act.Should().Throw<ArgumentException>()
.WithMessage($"Unsupported platform type: {unsupportedPlatform}");
Assert.Throws<ArgumentException>(() => sut.SetCurrentPlatform(unsupportedPlatform));
}
[Fact]
@@ -129,7 +126,7 @@ public class PlatformContextManagerTests
IPlatformContext result = sut.GetCurrentContext();
// Assert
result.Should().Be(mockUnixContext);
Assert.Same(mockUnixContext, result);
_mockPlatformContextFactory.Received(1).CreateStrategy<IUnixPlatformContext>();
}
@@ -147,7 +144,7 @@ public class PlatformContextManagerTests
IPlatformContext result = sut.GetCurrentContext();
// Assert
result.Should().Be(mockWindowsContext);
Assert.Same(mockWindowsContext, result);
_mockPlatformContextFactory.Received(1).CreateStrategy<IWindowsPlatformContext>();
}
}
@@ -1,5 +1,4 @@
#region ========================================================================= USING =====================================================================================
using FluentAssertions;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Path;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
@@ -25,8 +24,8 @@ public class PlatformContextTests
WindowsPlatformContext windowsPlatformContext = new(mockWindowsPathStrategy);
// Assert
windowsPlatformContext.Platform.Should().Be(PlatformType.Windows);
windowsPlatformContext.PathStrategy.Should().Be(mockWindowsPathStrategy);
Assert.Equal(PlatformType.Windows, windowsPlatformContext.Platform);
Assert.Equal(mockWindowsPathStrategy, windowsPlatformContext.PathStrategy);
}
[Fact]
@@ -39,8 +38,8 @@ public class PlatformContextTests
UnixPlatformContext unixPlatformContext = new(mockUnixPathStrategy);
// Assert
unixPlatformContext.Platform.Should().Be(PlatformType.Unix);
unixPlatformContext.PathStrategy.Should().Be(mockUnixPathStrategy);
Assert.Equal(PlatformType.Unix, unixPlatformContext.Platform);
Assert.Equal(mockUnixPathStrategy, unixPlatformContext.PathStrategy);
}
[Fact]
@@ -53,7 +52,7 @@ public class PlatformContextTests
WindowsPlatformContext windowsPlatformContext = new(mockWindowsPathStrategy);
// Assert
windowsPlatformContext.Should().BeAssignableTo<IWindowsPlatformContext>();
Assert.IsAssignableFrom<IWindowsPlatformContext>(windowsPlatformContext);
}
[Fact]
@@ -66,7 +65,7 @@ public class PlatformContextTests
UnixPlatformContext unixPlatformContext = new(mockUnixPathStrategy);
// Assert
unixPlatformContext.Should().BeAssignableTo<IUnixPlatformContext>();
Assert.IsAssignableFrom<IUnixPlatformContext>(unixPlatformContext);
}
[Fact]
@@ -77,8 +76,7 @@ public class PlatformContextTests
WindowsPlatformContext windowsPlatformContext = new(mockWindowsPathStrategy);
// Act & Assert
windowsPlatformContext.GetType().GetProperty(nameof(WindowsPlatformContext.PathStrategy))!
.SetMethod.Should().BeNull();
Assert.Null(windowsPlatformContext.GetType().GetProperty(nameof(WindowsPlatformContext.PathStrategy))!.SetMethod);
}
[Fact]
@@ -89,8 +87,7 @@ public class PlatformContextTests
UnixPlatformContext unixPlatformContext = new(mockUnixPathStrategy);
// Act & Assert
unixPlatformContext.GetType().GetProperty(nameof(UnixPlatformContext.PathStrategy))!
.SetMethod.Should().BeNull();
Assert.Null(unixPlatformContext.GetType().GetProperty(nameof(UnixPlatformContext.PathStrategy))!.SetMethod);
}
[Fact]
@@ -101,8 +98,7 @@ public class PlatformContextTests
WindowsPlatformContext windowsPlatformContext = new(mockWindowsPathStrategy);
// Act & Assert
windowsPlatformContext.GetType().GetProperty(nameof(WindowsPlatformContext.Platform))!
.SetMethod.Should().BeNull();
Assert.Null(windowsPlatformContext.GetType().GetProperty(nameof(WindowsPlatformContext.Platform))!.SetMethod);
}
[Fact]
@@ -113,7 +109,6 @@ public class PlatformContextTests
UnixPlatformContext unixPlatformContext = new(mockUnixPathStrategy);
// Act & Assert
unixPlatformContext.GetType().GetProperty(nameof(UnixPlatformContext.Platform))!
.SetMethod.Should().BeNull();
Assert.Null(unixPlatformContext.GetType().GetProperty(nameof(UnixPlatformContext.Platform))!.SetMethod);
}
}
@@ -1,6 +1,5 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FluentAssertions;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.ValueObjects.Fixtures;
@@ -35,8 +34,8 @@ public class FileSystemPathIdTests
ErrorOr<FileSystemPathId> result = FileSystemPathId.Create(validPath);
// Assert
result.IsError.Should().BeFalse();
result.Value.Path.Should().Be(validPath);
Assert.False(result.IsError);
Assert.Equal(validPath, result.Value.Path);
}
[Theory]
@@ -49,8 +48,8 @@ public class FileSystemPathIdTests
ErrorOr<FileSystemPathId> result = FileSystemPathId.Create(invalidPath!);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.InvalidPath);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
}
[Fact]
@@ -65,7 +64,7 @@ public class FileSystemPathIdTests
bool result = id1.Equals(id2);
// Assert
result.Should().BeTrue();
Assert.True(result);
}
[Fact]
@@ -79,7 +78,7 @@ public class FileSystemPathIdTests
bool result = id1.Equals(id2);
// Assert
result.Should().BeFalse();
Assert.False(result);
}
[Fact]
@@ -95,7 +94,7 @@ public class FileSystemPathIdTests
int hashCode2 = id2.GetHashCode();
// Assert
hashCode1.Should().Be(hashCode2);
Assert.Equal(hashCode1, hashCode2);
}
[Fact]
@@ -110,7 +109,7 @@ public class FileSystemPathIdTests
int hashCode2 = id2.GetHashCode();
// Assert
hashCode1.Should().NotBe(hashCode2);
Assert.NotEqual(hashCode1, hashCode2);
}
[Fact]
@@ -125,7 +124,7 @@ public class FileSystemPathIdTests
bool result = id1 == id2;
// Assert
result.Should().BeTrue();
Assert.True(result);
}
[Fact]
@@ -139,6 +138,6 @@ public class FileSystemPathIdTests
bool result = id1 != id2;
// Assert
result.Should().BeTrue();
Assert.True(result);
}
}
@@ -1,6 +1,5 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FluentAssertions;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.ValueObjects.Fixtures;
@@ -37,10 +36,10 @@ public class PathSegmentTests
ErrorOr<PathSegment> result = PathSegment.Create(name, isDirectory, isDrive);
// Assert
result.IsError.Should().BeFalse();
result.Value.Name.Should().Be(name);
result.Value.IsDirectory.Should().Be(isDirectory);
result.Value.IsDrive.Should().Be(isDrive);
Assert.False(result.IsError);
Assert.Equal(name, result.Value.Name);
Assert.Equal(isDirectory, result.Value.IsDirectory);
Assert.Equal(isDrive, result.Value.IsDrive);
}
[Theory]
@@ -53,8 +52,8 @@ public class PathSegmentTests
ErrorOr<PathSegment> result = PathSegment.Create(invalidName!, true, false);
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.NameCannotBeEmpty);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.NameCannotBeEmpty, result.FirstError);
}
[Fact]
@@ -68,7 +67,7 @@ public class PathSegmentTests
bool result = segment1.Equals(segment2);
// Assert
result.Should().BeTrue();
Assert.True(result);
}
[Fact]
@@ -82,7 +81,7 @@ public class PathSegmentTests
bool result = segment1.Equals(segment2);
// Assert
result.Should().BeFalse();
Assert.False(result);
}
[Fact]
@@ -97,7 +96,7 @@ public class PathSegmentTests
int hashCode2 = segment2.GetHashCode();
// Assert
hashCode1.Should().Be(hashCode2);
Assert.Equal(hashCode1, hashCode2);
}
[Fact]
@@ -112,7 +111,7 @@ public class PathSegmentTests
int hashCode2 = segment2.GetHashCode();
// Assert
hashCode1.Should().NotBe(hashCode2);
Assert.NotEqual(hashCode1, hashCode2);
}
[Fact]
@@ -126,7 +125,7 @@ public class PathSegmentTests
bool result = segment1 == segment2;
// Assert
result.Should().BeTrue();
Assert.True(result);
}
[Fact]
@@ -140,6 +139,6 @@ public class PathSegmentTests
bool result = segment1 != segment2;
// Assert
result.Should().BeTrue();
Assert.True(result);
}
}
@@ -1,6 +1,5 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FluentAssertions;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
@@ -44,15 +43,15 @@ public class StreamInfoTests
ErrorOr<StreamInfo> result = StreamInfo.Create(streamId, mimeType, bitrate, codec, resolution, frameRate, sampleRate, channels);
// Assert
result.IsError.Should().BeFalse();
result.Value.StreamId.Should().Be(streamId);
result.Value.MimeType.Should().Be(mimeType);
result.Value.Bitrate.Should().Be(bitrate);
result.Value.Codec.Should().Be(codec);
result.Value.Resolution.Should().Be(resolution);
result.Value.FrameRate.Should().Be(frameRate);
result.Value.SampleRate.Should().Be(sampleRate);
result.Value.Channels.Should().Be(channels);
Assert.False(result.IsError);
Assert.Equal(streamId, result.Value.StreamId);
Assert.Equal(mimeType, result.Value.MimeType);
Assert.Equal(bitrate, result.Value.Bitrate);
Assert.Equal(codec, result.Value.Codec);
Assert.Equal(resolution, result.Value.Resolution);
Assert.Equal(frameRate, result.Value.FrameRate);
Assert.Equal(sampleRate, result.Value.SampleRate);
Assert.Equal(channels, result.Value.Channels);
}
[Fact]
@@ -68,8 +67,8 @@ public class StreamInfoTests
ErrorOr<StreamInfo> result = StreamInfo.Create(streamId!, mimeType, bitrate, codec, Optional<string>.None(), Optional<float>.None(), Optional<int>.None(), Optional<int>.None());
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.StreamIdCannotBeEmpty);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.StreamIdCannotBeEmpty, result.FirstError);
}
[Fact]
@@ -85,8 +84,8 @@ public class StreamInfoTests
ErrorOr<StreamInfo> result = StreamInfo.Create(streamId, mimeType, bitrate, codec!, Optional<string>.None(), Optional<float>.None(), Optional<int>.None(), Optional<int>.None());
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.CodecCannotBeEmpty);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.CodecCannotBeEmpty, result.FirstError);
}
[Fact]
@@ -102,8 +101,8 @@ public class StreamInfoTests
ErrorOr<StreamInfo> result = StreamInfo.Create(streamId, mimeType, bitrate, codec, Optional<string>.None(), Optional<float>.None(), Optional<int>.None(), Optional<int>.None());
// Assert
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileSystemManagement.BitrateMustBeAPositiveNumber);
Assert.True(result.IsError);
Assert.Equal(Errors.FileSystemManagement.BitrateMustBeAPositiveNumber, result.FirstError);
}
[Fact]
@@ -119,7 +118,7 @@ public class StreamInfoTests
bool result = info1.Equals(info2);
// Assert
result.Should().BeTrue();
Assert.True(result);
}
[Fact]
@@ -133,7 +132,7 @@ public class StreamInfoTests
bool result = info1.Equals(info2);
// Assert
result.Should().BeFalse();
Assert.False(result);
}
[Fact]
@@ -150,7 +149,7 @@ public class StreamInfoTests
int hashCode2 = info2.GetHashCode();
// Assert
hashCode1.Should().Be(hashCode2);
Assert.Equal(hashCode1, hashCode2);
}
[Fact]
@@ -165,6 +164,6 @@ public class StreamInfoTests
int hashCode2 = info2.GetHashCode();
// Assert
hashCode1.Should().NotBe(hashCode2);
Assert.NotEqual(hashCode1, hashCode2);
}
}
@@ -1,5 +1,4 @@
#region ========================================================================= USING =====================================================================================
using FluentAssertions;
using Lumina.Domain.Common.Enums.PhotoLibrary;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using Lumina.Domain.UnitTests.Core.Aggregates.FileSystemManagementAggregate.ValueObjects.Fixtures;
@@ -28,7 +27,7 @@ public class ThumbnailTests
}
[Fact]
public void Constructor_ShouldSetPropertiesCorrectly()
public void Constructor_WhenCalled_ShouldSetPropertiesCorrectly()
{
// Arrange
ImageType type = ImageType.PNG;
@@ -38,8 +37,8 @@ public class ThumbnailTests
Thumbnail thumbnail = new(type, bytes);
// Assert
thumbnail.Type.Should().Be(type);
thumbnail.Bytes.Should().BeEquivalentTo(bytes);
Assert.Equal(type, thumbnail.Type);
Assert.Equal(bytes, thumbnail.Bytes);
}
[Fact]
@@ -53,7 +52,7 @@ public class ThumbnailTests
bool result = thumbnail1.Equals(thumbnail2);
// Assert
result.Should().BeTrue();
Assert.True(result);
}
[Fact]
@@ -67,7 +66,7 @@ public class ThumbnailTests
bool result = thumbnail1.Equals(thumbnail2);
// Assert
result.Should().BeFalse();
Assert.False(result);
}
[Fact]
@@ -81,7 +80,7 @@ public class ThumbnailTests
bool result = thumbnail1.Equals(thumbnail2);
// Assert
result.Should().BeFalse();
Assert.False(result);
}
[Fact]
@@ -96,7 +95,7 @@ public class ThumbnailTests
int hashCode2 = thumbnail2.GetHashCode();
// Assert
hashCode1.Should().Be(hashCode2);
Assert.Equal(hashCode1, hashCode2);
}
[Fact]
@@ -111,7 +110,7 @@ public class ThumbnailTests
int hashCode2 = thumbnail2.GetHashCode();
// Assert
hashCode1.Should().NotBe(hashCode2);
Assert.NotEqual(hashCode1, hashCode2);
}
[Fact]
@@ -124,8 +123,8 @@ public class ThumbnailTests
List<object> components = thumbnail.GetEqualityComponents().ToList();
// Assert
components.Should().HaveCount(2);
components[0].Should().Be(thumbnail.Type);
components[1].Should().BeEquivalentTo(thumbnail.Bytes);
Assert.Equal(2, components.Count);
Assert.Equal(thumbnail.Type, components[0]);
Assert.Equal(thumbnail.Bytes, components[1]);
}
}