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
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#if NET8_0_OR_GREATER
using System.IO.Abstractions;
using Testably.Abstractions.Testing;

namespace aweXpect.Testably.Tests;

public sealed partial class DriveInfo
{
public sealed class DoesNotComplyWithIsReady
{
public sealed class Tests
{
[Fact]
public async Task WhenDriveIsReady_ShouldFail()
{
MockFileSystem fileSystem = new(o => o.SimulatingOperatingSystem(SimulationMode.Windows));
fileSystem.WithDrive("D:", d => d.SetIsReady(true));
IDriveInfo driveInfo = fileSystem.DriveInfo.New("D:");

async Task Act()
{
await That(driveInfo).DoesNotComplyWith(d => d.IsReady());
}

await That(Act).ThrowsException()
.WithMessage("""
Expected that driveInfo
is not ready,
but it was
""");
}
}
}
}

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#if NET8_0_OR_GREATER
using System.IO.Abstractions;
using Testably.Abstractions.Testing;

namespace aweXpect.Testably.Tests;

public sealed partial class DriveInfo
{
public sealed class DoesNotHaveAvailableFreeSpace
{
public sealed class Tests
{
[Fact]
public async Task WhenAvailableFreeSpaceMatches_ShouldFail()
{
MockFileSystem fileSystem = new(o => o.SimulatingOperatingSystem(SimulationMode.Windows));
fileSystem.WithDrive("D:", d => d.SetTotalSize(2048));
IDriveInfo driveInfo = fileSystem.DriveInfo.New("D:");

async Task Act()
{
await That(driveInfo).DoesNotComplyWith(d => d.HasAvailableFreeSpace(2048));
}

await That(Act).ThrowsException()
.WithMessage("""
Expected that driveInfo
does not have available free space 2048,
but it did
""");
}
}
}
}

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#if NET8_0_OR_GREATER
using System.IO.Abstractions;
using Testably.Abstractions.Testing;

namespace aweXpect.Testably.Tests;

public sealed partial class DriveInfo
{
public sealed class DoesNotHaveDriveFormat
{
public sealed class Tests
{
[Fact]
public async Task WhenDriveFormatMatches_ShouldFail()
{
MockFileSystem fileSystem = new(o => o.SimulatingOperatingSystem(SimulationMode.Windows));
fileSystem.WithDrive("D:", d => d.SetDriveFormat("NTFS"));
IDriveInfo driveInfo = fileSystem.DriveInfo.New("D:");

async Task Act()
{
await That(driveInfo).DoesNotComplyWith(d => d.HasDriveFormat("NTFS"));
}

await That(Act).ThrowsException()
.WithMessage("""
Expected that driveInfo
does not have drive format not equal to "NTFS",
but it did
""");
}
}
}
}

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#if NET8_0_OR_GREATER
using System.IO;
using System.IO.Abstractions;
using Testably.Abstractions.Testing;

namespace aweXpect.Testably.Tests;

public sealed partial class DriveInfo
{
public sealed class DoesNotHaveDriveType
{
public sealed class Tests
{
[Fact]
public async Task WhenDriveTypeMatches_ShouldFail()
{
MockFileSystem fileSystem = new(o => o.SimulatingOperatingSystem(SimulationMode.Windows));
fileSystem.WithDrive("D:", d => d.SetDriveType(DriveType.Fixed));
IDriveInfo driveInfo = fileSystem.DriveInfo.New("D:");

async Task Act()
{
await That(driveInfo).DoesNotComplyWith(d => d.HasDriveType(DriveType.Fixed));
}

await That(Act).ThrowsException()
.WithMessage("""
Expected that driveInfo
does not have drive type Fixed,
but it did
""");
}
}
}
}

#endif
36 changes: 36 additions & 0 deletions Tests/aweXpect.Testably.Tests/DriveInfo.DoesNotHaveName.Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#if NET8_0_OR_GREATER
using System.IO.Abstractions;
using Testably.Abstractions.Testing;

namespace aweXpect.Testably.Tests;

public sealed partial class DriveInfo
{
public sealed class DoesNotHaveName
{
public sealed class Tests
{
[Fact]
public async Task WhenNameMatches_ShouldFail()
{
MockFileSystem fileSystem = new(o => o.SimulatingOperatingSystem(SimulationMode.Windows));
fileSystem.WithDrive("D:");
IDriveInfo driveInfo = fileSystem.DriveInfo.New("D:");

async Task Act()
{
await That(driveInfo).DoesNotComplyWith(d => d.HasName(driveInfo.Name));
}

await That(Act).ThrowsException()
.WithMessage("""
Expected that driveInfo
does not have name not equal to "D:\",
but it did
""");
}
}
}
}

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#if NET8_0_OR_GREATER
using System.IO.Abstractions;
using Testably.Abstractions.Testing;

namespace aweXpect.Testably.Tests;

public sealed partial class DriveInfo
{
public sealed class DoesNotHaveTotalFreeSpace
{
public sealed class Tests
{
[Fact]
public async Task WhenTotalFreeSpaceMatches_ShouldFail()
{
MockFileSystem fileSystem = new(o => o.SimulatingOperatingSystem(SimulationMode.Windows));
fileSystem.WithDrive("D:", d => d.SetTotalSize(2048));
IDriveInfo driveInfo = fileSystem.DriveInfo.New("D:");

async Task Act()
{
await That(driveInfo).DoesNotComplyWith(d => d.HasTotalFreeSpace(2048));
}

await That(Act).ThrowsException()
.WithMessage("""
Expected that driveInfo
does not have total free space 2048,
but it did
""");
}
}
}
}

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#if NET8_0_OR_GREATER
using System.IO.Abstractions;
using Testably.Abstractions.Testing;

namespace aweXpect.Testably.Tests;

public sealed partial class DriveInfo
{
public sealed class DoesNotHaveTotalSize
{
public sealed class Tests
{
[Fact]
public async Task WhenTotalSizeMatches_ShouldFail()
{
MockFileSystem fileSystem = new(o => o.SimulatingOperatingSystem(SimulationMode.Windows));
fileSystem.WithDrive("D:", d => d.SetTotalSize(2048));
IDriveInfo driveInfo = fileSystem.DriveInfo.New("D:");

async Task Act()
{
await That(driveInfo).DoesNotComplyWith(d => d.HasTotalSize(2048));
}

await That(Act).ThrowsException()
.WithMessage("""
Expected that driveInfo
does not have total size 2048,
but it did
""");
}
}
}
}

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#if NET8_0_OR_GREATER
using System.IO.Abstractions;
using Testably.Abstractions.Testing;

namespace aweXpect.Testably.Tests;

public sealed partial class DriveInfo
{
public sealed class DoesNotHaveVolumeLabel
{
public sealed class Tests
{
[Fact]
public async Task WhenVolumeLabelMatches_ShouldFail()
{
MockFileSystem fileSystem = new(o => o.SimulatingOperatingSystem(SimulationMode.Windows));
IDriveInfo driveInfo = fileSystem.DriveInfo.New("C:");
string actualLabel = driveInfo.VolumeLabel;

async Task Act()
{
await That(driveInfo).DoesNotComplyWith(d => d.HasVolumeLabel(actualLabel));
}

await That(Act).ThrowsException()
.WithMessage($"""
Expected that driveInfo
does not have volume label not equal to "{actualLabel}",
but it did
""");
}
}
}
}

#endif
11 changes: 10 additions & 1 deletion Tests/aweXpect.Testably.Tests/DriveInfo.HasName.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@ async Task Act()
await That(driveInfo).HasName("Z:\\");
}

await That(Act).ThrowsException();
await That(Act).ThrowsException()
.WithMessage("""
Expected that driveInfo
has name equal to "Z:\",
but it was "D:\" which differs at index 0:
↓ (actual)
"D:\"
"Z:\"
↑ (expected)
""");
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ async Task Act()
await That(driveInfo).HasVolumeLabel("definitely-not-the-label");
}

await That(Act).ThrowsException();
await That(Act).ThrowsException()
.WithMessage("""
Expected that driveInfo
has volume label equal to "definitely-not-the-label",
but it was *
""").AsWildcard();
}

[Fact]
Expand Down
Loading