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
Expand Up @@ -75,6 +75,7 @@ async Task Act()
}

await That(Act).Throws<ArgumentException>()
.WithMessage("The unexpected file attributes must include at least one flag.*").AsWildcard().And
.WithParamName("unexpected");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ async Task Act()
}

await That(Act).Throws<ArgumentException>()
.WithMessage("The expected file attributes must include at least one flag.*").AsWildcard().And
.WithParamName("expected");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,28 @@ async Task Act()

await That(Act).DoesNotThrow();
}

[Fact]
public async Task WhenNegatedAndCreationTimeMatches_ShouldFail()
{
MockFileSystem fileSystem = new();
DateTime expected = CurrentTime().ToUniversalTime();
fileSystem.Directory.CreateDirectory("foo");
fileSystem.Directory.SetCreationTimeUtc("foo", expected);
IDirectoryInfo dirInfo = fileSystem.DirectoryInfo.New("foo");

async Task Act()
{
await That(dirInfo).DoesNotComplyWith(d => d.HasCreationTime(expected));
}

await That(Act).ThrowsException()
.WithMessage($"""
Expected that dirInfo
does not have creation time equal to {Formatter.Format(expected)},
but it was {Formatter.Format(expected)}
""");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,28 @@ async Task Act()

await That(Act).DoesNotThrow();
}

[Fact]
public async Task WhenNegatedAndLastAccessTimeMatches_ShouldFail()
{
MockFileSystem fileSystem = new();
DateTime expected = CurrentTime().ToUniversalTime();
fileSystem.Directory.CreateDirectory("foo");
fileSystem.Directory.SetLastAccessTimeUtc("foo", expected);
IDirectoryInfo dirInfo = fileSystem.DirectoryInfo.New("foo");

async Task Act()
{
await That(dirInfo).DoesNotComplyWith(d => d.HasLastAccessTime(expected));
}

await That(Act).ThrowsException()
.WithMessage($"""
Expected that dirInfo
does not have last access time equal to {Formatter.Format(expected)},
but it was {Formatter.Format(expected)}
""");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,28 @@ async Task Act()

await That(Act).DoesNotThrow();
}

[Fact]
public async Task WhenNegatedAndLastWriteTimeMatches_ShouldFail()
{
MockFileSystem fileSystem = new();
DateTime expected = CurrentTime().ToUniversalTime();
fileSystem.Directory.CreateDirectory("foo");
fileSystem.Directory.SetLastWriteTimeUtc("foo", expected);
IDirectoryInfo dirInfo = fileSystem.DirectoryInfo.New("foo");

async Task Act()
{
await That(dirInfo).DoesNotComplyWith(d => d.HasLastWriteTime(expected));
}

await That(Act).ThrowsException()
.WithMessage($"""
Expected that dirInfo
does not have last write time equal to {Formatter.Format(expected)},
but it was {Formatter.Format(expected)}
""");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ async Task Act()
await That(rootDirInfo).WhoseParent.IsNotEmpty();
}

await That(Act).Throws<InvalidOperationException>();
await That(Act).Throws<InvalidOperationException>()
.WithMessage("Cannot assert on the parent of a root directory because it has no parent.");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ async Task Act()
}

await That(Act).Throws<ArgumentException>()
.WithMessage("The unexpected file attributes must include at least one flag.*").AsWildcard().And
.WithParamName("unexpected");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ async Task Act()
}

await That(Act).Throws<ArgumentException>()
.WithMessage("The expected file attributes must include at least one flag.*").AsWildcard().And
.WithParamName("expected");
}
}
Expand Down
23 changes: 23 additions & 0 deletions Tests/aweXpect.Testably.Tests/FileInfo.HasCreationTime.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,29 @@ async Task Act()

await That(Act).DoesNotThrow();
}

[Fact]
public async Task WhenNegatedAndCreationTimeMatches_ShouldFail()
{
MockFileSystem fileSystem = new();
DateTime expected = CurrentTime().ToUniversalTime();
string path = "foo.txt";
fileSystem.File.WriteAllText(path, "");
fileSystem.File.SetCreationTimeUtc(path, expected);
IFileInfo fileInfo = fileSystem.FileInfo.New(path);

async Task Act()
{
await That(fileInfo).DoesNotComplyWith(f => f.HasCreationTime(expected));
}

await That(Act).ThrowsException()
.WithMessage($"""
Expected that fileInfo
does not have creation time equal to {Formatter.Format(expected)},
but it was {Formatter.Format(expected)}
""");
}
}
}
}
21 changes: 21 additions & 0 deletions Tests/aweXpect.Testably.Tests/FileInfo.HasExtension.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,27 @@ async Task Act()

await That(Act).DoesNotThrow();
}

[Fact]
public async Task WhenNegatedAndExtensionMatches_ShouldFail()
{
MockFileSystem fileSystem = new();
// ReSharper disable once MethodHasAsyncOverload
fileSystem.File.WriteAllText("foo.txt", "");
IFileInfo fileInfo = fileSystem.FileInfo.New("foo.txt");

async Task Act()
{
await That(fileInfo).DoesNotComplyWith(f => f.HasExtension(".txt"));
}

await That(Act).ThrowsException()
.WithMessage("""
Expected that fileInfo
does not have extension not equal to ".txt",
but it did
""");
}
}
}
}
23 changes: 23 additions & 0 deletions Tests/aweXpect.Testably.Tests/FileInfo.HasLastAccessTime.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,29 @@ async Task Act()

await That(Act).DoesNotThrow();
}

[Fact]
public async Task WhenNegatedAndLastAccessTimeMatches_ShouldFail()
{
MockFileSystem fileSystem = new();
DateTime expected = CurrentTime().ToUniversalTime();
string path = "foo.txt";
fileSystem.File.WriteAllText(path, "");
fileSystem.File.SetLastAccessTimeUtc(path, expected);
IFileInfo fileInfo = fileSystem.FileInfo.New(path);

async Task Act()
{
await That(fileInfo).DoesNotComplyWith(f => f.HasLastAccessTime(expected));
}

await That(Act).ThrowsException()
.WithMessage($"""
Expected that fileInfo
does not have last access time equal to {Formatter.Format(expected)},
but it was {Formatter.Format(expected)}
""");
}
}
}
}
23 changes: 23 additions & 0 deletions Tests/aweXpect.Testably.Tests/FileInfo.HasLastWriteTime.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,29 @@ async Task Act()

await That(Act).DoesNotThrow();
}

[Fact]
public async Task WhenNegatedAndLastWriteTimeMatches_ShouldFail()
{
MockFileSystem fileSystem = new();
DateTime expected = CurrentTime().ToUniversalTime();
string path = "foo.txt";
fileSystem.File.WriteAllText(path, "");
fileSystem.File.SetLastWriteTimeUtc(path, expected);
IFileInfo fileInfo = fileSystem.FileInfo.New(path);

async Task Act()
{
await That(fileInfo).DoesNotComplyWith(f => f.HasLastWriteTime(expected));
}

await That(Act).ThrowsException()
.WithMessage($"""
Expected that fileInfo
does not have last write time equal to {Formatter.Format(expected)},
but it was {Formatter.Format(expected)}
""");
}
}
}
}
Loading