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.13.0"/>
<PackageVersion Include="aweXpect.Testably" Version="0.14.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 @@ -54,8 +54,7 @@ public async Task With_FileDescription_WithBytes_ShouldCreateFileContent(string
sut.With(description);

await That(fileSystem.Statistics.TotalCount).IsEqualTo(0);
await That(fileSystem.File.Exists(name)).IsTrue();
await That(fileSystem.File.ReadAllBytes(name)).IsEqualTo(bytes);
await That(fileSystem).HasFile(name).WithContent(bytes);
}

[Test]
Expand All @@ -70,8 +69,7 @@ public async Task With_FileDescription_WithContent_ShouldCreateFileContent(strin
sut.With(description);

await That(fileSystem.Statistics.TotalCount).IsEqualTo(0);
await That(fileSystem.File.Exists(name)).IsTrue();
await That(fileSystem.File.ReadAllText(name)).IsEqualTo(content);
await That(fileSystem).HasFile(name).WithContent(content);
}

[Test]
Expand Down Expand Up @@ -105,8 +103,14 @@ public async Task With_FileDescriptions_ShouldSetIsReadOnlyFlag(bool isReadOnly,
sut.With(description);

await That(fileSystem.Statistics.TotalCount).IsEqualTo(0);
await That(fileSystem.File.Exists(name)).IsTrue();
await That(fileSystem.FileInfo.New(name).IsReadOnly).IsEqualTo(isReadOnly);
if (isReadOnly)
{
await That(fileSystem).HasFile(name).Which.IsReadOnly();
}
else
{
await That(fileSystem).HasFile(name).Which.IsNotReadOnly();
}
}

[Test]
Expand Down Expand Up @@ -204,8 +208,7 @@ public async Task WithFile_HasStringContent_ShouldWriteFileContent(string path)
sut.WithFile(path).Which(f => f.HasStringContent("foo"));

await That(fileSystem.Statistics.TotalCount).IsEqualTo(0);
await That(fileSystem.File.Exists(path)).IsTrue();
await That(fileSystem.File.ReadAllText(path)).IsEqualTo("foo");
await That(fileSystem).HasFile(path).WithContent("foo");
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using aweXpect.Testably;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Testably.Abstractions.Testing.Initializer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
global using Test = Testably.Abstractions.Testing.Tests.TestHelpers.Test;
global using TUnit;
global using aweXpect;
global using aweXpect.Testably;
global using static aweXpect.Expect;
global using Skip = Testably.Abstractions.TestHelpers.Skip;
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ await FileSystem.File.AppendAllBytesAsync(path, previousBytes,
await FileSystem.File.AppendAllBytesAsync(path, bytes,
CancellationToken);

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo([..previousBytes, ..bytes]);
await That(FileSystem).HasFile(path).WithContent([..previousBytes, ..bytes]);
}

[Test]
Expand All @@ -61,8 +60,7 @@ public async Task AppendAllBytesAsync_MissingFile_ShouldCreateFile(
await FileSystem.File.AppendAllBytesAsync(path, bytes,
CancellationToken);

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo(bytes);
await That(FileSystem).HasFile(path).WithContent(bytes);
}

[Test]
Expand Down Expand Up @@ -90,8 +88,7 @@ await FileSystem.File.AppendAllBytesAsync(path, previousBytes,
await FileSystem.File.AppendAllBytesAsync(path, bytes.AsMemory(),
CancellationToken);

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo([..previousBytes, ..bytes]);
await That(FileSystem).HasFile(path).WithContent([..previousBytes, ..bytes]);
}

[Test]
Expand Down Expand Up @@ -119,8 +116,7 @@ public async Task AppendAllBytesAsync_ReadOnlyMemory_MissingFile_ShouldCreateFil
await FileSystem.File.AppendAllBytesAsync(path, bytes.AsMemory(),
CancellationToken);

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo(bytes);
await That(FileSystem).HasFile(path).WithContent(bytes);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ public async Task AppendAllBytes_ExistingFile_ShouldAppendLinesToFile(

FileSystem.File.AppendAllBytes(path, bytes);

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo([..previousBytes, ..bytes]);
await That(FileSystem).HasFile(path).WithContent([..previousBytes, ..bytes]);
}

[Test]
Expand All @@ -40,8 +39,7 @@ public async Task AppendAllBytes_MissingFile_ShouldCreateFile(
{
FileSystem.File.AppendAllBytes(path, bytes);

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo(bytes);
await That(FileSystem).HasFile(path).WithContent(bytes);
}

[Test]
Expand Down Expand Up @@ -84,8 +82,7 @@ public async Task AppendAllBytes_Span_ExistingFile_ShouldAppendLinesToFile(

FileSystem.File.AppendAllBytes(path, bytes.AsSpan());

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo([..previousBytes, ..bytes]);
await That(FileSystem).HasFile(path).WithContent([..previousBytes, ..bytes]);
}

[Test]
Expand All @@ -109,8 +106,7 @@ public async Task AppendAllBytes_Span_MissingFile_ShouldCreateFile(
{
FileSystem.File.AppendAllBytes(path, bytes.AsSpan());

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo(bytes);
await That(FileSystem).HasFile(path).WithContent(bytes);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ await FileSystem.File.AppendAllLinesAsync(path, previousContents,
await FileSystem.File.AppendAllLinesAsync(path, contents,
CancellationToken);

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllText(path)).IsEqualTo(expectedContent);
await That(FileSystem).HasFile(path).WithContent(expectedContent);
}

[Test]
Expand Down Expand Up @@ -100,8 +99,7 @@ public async Task AppendAllLinesAsync_MissingFile_ShouldCreateFile(
await FileSystem.File.AppendAllLinesAsync(path, contents,
CancellationToken);

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllText(path)).IsEqualTo(expectedContent);
await That(FileSystem).HasFile(path).WithContent(expectedContent);
}

[Test]
Expand Down Expand Up @@ -146,8 +144,7 @@ public async Task AppendAllLinesAsync_ShouldEndWithNewline(string path)
await FileSystem.File.AppendAllLinesAsync(path, contents,
CancellationToken);

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllText(path)).IsEqualTo(expectedResult);
await That(FileSystem).HasFile(path).WithContent(expectedResult);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public async Task AppendAllLines_ExistingFile_ShouldAppendLinesToFile(

FileSystem.File.AppendAllLines(path, contents);

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllText(path)).IsEqualTo(expectedContent);
await That(FileSystem).HasFile(path).WithContent(expectedContent);
}

[Test]
Expand All @@ -45,8 +44,7 @@ public async Task AppendAllLines_MissingFile_ShouldCreateFile(
+ Environment.NewLine;
FileSystem.File.AppendAllLines(path, contents);

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllText(path)).IsEqualTo(expectedContent);
await That(FileSystem).HasFile(path).WithContent(expectedContent);
}

[Test]
Expand Down Expand Up @@ -88,8 +86,7 @@ public async Task AppendAllLines_ShouldEndWithNewline(string path)

FileSystem.File.AppendAllLines(path, contents);

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllText(path)).IsEqualTo(expectedResult);
await That(FileSystem).HasFile(path).WithContent(expectedResult);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ await FileSystem.File.AppendAllTextAsync(path, previousContents,
await FileSystem.File.AppendAllTextAsync(path, contents,
CancellationToken);

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllText(path)).IsEqualTo(previousContents + contents);
await That(FileSystem).HasFile(path).WithContent(previousContents + contents);
}

[Test]
Expand All @@ -78,8 +77,7 @@ public async Task AppendAllTextAsync_MissingFile_ShouldCreateFile(
await FileSystem.File.AppendAllTextAsync(path, contents,
CancellationToken);

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllText(path)).IsEqualTo(contents);
await That(FileSystem).HasFile(path).WithContent(contents);
}

[Test]
Expand All @@ -91,8 +89,7 @@ public async Task AppendAllTextAsync_ShouldNotEndWithNewline(string path)
await FileSystem.File.AppendAllTextAsync(path, contents,
CancellationToken);

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllText(path)).IsEqualTo(contents);
await That(FileSystem).HasFile(path).WithContent(contents);
}

[Test]
Expand Down Expand Up @@ -183,8 +180,7 @@ await FileSystem.File.AppendAllTextAsync(path, previousContents,
await FileSystem.File.AppendAllTextAsync(path, contents.AsMemory(),
CancellationToken);

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllText(path)).IsEqualTo(previousContents + contents);
await That(FileSystem).HasFile(path).WithContent(previousContents + contents);
}

[Test]
Expand Down Expand Up @@ -212,8 +208,7 @@ public async Task AppendAllTextAsync_ReadOnlyMemory_MissingFile_ShouldCreateFile
await FileSystem.File.AppendAllTextAsync(path, contents.AsMemory(),
CancellationToken);

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllText(path)).IsEqualTo(contents);
await That(FileSystem).HasFile(path).WithContent(contents);
}

[Test]
Expand All @@ -225,8 +220,7 @@ public async Task AppendAllTextAsync_ReadOnlyMemory_ShouldNotEndWithNewline(stri
await FileSystem.File.AppendAllTextAsync(path, contents.AsMemory(),
CancellationToken);

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllText(path)).IsEqualTo(contents);
await That(FileSystem).HasFile(path).WithContent(contents);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ public async Task AppendAllText_ExistingFile_ShouldAppendLinesToFile(

FileSystem.File.AppendAllText(path, contents);

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllText(path)).IsEqualTo(previousContents + contents);
await That(FileSystem).HasFile(path).WithContent(previousContents + contents);
}

[Test]
Expand All @@ -42,8 +41,7 @@ public async Task AppendAllText_MissingFile_ShouldCreateFile(
{
FileSystem.File.AppendAllText(path, contents);

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllText(path)).IsEqualTo(contents);
await That(FileSystem).HasFile(path).WithContent(contents);
}

[Test]
Expand All @@ -55,8 +53,7 @@ public async Task AppendAllText_MissingFile_ShouldCreateFileWithByteOrderMark(

FileSystem.File.AppendAllText(path, "AA", Encoding.UTF32);

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo(expectedBytes);
await That(FileSystem).HasFile(path).WithContent(expectedBytes);
}

[Test]
Expand Down Expand Up @@ -100,8 +97,7 @@ public async Task AppendAllText_ShouldNotEndWithNewline(string path)

FileSystem.File.AppendAllText(path, contents);

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllText(path)).IsEqualTo(contents);
await That(FileSystem).HasFile(path).WithContent(contents);
}

[Test]
Expand Down Expand Up @@ -175,8 +171,7 @@ public async Task AppendAllText_Span_ExistingFile_ShouldAppendLinesToFile(

FileSystem.File.AppendAllText(path, contents.AsSpan());

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllText(path)).IsEqualTo(previousContents + contents);
await That(FileSystem).HasFile(path).WithContent(previousContents + contents);
}

[Test]
Expand All @@ -201,8 +196,7 @@ public async Task AppendAllText_Span_MissingFile_ShouldCreateFile(
{
FileSystem.File.AppendAllText(path, contents.AsSpan());

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllText(path)).IsEqualTo(contents);
await That(FileSystem).HasFile(path).WithContent(contents);
}

[Test]
Expand All @@ -214,8 +208,7 @@ public async Task AppendAllText_Span_MissingFile_ShouldCreateFileWithByteOrderMa

FileSystem.File.AppendAllText(path, "AA".AsSpan(), Encoding.UTF32);

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo(expectedBytes);
await That(FileSystem).HasFile(path).WithContent(expectedBytes);
}

[Test]
Expand Down Expand Up @@ -259,8 +252,7 @@ public async Task AppendAllText_Span_ShouldNotEndWithNewline(string path)

FileSystem.File.AppendAllText(path, contents.AsSpan());

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllText(path)).IsEqualTo(contents);
await That(FileSystem).HasFile(path).WithContent(contents);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ public async Task AppendText_MissingFile_ShouldCreateFile(
stream.Write(appendText);
}

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllText(path)).IsEqualTo(appendText);
await That(FileSystem).HasFile(path).WithContent(appendText);
}

[Test]
Expand All @@ -31,7 +30,6 @@ public async Task AppendText_ShouldAddTextToExistingFile(
stream.Write(appendText);
}

await That(FileSystem.File.Exists(path)).IsTrue();
await That(FileSystem.File.ReadAllText(path)).IsEqualTo(contents + appendText);
await That(FileSystem).HasFile(path).WithContent(contents + appendText);
}
}
Loading
Loading