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 @@ -46,7 +46,7 @@
<PackageVersion Include="System.Net.Http" Version="4.3.4"/>
<PackageVersion Include="aweXpect" Version="2.33.0"/>
<PackageVersion Include="aweXpect.Chronology" Version="1.1.0"/>
<PackageVersion Include="aweXpect.Testably" Version="0.14.0"/>
<PackageVersion Include="aweXpect.Testably" Version="0.15.0"/>
<PackageVersion Include="aweXpect.Mockolate" Version="3.1.0"/>
<PackageVersion Include="Mockolate" Version="3.2.0"/>
<PackageVersion Include="TUnit.Engine" Version="1.24.0"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public async Task AvailableFreeSpace_CannotGetNegative(long size)

FileSystem.WithDrive(d => d.ChangeUsedBytes(-1));

await That(drive.AvailableFreeSpace).IsEqualTo(size);
await That(drive).HasAvailableFreeSpace(size);
}

[Test]
Expand All @@ -38,7 +38,7 @@ void Act()

IDriveInfo drive = FileSystem.GetDefaultDrive();
await That(Act).ThrowsExactly<IOException>().WithMessage($"*'{drive.Name}'*").AsWildcard();
await That(drive.AvailableFreeSpace).IsEqualTo(fileSize - 1);
await That(drive).HasAvailableFreeSpace(fileSize - 1);
}

[Test]
Expand All @@ -54,10 +54,10 @@ public async Task AvailableFreeSpace_ShouldBeChangedWhenAppendingToAFile(
IDriveInfo drive = FileSystem.GetDefaultDrive();

FileSystem.File.WriteAllText(path, fileContent1, encoding);
await That(drive.AvailableFreeSpace).IsEqualTo(expectedRemainingBytes + fileSize2);
await That(drive).HasAvailableFreeSpace(expectedRemainingBytes + fileSize2);
FileSystem.File.AppendAllText(path, fileContent2, encoding);

await That(drive.AvailableFreeSpace).IsEqualTo(expectedRemainingBytes);
await That(drive).HasAvailableFreeSpace(expectedRemainingBytes);
}

[Test]
Expand All @@ -78,7 +78,7 @@ public async Task AvailableFreeSpace_ShouldBeChangedWhenWorkingWithStreams(
stream.SetLength(stream.Length - reduceLength);
}

await That(drive.AvailableFreeSpace).IsEqualTo(previousFreeSpace + reduceLength);
await That(drive).HasAvailableFreeSpace(previousFreeSpace + reduceLength);
}

[Test]
Expand All @@ -94,7 +94,7 @@ public async Task AvailableFreeSpace_ShouldBeReducedByWritingToFile(

IDriveInfo drive = FileSystem.GetDefaultDrive();

await That(drive.AvailableFreeSpace).IsEqualTo(0);
await That(drive).HasAvailableFreeSpace(0);
}

[Test]
Expand All @@ -111,7 +111,7 @@ public async Task AvailableFreeSpace_ShouldBeReleasedWhenDeletingAFile(

IDriveInfo drive = FileSystem.GetDefaultDrive();

await That(drive.AvailableFreeSpace).IsEqualTo(fileSize);
await That(drive).HasAvailableFreeSpace(fileSize);
}

[Test]
Expand All @@ -122,7 +122,7 @@ public async Task AvailableFreeSpace_ShouldBeSetTotalSize(long size)

IDriveInfo drive = FileSystem.GetDefaultDrive();

await That(drive.AvailableFreeSpace).IsEqualTo(size);
await That(drive).HasAvailableFreeSpace(size);
}

[Test]
Expand Down Expand Up @@ -220,7 +220,7 @@ public async Task SetDriveFormat_Default_ShouldBeNTFS()
FileSystem.WithDrive(d => d.SetDriveFormat());

IDriveInfo drive = FileSystem.GetDefaultDrive();
await That(drive.DriveFormat).IsEqualTo("NTFS");
await That(drive).HasDriveFormat("NTFS");
}

[Test]
Expand All @@ -230,7 +230,7 @@ public async Task SetDriveFormat_ShouldChangeDriveFormat(string driveFormat)
FileSystem.WithDrive(d => d.SetDriveFormat(driveFormat));

IDriveInfo drive = FileSystem.GetDefaultDrive();
await That(drive.DriveFormat).IsEqualTo(driveFormat);
await That(drive).HasDriveFormat(driveFormat);
}

[Test]
Expand All @@ -239,7 +239,7 @@ public async Task SetDriveType_Default_ShouldBeFixed()
FileSystem.WithDrive(d => d.SetDriveType());

IDriveInfo drive = FileSystem.GetDefaultDrive();
await That(drive.DriveType).IsEqualTo(DriveType.Fixed);
await That(drive).HasDriveType(DriveType.Fixed);
}

[Test]
Expand All @@ -249,7 +249,7 @@ public async Task SetDriveType_ShouldChangeDriveType(DriveType driveType)
FileSystem.WithDrive(d => d.SetDriveType(driveType));

IDriveInfo drive = FileSystem.GetDefaultDrive();
await That(drive.DriveType).IsEqualTo(driveType);
await That(drive).HasDriveType(driveType);
}

[Test]
Expand All @@ -270,6 +270,6 @@ public async Task SetTotalSize_Default_ShouldBe1Gigabyte()

IDriveInfo drive = FileSystem.GetDefaultDrive();

await That(drive.AvailableFreeSpace).IsEqualTo(1024 * 1024 * 1024);
await That(drive).HasAvailableFreeSpace(1024 * 1024 * 1024);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,21 @@ public async Task ShouldBePossibleToChainMethods(
IFileVersionInfo result = fileSystem.FileVersionInfo.GetVersionInfo("foo");

await That(result.Comments).IsEqualTo(comments);
await That(result.CompanyName).IsEqualTo(companyName);
await That(result.FileDescription).IsEqualTo(fileDescription);
await That(result.FileVersion).IsEqualTo(fileVersion);
await That(result).HasCompanyName(companyName);
await That(result).HasFileDescription(fileDescription);
await That(result).HasFileVersion(fileVersion);
await That(result.InternalName).IsEqualTo(internalName);
await That(result.IsDebug).IsEqualTo(isDebug);
await That(result.IsPatched).IsEqualTo(isPatched);
await That(result.IsPreRelease).IsEqualTo(isPreRelease);
await That(result.IsSpecialBuild).IsEqualTo(isSpecialBuild);
await That(result.Language).IsEqualTo(language);
await That(result).HasLanguage(language);
await That(result.LegalCopyright).IsEqualTo(legalCopyright);
await That(result.LegalTrademarks).IsEqualTo(legalTrademarks);
await That(result.OriginalFilename).IsEqualTo(originalFilename);
await That(result).HasOriginalFilename(originalFilename);
await That(result.PrivateBuild).IsEqualTo(privateBuild);
await That(result.ProductName).IsEqualTo(productName);
await That(result.ProductVersion).IsEqualTo(productVersion);
await That(result).HasProductName(productName);
await That(result).HasProductVersion(productVersion);
await That(result.SpecialBuild).IsEqualTo(specialBuild);
}

Expand All @@ -91,7 +91,7 @@ public async Task WithCompanyName_ShouldSetCompanyName(string? companyName)

IFileVersionInfo result = fileSystem.FileVersionInfo.GetVersionInfo("foo");

await That(result.CompanyName).IsEqualTo(companyName);
await That(result).HasCompanyName(companyName);
}

[Test]
Expand All @@ -104,7 +104,7 @@ public async Task WithFileDescription_ShouldSetFileDescription(string? fileDescr

IFileVersionInfo result = fileSystem.FileVersionInfo.GetVersionInfo("foo");

await That(result.FileDescription).IsEqualTo(fileDescription);
await That(result).HasFileDescription(fileDescription);
}

[Test]
Expand All @@ -123,7 +123,7 @@ public async Task WithFileVersion_ShouldSetFileVersion(
b => b.SetFileVersion("9.8.7.6").SetFileVersion(fileVersion));

IFileVersionInfo result = fileSystem.FileVersionInfo.GetVersionInfo("foo");
await That(result.FileVersion).IsEqualTo(fileVersion);
await That(result).HasFileVersion(fileVersion);
await That(result.FileMajorPart).IsEqualTo(fileMajorPart);
await That(result.FileMinorPart).IsEqualTo(fileMinorPart);
await That(result.FileBuildPart).IsEqualTo(fileBuildPart);
Expand Down Expand Up @@ -155,7 +155,7 @@ public async Task WithFileVersion_WhenContainsPreReleaseInfo_ShouldIgnorePreRele
fileSystem.WithFileVersionInfo("*", b => b.SetFileVersion(fileVersion));

IFileVersionInfo result = fileSystem.FileVersionInfo.GetVersionInfo("foo");
await That(result.FileVersion).IsEqualTo(fileVersion);
await That(result).HasFileVersion(fileVersion);
await That(result.FileMajorPart).IsEqualTo(fileMajorPart);
await That(result.FileMinorPart).IsEqualTo(fileMinorPart);
await That(result.FileBuildPart).IsEqualTo(fileBuildPart);
Expand All @@ -176,7 +176,7 @@ public async Task WithFileVersion_WhenStringIsInvalid_ShouldNotSetFileVersionPar
.SetFileVersion(fileVersion));

IFileVersionInfo result = fileSystem.FileVersionInfo.GetVersionInfo("foo");
await That(result.FileVersion).IsEqualTo(fileVersion);
await That(result).HasFileVersion(fileVersion);
await That(result.FileMajorPart).IsEqualTo(0);
await That(result.FileMinorPart).IsEqualTo(0);
await That(result.FileBuildPart).IsEqualTo(0);
Expand Down Expand Up @@ -271,7 +271,7 @@ public async Task WithLanguage_ShouldSetLanguage(string? language)

IFileVersionInfo result = fileSystem.FileVersionInfo.GetVersionInfo("foo");

await That(result.Language).IsEqualTo(language);
await That(result).HasLanguage(language);
}

[Test]
Expand Down Expand Up @@ -310,7 +310,7 @@ public async Task WithOriginalFilename_ShouldSetOriginalFilename(string? origina

IFileVersionInfo result = fileSystem.FileVersionInfo.GetVersionInfo("foo");

await That(result.OriginalFilename).IsEqualTo(originalFilename);
await That(result).HasOriginalFilename(originalFilename);
}

[Test]
Expand All @@ -336,7 +336,7 @@ public async Task WithProductName_ShouldSetProductName(string? productName)

IFileVersionInfo result = fileSystem.FileVersionInfo.GetVersionInfo("foo");

await That(result.ProductName).IsEqualTo(productName);
await That(result).HasProductName(productName);
}

[Test]
Expand All @@ -355,7 +355,7 @@ public async Task WithProductVersion_ShouldSetProductVersion(
b => b.SetProductVersion("9.8.7.6").SetProductVersion(productVersion));

IFileVersionInfo result = fileSystem.FileVersionInfo.GetVersionInfo("foo");
await That(result.ProductVersion).IsEqualTo(productVersion);
await That(result).HasProductVersion(productVersion);
await That(result.ProductMajorPart).IsEqualTo(fileMajorPart);
await That(result.ProductMinorPart).IsEqualTo(fileMinorPart);
await That(result.ProductBuildPart).IsEqualTo(fileBuildPart);
Expand Down Expand Up @@ -387,7 +387,7 @@ public async Task WithProductVersion_WhenContainsPreReleaseInfo_ShouldIgnorePreR
fileSystem.WithFileVersionInfo("*", b => b.SetProductVersion(productVersion));

IFileVersionInfo result = fileSystem.FileVersionInfo.GetVersionInfo("foo");
await That(result.ProductVersion).IsEqualTo(productVersion);
await That(result).HasProductVersion(productVersion);
await That(result.ProductMajorPart).IsEqualTo(fileMajorPart);
await That(result.ProductMinorPart).IsEqualTo(fileMinorPart);
await That(result.ProductBuildPart).IsEqualTo(fileBuildPart);
Expand All @@ -408,7 +408,7 @@ public async Task WithProductVersion_WhenStringIsInvalid_ShouldNotSetProductVers
.SetProductVersion(productVersion));

IFileVersionInfo result = fileSystem.FileVersionInfo.GetVersionInfo("foo");
await That(result.ProductVersion).IsEqualTo(productVersion);
await That(result).HasProductVersion(productVersion);
await That(result.ProductMajorPart).IsEqualTo(0);
await That(result.ProductMinorPart).IsEqualTo(0);
await That(result.ProductBuildPart).IsEqualTo(0);
Expand Down
32 changes: 13 additions & 19 deletions Tests/Testably.Abstractions.Testing.Tests/MockFileSystemTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ public async Task FileSystemMock_ShouldBeInitializedWithADefaultDrive()
IDriveInfo drive = sut.GetDefaultDrive();

await That(drives).IsNotEmpty();
await That(drive.Name).IsEqualTo(expectedDriveName);
await That(drive).HasName(expectedDriveName);
await That(drive.AvailableFreeSpace).IsGreaterThan(0);
await That(drive.DriveFormat).IsEqualTo(DriveInfoMock.DefaultDriveFormat);
await That(drive.DriveType).IsEqualTo(DriveInfoMock.DefaultDriveType);
await That(drive).HasDriveFormat(DriveInfoMock.DefaultDriveFormat);
await That(drive).HasDriveType(DriveInfoMock.DefaultDriveType);
await That(drive.VolumeLabel).IsNotNullOrEmpty();
}

Expand Down Expand Up @@ -188,11 +188,11 @@ public async Task WithDrive_Duplicate_ShouldUpdateExistingDrive(string driveName
await That(sut.DriveInfo.GetDrives().Length).IsEqualTo(2);
IDriveInfo drive = sut.DriveInfo.GetDrives()
.Single(x => string.Equals(x.Name, driveName, StringComparison.Ordinal));
await That(drive.TotalSize).IsEqualTo(100);
await That(drive).HasTotalSize(100);

sut.WithDrive(driveName, d => d.SetTotalSize(200));
await That(sut.DriveInfo.GetDrives().Length).IsEqualTo(2);
await That(drive.TotalSize).IsEqualTo(200);
await That(drive).HasTotalSize(200);
}

[Test]
Expand All @@ -202,11 +202,8 @@ public async Task WithDrive_ExistingName_ShouldUpdateDrive()
string driveName = "".PrefixRoot(sut);
sut.WithDrive(driveName);

IDriveInfo[] drives = sut.DriveInfo.GetDrives();

await That(drives.Length).IsGreaterThanOrEqualTo(1);
await That(drives).HasSingle()
.Matching(d => string.Equals(d.Name, driveName, StringComparison.Ordinal));
await That(sut.DriveInfo.GetDrives().Length).IsGreaterThanOrEqualTo(1);
await That(sut).HasDrive(driveName);
}

[Test]
Expand All @@ -218,11 +215,8 @@ public async Task WithDrive_NewName_ShouldCreateNewDrives(string driveName)
MockFileSystem sut = new();
sut.WithDrive(driveName);

IDriveInfo[] drives = sut.DriveInfo.GetDrives();

await That(drives.Length).IsEqualTo(2);
await That(drives).HasSingle()
.Matching(d => string.Equals(d.Name, driveName, StringComparison.Ordinal));
await That(sut.DriveInfo.GetDrives().Length).IsEqualTo(2);
await That(sut).HasDrive(driveName);
}

[Test]
Expand Down Expand Up @@ -266,9 +260,9 @@ public async Task WithDrive_WithCallback_ShouldUpdateDrive(long totalSize)

IDriveInfo drive = sut.GetDefaultDrive();

await That(drive.TotalSize).IsEqualTo(totalSize);
await That(drive.TotalFreeSpace).IsEqualTo(totalSize);
await That(drive.AvailableFreeSpace).IsEqualTo(totalSize);
await That(drive).HasTotalSize(totalSize);
await That(drive).HasTotalFreeSpace(totalSize);
await That(drive).HasAvailableFreeSpace(totalSize);
}

#if NET6_0_OR_GREATER
Expand Down Expand Up @@ -368,7 +362,7 @@ public async Task WithUncDrive_WriteBytes_ShouldReduceAvailableFreeSpace(

sut.File.WriteAllBytes(Path.Combine(uncDrive, path), bytes);

await That(drive.AvailableFreeSpace).IsEqualTo(previousFreeSpace - bytes.Length);
await That(drive).HasAvailableFreeSpace(previousFreeSpace - bytes.Length);
}

#if FEATURE_FILESYSTEM_UNIXFILEMODE
Expand Down
Loading
Loading