Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<ItemGroup>
<PackageVersion Include="Testably.Abstractions" Version="2.3.4" />
<PackageVersion Include="Testably.Abstractions.Testing" Version="2.3.4" />
<PackageVersion Include="Testably.Abstractions.FluentAssertions" Version="0.5.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ public void CreateDirectory_CustomException_ShouldNotCreateDirectory(
{
FileSystem.Intercept.Event(_ =>
{
FileSystem.Directory.Exists(path).Should().BeFalse();
FileSystem.Should().NotHaveDirectory(path);
throw exceptionToThrow;
});
Exception? exception = Record.Exception(() =>
{
FileSystem.Directory.CreateDirectory(path);
});

FileSystem.Directory.Exists(path).Should().BeFalse();
FileSystem.Should().NotHaveDirectory(path);
exception.Should().Be(exceptionToThrow);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public void Directory_ShouldSetExtensionPoint(IFileSystem fileSystem)

IFileSystem result = sut.FileSystem;

result.Should().Be(fileSystem);
result.Should().BeSameAs(fileSystem);
}

[SkippableTheory]
Expand All @@ -24,7 +24,7 @@ public void DirectoryInfo_ShouldSetExtensionPoint(IFileSystem fileSystem)

IFileSystem result = sut.FileSystem;

result.Should().Be(fileSystem);
result.Should().BeSameAs(fileSystem);
}

[SkippableTheory]
Expand All @@ -35,7 +35,7 @@ public void DirectoryInfoFactory_ShouldSetExtensionPoint(IFileSystem fileSystem)

IFileSystem result = sut.FileSystem;

result.Should().Be(fileSystem);
result.Should().BeSameAs(fileSystem);
}

[SkippableTheory]
Expand All @@ -46,7 +46,7 @@ public void DriveInfo_ShouldSetExtensionPoint(IFileSystem fileSystem)

IFileSystem result = sut.FileSystem;

result.Should().Be(fileSystem);
result.Should().BeSameAs(fileSystem);
}

[SkippableTheory]
Expand All @@ -57,7 +57,7 @@ public void DriveInfoFactory_ShouldSetExtensionPoint(IFileSystem fileSystem)

IFileSystem result = sut.FileSystem;

result.Should().Be(fileSystem);
result.Should().BeSameAs(fileSystem);
}

[SkippableTheory]
Expand All @@ -68,7 +68,7 @@ public void File_ShouldSetExtensionPoint(IFileSystem fileSystem)

IFileSystem result = sut.FileSystem;

result.Should().Be(fileSystem);
result.Should().BeSameAs(fileSystem);
}

[SkippableTheory]
Expand All @@ -79,7 +79,7 @@ public void FileInfo_ShouldSetExtensionPoint(IFileSystem fileSystem)

IFileSystem result = sut.FileSystem;

result.Should().Be(fileSystem);
result.Should().BeSameAs(fileSystem);
}

[SkippableTheory]
Expand All @@ -90,7 +90,7 @@ public void FileInfoFactory_ShouldSetExtensionPoint(IFileSystem fileSystem)

IFileSystem result = sut.FileSystem;

result.Should().Be(fileSystem);
result.Should().BeSameAs(fileSystem);
}

[SkippableTheory]
Expand All @@ -101,7 +101,7 @@ public void FileStreamFactory_ShouldSetExtensionPoint(IFileSystem fileSystem)

IFileSystem result = sut.FileSystem;

result.Should().Be(fileSystem);
result.Should().BeSameAs(fileSystem);
}

[SkippableTheory]
Expand All @@ -112,7 +112,7 @@ public void FileSystemInfo_ShouldSetExtensionPoint(IFileSystem fileSystem)

IFileSystem result = sut.FileSystem;

result.Should().Be(fileSystem);
result.Should().BeSameAs(fileSystem);
}

[SkippableTheory]
Expand All @@ -123,7 +123,7 @@ public void FileSystemWatcher_ShouldSetExtensionPoint(IFileSystem fileSystem)

IFileSystem result = sut.FileSystem;

result.Should().Be(fileSystem);
result.Should().BeSameAs(fileSystem);
}

[SkippableTheory]
Expand All @@ -134,7 +134,7 @@ public void FileSystemWatcherFactory_ShouldSetExtensionPoint(IFileSystem fileSys

IFileSystem result = sut.FileSystem;

result.Should().Be(fileSystem);
result.Should().BeSameAs(fileSystem);
}

[SkippableTheory]
Expand All @@ -145,7 +145,7 @@ public void Path_ShouldSetExtensionPoint(IFileSystem fileSystem)

IFileSystem result = sut.FileSystem;

result.Should().Be(fileSystem);
result.Should().BeSameAs(fileSystem);
}

public static IEnumerable<object[]> GetFileSystems =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,10 @@ public void InternalBufferSize_ShouldResetQueue(string path1, string path2)
{
break;
}

FileSystem.Directory.CreateDirectory($"{i}_{path1}");
}

fileSystemWatcher.InternalBufferSize = 4196;
FileSystem.Directory.CreateDirectory(path2);
for (int i = 0; i < 4196 / 128; i++)
Expand All @@ -175,6 +177,7 @@ public void InternalBufferSize_ShouldResetQueue(string path1, string path2)
{
break;
}

FileSystem.Directory.CreateDirectory($"{i}_{path2}");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void With_DirectoryDescriptions_ShouldCreateDirectories(

foreach (DirectoryDescription directory in directories)
{
fileSystem.Directory.Exists(directory.Name).Should().BeTrue();
fileSystem.Should().HaveDirectory(directory.Name);
}
}

Expand All @@ -31,7 +31,7 @@ public void With_FileDescriptions_ShouldCreateFileContent(string name, string co

sut.With(description);

fileSystem.File.Exists(name).Should().BeTrue();
fileSystem.Should().HaveFile(name);
fileSystem.File.ReadAllText(name).Should().Be(content);
}

Expand All @@ -46,7 +46,7 @@ public void With_FileDescriptions_ShouldCreateFiles(FileDescription[] files)

foreach (FileDescription file in files)
{
fileSystem.File.Exists(file.Name).Should().BeTrue();
fileSystem.Should().HaveFile(file.Name);
}
}

Expand All @@ -64,7 +64,7 @@ public void With_FileDescriptions_ShouldSetIsReadOnlyFlag(bool isReadOnly, strin

sut.With(description);

fileSystem.File.Exists(name).Should().BeTrue();
fileSystem.Should().HaveFile(name);
fileSystem.FileInfo.New(name).IsReadOnly.Should().Be(isReadOnly);
}

Expand All @@ -79,8 +79,8 @@ public void With_FilesAndDirectories_ShouldBothBeCreated(string fileName, string

sut.With(fileDescription, directoryDescription);

fileSystem.File.Exists(fileName).Should().BeTrue();
fileSystem.Directory.Exists(directoryName).Should().BeTrue();
fileSystem.Should().HaveFile(fileName);
fileSystem.Should().HaveDirectory(directoryName);
}

[Theory]
Expand Down Expand Up @@ -120,7 +120,7 @@ public void WithFile_HasStringContent_ShouldWriteFileContent(string path)

sut.WithFile(path).Which(f => f.HasStringContent("foo"));

fileSystem.File.Exists(path).Should().BeTrue();
fileSystem.Should().HaveFile(path);
fileSystem.File.ReadAllText(path).Should().Be("foo");
}

Expand All @@ -135,8 +135,8 @@ public void WithFile_MissingDirectory_ShouldCreateDirectory(string directoryPath

sut.WithFile(path);

fileSystem.File.Exists(path).Should().BeTrue();
fileSystem.Directory.Exists(directoryPath).Should().BeTrue();
fileSystem.Should().HaveFile(path);
fileSystem.Should().HaveDirectory(directoryPath);
}

[Theory]
Expand All @@ -151,7 +151,7 @@ public void WithSubdirectories_ShouldCreateAllDirectories(string[] paths)

foreach (string path in paths)
{
fileSystem.Directory.Exists(path).Should().BeTrue();
fileSystem.Should().HaveDirectory(path);
}

result.Should().Be(sut);
Expand Down Expand Up @@ -196,7 +196,7 @@ public void WithSubdirectory_MultipleDirectoryLevels(string level1, string level
IFileSystemDirectoryInitializer<MockFileSystem> result = sut
.WithSubdirectory(path);

fileSystem.Directory.Exists(path).Should().BeTrue();
result.FileSystem.Should().Be(fileSystem);
fileSystem.Should().HaveDirectory(path);
result.FileSystem.Should().BeSameAs(fileSystem);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public void
result.Length.Should().Be(2);
result.Should().Contain(x => x.EndsWith("TestFile1.txt"));
result.Should().Contain(x => x.EndsWith("TestFile2.txt"));
fileSystem.Directory.Exists(Path.Combine(path, "SubResource")).Should().BeFalse();
fileSystem.Should().NotHaveDirectory(Path.Combine(path, "SubResource"));
}

[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ public void Container_ShouldProvideCorrectTimeAndFileSystem(string path)
IStorageLocation location = InMemoryLocation.New(null, path);
IStorageContainer sut = InMemoryContainer.NewFile(location, fileSystem);

sut.FileSystem.Should().Be(fileSystem);
sut.TimeSystem.Should().Be(fileSystem.TimeSystem);
sut.FileSystem.Should().BeSameAs(fileSystem);
sut.TimeSystem.Should().BeSameAs(fileSystem.TimeSystem);
}

[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public void Constructor_ShouldSetFileAndTimeSystem()

IStorageContainer sut = NullContainer.New(fileSystem);

sut.FileSystem.Should().Be(fileSystem);
sut.TimeSystem.Should().Be(fileSystem.TimeSystem);
sut.FileSystem.Should().BeSameAs(fileSystem);
sut.TimeSystem.Should().BeSameAs(fileSystem.TimeSystem);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
global using FluentAssertions;
global using System;
global using System.IO.Abstractions;
global using Testably.Abstractions.FluentAssertions;
global using Xunit;
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
<ProjectReference Include="..\..\Source\Testably.Abstractions\Testably.Abstractions.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Testably.Abstractions.FluentAssertions" />
</ItemGroup>

<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void CreateDirectory_AlreadyExisting_ShouldDoNothing(string path)
});

exception.Should().BeNull();
FileSystem.Directory.Exists(path).Should().BeTrue();
FileSystem.Should().HaveDirectory(path);
}

[SkippableTheory]
Expand All @@ -39,14 +39,14 @@ public void CreateDirectory_ReadOnlyParent_ShouldStillCreateDirectory(string par
if (Test.RunsOnWindows)
{
exception.Should().BeNull();
FileSystem.Directory.Exists(subdirectoryPath).Should().BeTrue();
FileSystem.Should().HaveDirectory(subdirectoryPath);
FileSystem.DirectoryInfo.New(parent).Attributes
.Should().HaveFlag(FileAttributes.ReadOnly);
}
else
{
exception.Should().BeException<UnauthorizedAccessException>(hResult: -2147024891);
FileSystem.Directory.Exists(subdirectoryPath).Should().BeFalse();
FileSystem.Should().NotHaveDirectory(subdirectoryPath);
}
}

Expand All @@ -63,7 +63,7 @@ public void CreateDirectory_FileWithSameNameAlreadyExists_ShouldThrowIOException

exception.Should().BeException<IOException>(
hResult: Test.RunsOnWindows ? -2147024713 : 17);
FileSystem.Directory.Exists(name).Should().BeFalse();
FileSystem.Should().NotHaveDirectory(name);
}

[SkippableFact]
Expand All @@ -78,7 +78,7 @@ public void CreateDirectory_Root_ShouldNotThrowException()
});

exception.Should().BeNull();
FileSystem.Directory.Exists(path).Should().BeTrue();
FileSystem.Should().HaveDirectory(path);
}

[SkippableTheory]
Expand Down Expand Up @@ -218,9 +218,8 @@ public void CreateDirectory_NullCharacter_ShouldThrowArgumentException()
public void CreateDirectory_ShouldCreateDirectoryInBasePath()
{
IDirectoryInfo result = FileSystem.Directory.CreateDirectory("foo");
bool exists = FileSystem.Directory.Exists("foo");

exists.Should().BeTrue();
FileSystem.Should().HaveDirectory("foo");
result.FullName.Should().StartWith(BasePath);
}

Expand Down Expand Up @@ -263,7 +262,7 @@ public void CreateDirectory_TrailingDirectorySeparator_ShouldNotBeTrimmed(
result.FullName.Should().Be(System.IO.Path.Combine(BasePath, expectedName
.Replace(FileSystem.Path.AltDirectorySeparatorChar,
FileSystem.Path.DirectorySeparatorChar)));
FileSystem.Directory.Exists(nameWithSuffix).Should().BeTrue();
FileSystem.Should().HaveDirectory(nameWithSuffix);
}

[SkippableTheory]
Expand All @@ -285,7 +284,7 @@ public void CreateDirectory_EmptyOrWhitespace_ShouldReturnEmptyString(
result.FullName.Should().Be(System.IO.Path.Combine(BasePath, expectedName
.Replace(FileSystem.Path.AltDirectorySeparatorChar,
FileSystem.Path.DirectorySeparatorChar)));
FileSystem.Directory.Exists(nameWithSuffix).Should().BeTrue();
FileSystem.Should().HaveDirectory(nameWithSuffix);
}
#else
[SkippableTheory]
Expand Down Expand Up @@ -317,7 +316,7 @@ public void CreateDirectory_TrailingDirectorySeparator_ShouldNotBeTrimmed(
result.FullName.Should().Be(System.IO.Path.Combine(BasePath, expectedName
.Replace(FileSystem.Path.AltDirectorySeparatorChar,
FileSystem.Path.DirectorySeparatorChar)));
FileSystem.Directory.Exists(nameWithSuffix).Should().BeTrue();
FileSystem.Should().HaveDirectory(nameWithSuffix);
}
#endif
}
Loading