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
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<ItemGroup>
<PackageVersion Include="Testably.Abstractions" Version="2.4.1" />
<PackageVersion Include="Testably.Abstractions.Testing" Version="2.4.1" />
<PackageVersion Include="Testably.Abstractions.FluentAssertions" Version="0.9.0" />
<PackageVersion Include="Testably.Abstractions.FluentAssertions" Version="0.10.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public void Initialize_WithSubdirectory_ShouldExist(string directoryName)
MockFileSystem> result =
sut.Initialize().WithSubdirectory(directoryName);

result.Directory.Exists.Should().BeTrue();
result.Directory.Should().Exist();
}

[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ public void CreateDirectory_ShouldCreateParentDirectories()
result.Name.Should().Be(directoryLevel3);
result.Parent!.Name.Should().Be(directoryLevel2);
result.Parent.Parent!.Name.Should().Be(directoryLevel1);
result.Exists.Should().BeTrue();
result.Parent.Exists.Should().BeTrue();
result.Parent.Parent.Exists.Should().BeTrue();
result.Should().Exist();
result.Parent.Should().Exist();
result.Parent.Parent.Should().Exist();
}

#if NETFRAMEWORK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void Delete_FullPath_ShouldDeleteDirectory(string directoryName)
FileSystem.Directory.Delete(result.FullName);

FileSystem.Should().NotHaveDirectory(directoryName);
result.Exists.Should().BeFalse();
result.Should().NotExist();
}

[SkippableTheory]
Expand Down Expand Up @@ -195,7 +195,7 @@ public void Delete_ShouldDeleteDirectory(string directoryName)
FileSystem.Directory.Delete(directoryName);

FileSystem.Should().NotHaveDirectory(directoryName);
result.Exists.Should().BeFalse();
result.Should().NotExist();
}

[SkippableTheory]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#if FEATURE_FILESYSTEM_LINK
using System.IO;
using Testably.Abstractions.FluentAssertions;

namespace Testably.Abstractions.Tests.FileSystem.Directory;

Expand Down Expand Up @@ -32,7 +33,7 @@ public void ResolveLinkTarget_AbsolutePath_ShouldFollowSymbolicLink(
FileSystem.Directory.ResolveLinkTarget(path, false);

target!.FullName.Should().Be(targetFullPath);
target.Exists.Should().BeTrue();
target.Should().Exist();
}

[SkippableTheory]
Expand All @@ -53,12 +54,12 @@ public void
if (!Test.RunsOnLinux)
{
target!.FullName.Should().Be(targetFullPath);
target.Exists.Should().BeTrue();
target.Should().Exist();
}
else
{
target!.FullName.Should().Be(targetFullPath);
target.Exists.Should().BeFalse();
target.Should().NotExist();
}
}

Expand Down Expand Up @@ -174,7 +175,7 @@ public void ResolveLinkTarget_RelativePath_ShouldFollowSymbolicLinkUnderWindows(
FileSystem.Directory.ResolveLinkTarget(path, false);

target!.FullName.Should().Be(targetFullPath);
target.Exists.Should().BeTrue();
target.Should().Exist();
}

[SkippableTheory]
Expand All @@ -194,7 +195,7 @@ public void ResolveLinkTarget_TargetDeletedAfterLinkCreation_ShouldReturnNull(

target!.FullName.Should().Be(targetFullPath);

target.Exists.Should().BeFalse();
target.Should().NotExist();
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public void CreateTempSubdirectory_ShouldCreateTheTemporaryDirectory()
{
IDirectoryInfo result = FileSystem.Directory.CreateTempSubdirectory();

result.Exists.Should().BeTrue();
result.Should().Exist();
}

[SkippableTheory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public void CreateSubdirectory_MissingParent_ShouldCreateDirectory(
string path, string subdirectory)
{
IDirectoryInfo sut = FileSystem.DirectoryInfo.New(path);
sut.Exists.Should().BeFalse();
sut.Should().NotExist();
IDirectoryInfo result = sut.CreateSubdirectory(subdirectory);

sut.Exists.Should().BeFalse();
sut.Should().NotExist();
FileSystem.Should().HaveDirectory(sut.FullName);
result.Exists.Should().BeTrue();
result.Should().Exist();
FileSystem.Should().HaveDirectory(result.FullName);
}

Expand All @@ -48,9 +48,9 @@ public void CreateSubdirectory_ShouldCreateDirectory(string path, string subdire
sut.Create();
IDirectoryInfo result = sut.CreateSubdirectory(subdirectory);

sut.Exists.Should().BeTrue();
sut.Should().Exist();
FileSystem.Should().HaveDirectory(sut.FullName);
result.Exists.Should().BeTrue();
result.Should().Exist();
FileSystem.Should().HaveDirectory(result.FullName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ public void Create_FileWithSameNameAlreadyExists_ShouldThrowIOException(string n
public void Create_ShouldCreateDirectory(string path)
{
IDirectoryInfo sut = FileSystem.DirectoryInfo.New(path);
sut.Exists.Should().BeFalse();
sut.Should().NotExist();

sut.Create();

#if NETFRAMEWORK
// The DirectoryInfo is not updated in .NET Framework!
sut.Exists.Should().BeFalse();
sut.Should().NotExist();
#else
sut.Exists.Should().BeTrue();
sut.Should().Exist();
#endif
FileSystem.Should().HaveDirectory(sut.FullName);
}
Expand Down Expand Up @@ -68,9 +68,9 @@ public void Create_ShouldCreateParentDirectories()
result.Name.Should().Be(directoryLevel3);
result.Parent!.Name.Should().Be(directoryLevel2);
result.Parent.Parent!.Name.Should().Be(directoryLevel1);
result.Exists.Should().BeTrue();
result.Parent.Exists.Should().BeTrue();
result.Parent.Parent.Exists.Should().BeTrue();
result.Should().Exist();
result.Parent.Should().Exist();
result.Parent.Parent.Should().Exist();
result.ToString().Should().Be(path);
}

Expand All @@ -81,23 +81,23 @@ public void Create_ShouldRefreshExistsCacheForCurrentItem_ExceptOnNetFramework(s
IDirectoryInfo sut1 = FileSystem.DirectoryInfo.New(path);
IDirectoryInfo sut2 = FileSystem.DirectoryInfo.New(path);
IDirectoryInfo sut3 = FileSystem.DirectoryInfo.New(path);
sut1.Exists.Should().BeFalse();
sut2.Exists.Should().BeFalse();
sut1.Should().NotExist();
sut2.Should().NotExist();
// Do not call Exists for `sut3`

sut1.Create();

if (Test.IsNetFramework)
{
sut1.Exists.Should().BeFalse();
sut2.Exists.Should().BeFalse();
sut3.Exists.Should().BeTrue();
sut1.Should().NotExist();
sut2.Should().NotExist();
sut3.Should().Exist();
}
else
{
sut1.Exists.Should().BeTrue();
sut2.Exists.Should().BeFalse();
sut3.Exists.Should().BeTrue();
sut1.Should().Exist();
sut2.Should().NotExist();
sut3.Should().Exist();
}

FileSystem.Should().HaveDirectory(path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public abstract partial class DeleteTests<TFileSystem>
public void Delete_MissingDirectory_ShouldThrowDirectoryNotFoundException(string path)
{
IDirectoryInfo sut = FileSystem.DirectoryInfo.New(path);
sut.Exists.Should().BeFalse();
sut.Should().NotExist();

Exception? exception = Record.Exception(() =>
{
Expand Down Expand Up @@ -69,15 +69,15 @@ public void Delete_Recursive_WithSubdirectory_ShouldDeleteDirectoryWithContent(
string subdirectoryPath = FileSystem.Path.Combine(path, subdirectory);
FileSystem.Directory.CreateDirectory(subdirectoryPath);
IDirectoryInfo sut = FileSystem.DirectoryInfo.New(path);
sut.Exists.Should().BeTrue();
sut.Should().Exist();

sut.Delete(true);

#if NETFRAMEWORK
// The DirectoryInfo is not updated in .NET Framework!
sut.Exists.Should().BeTrue();
sut.Should().Exist();
#else
sut.Exists.Should().BeFalse();
sut.Should().NotExist();
#endif
FileSystem.Should().NotHaveDirectory(sut.FullName);
FileSystem.Should().NotHaveDirectory(subdirectoryPath);
Expand All @@ -89,15 +89,15 @@ public void Delete_ShouldDeleteDirectory(string path)
{
FileSystem.Directory.CreateDirectory(path);
IDirectoryInfo sut = FileSystem.DirectoryInfo.New(path);
sut.Exists.Should().BeTrue();
sut.Should().Exist();

sut.Delete();

#if NETFRAMEWORK
// The DirectoryInfo is not updated in .NET Framework!
sut.Exists.Should().BeTrue();
sut.Should().Exist();
#else
sut.Exists.Should().BeFalse();
sut.Should().NotExist();
#endif
FileSystem.Should().NotHaveDirectory(sut.FullName);
}
Expand All @@ -109,7 +109,7 @@ public void Delete_WithSubdirectory_ShouldThrowIOException_AndNotDeleteDirectory
{
FileSystem.Directory.CreateDirectory(FileSystem.Path.Combine(path, subdirectory));
IDirectoryInfo sut = FileSystem.DirectoryInfo.New(path);
sut.Exists.Should().BeTrue();
sut.Should().Exist();

Exception? exception = Record.Exception(() =>
{
Expand All @@ -123,7 +123,7 @@ public void Delete_WithSubdirectory_ShouldThrowIOException_AndNotDeleteDirectory
? null
: $"'{sut.FullName}'");

sut.Exists.Should().BeTrue();
sut.Should().Exist();
FileSystem.Should().HaveDirectory(sut.FullName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public void Exists_ArbitraryPath_ShouldBeFalse(string path)
{
IDirectoryInfo sut = FileSystem.DirectoryInfo.New(path);

sut.Exists.Should().BeFalse();
sut.Should().NotExist();
FileSystem.Should().NotHaveDirectory(sut.FullName);
}

Expand All @@ -21,10 +21,10 @@ public void Exists_ExistedPreviously_ShouldOnlyUpdateOnInitialization(string pat
{
FileSystem.Directory.CreateDirectory(path);
IDirectoryInfo sut = FileSystem.DirectoryInfo.New(path);
sut.Exists.Should().BeTrue();
sut.Should().Exist();
FileSystem.Directory.Delete(path);

sut.Exists.Should().BeTrue();
sut.Should().Exist();
FileSystem.Should().NotHaveDirectory(sut.FullName);
}

Expand All @@ -35,18 +35,18 @@ public void Exists_File_ShouldReturnFalse(string path)
FileSystem.File.WriteAllText(path, null);
IDirectoryInfo sut = FileSystem.DirectoryInfo.New(path);

sut.Exists.Should().BeFalse();
sut.Should().NotExist();
}

[SkippableTheory]
[AutoData]
public void Exists_NotExistedPreviously_ShouldOnlyUpdateOnInitialization(string path)
{
IDirectoryInfo sut = FileSystem.DirectoryInfo.New(path);
sut.Exists.Should().BeFalse();
sut.Should().NotExist();
FileSystem.Directory.CreateDirectory(path);

sut.Exists.Should().BeFalse();
sut.Should().NotExist();
FileSystem.Should().HaveDirectory(sut.FullName);
}

Expand All @@ -56,19 +56,19 @@ public void Exists_ShouldNotChangeOnMoveTo(string path, string destination)
{
FileSystem.Directory.CreateDirectory(path);
IDirectoryInfo sut = FileSystem.DirectoryInfo.New(path);
sut.Exists.Should().BeTrue();
sut.Should().Exist();

sut.MoveTo(destination);

sut.Exists.Should().BeTrue();
sut.Should().Exist();
}

[SkippableTheory]
[AutoData]
public void Exists_ShouldUpdateOnCreateWhenNotNetFramework(string path)
{
IDirectoryInfo sut = FileSystem.DirectoryInfo.New(path);
sut.Exists.Should().BeFalse();
sut.Should().NotExist();

sut.Create();

Expand All @@ -81,7 +81,7 @@ public void Exists_ShouldUpdateOnDeleteWhenNotNetFramework(string path)
{
FileSystem.Directory.CreateDirectory(path);
IDirectoryInfo sut = FileSystem.DirectoryInfo.New(path);
sut.Exists.Should().BeTrue();
sut.Should().Exist();

sut.Delete();

Expand All @@ -94,7 +94,7 @@ public void Exists_ShouldUpdateOnRecursiveDeleteWhenNotNetFramework(string path)
{
FileSystem.Directory.CreateDirectory(path);
IDirectoryInfo sut = FileSystem.DirectoryInfo.New(path);
sut.Exists.Should().BeTrue();
sut.Should().Exist();

sut.Delete(true);

Expand All @@ -107,12 +107,12 @@ public void Exists_ShouldUpdateOnRefresh(string path)
{
FileSystem.Directory.CreateDirectory(path);
IDirectoryInfo sut = FileSystem.DirectoryInfo.New(path);
sut.Exists.Should().BeTrue();
sut.Should().Exist();
FileSystem.Directory.Delete(path);
sut.Exists.Should().BeTrue();
sut.Should().Exist();

sut.Refresh();

sut.Exists.Should().BeFalse();
sut.Should().NotExist();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ public void Parent_ArbitraryPaths_ShouldNotBeNull(string path1,
IDirectoryInfo sut = FileSystem.DirectoryInfo.New(path);

sut.Parent.Should().NotBeNull();
sut.Parent!.Exists.Should().BeFalse();
sut.Parent!.Should().NotExist();
sut.Parent.Parent.Should().NotBeNull();
sut.Parent.Parent!.Exists.Should().BeFalse();
sut.Parent.Parent!.Should().NotExist();
}

[SkippableFact]
Expand Down Expand Up @@ -357,7 +357,7 @@ public void Root_ShouldExist(string path)
string expectedRoot = FileTestHelper.RootDrive();
IDirectoryInfo result = FileSystem.DirectoryInfo.New(path);

result.Root.Exists.Should().BeTrue();
result.Root.Should().Exist();
result.Root.FullName.Should().Be(expectedRoot);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void New_ShouldCreateNewDirectoryInfoFromPath(string path)
IDirectoryInfo result = FileSystem.DirectoryInfo.New(path);

result.ToString().Should().Be(path);
result.Exists.Should().BeFalse();
result.Should().NotExist();
}

[SkippableFact]
Expand Down
Loading