Skip to content

Commit 606a486

Browse files
authored
refactor: use aweXpect in wrapper tests (#1234)
Use [aweXpect](https://awexpect.com) in `TestableIO.System.IO.Abstractions.Wrappers.Tests`
1 parent 09ca459 commit 606a486

18 files changed

+88
-99
lines changed

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<PackageVersion Include="NUnit3TestAdapter" Version="5.0.0" />
2121
<PackageVersion Include="PublicApiGenerator" Version="11.4.2"/>
2222
<PackageVersion Include="aweXpect" Version="1.6.0"/>
23+
<PackageVersion Include="aweXpect.Testably" Version="0.7.0"/>
2324
</ItemGroup>
2425
<ItemGroup>
2526
<PackageVersion Include="Nuke.Common" Version="9.0.4"/>

tests/Directory.Build.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
<PrivateAssets>all</PrivateAssets>
2525
</PackageReference>
2626
<PackageReference Include="NUnit3TestAdapter" />
27+
<PackageReference Include="aweXpect"/>
28+
<PackageReference Include="aweXpect.Testably"/>
2729
</ItemGroup>
2830

2931
<PropertyGroup>

tests/TestableIO.System.IO.Abstractions.Api.Tests/ApiAcceptance.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using aweXpect;
2-
3-
namespace TestableIO.System.IO.Abstractions.Api.Tests;
1+
namespace TestableIO.System.IO.Abstractions.Api.Tests;
42

53
public sealed class ApiAcceptance
64
{
@@ -27,6 +25,6 @@ public async Task AcceptApiChanges()
2725
}
2826
}
2927

30-
await Expect.That(assemblyNames).IsNotEmpty();
28+
await That(assemblyNames).IsNotEmpty();
3129
}
3230
}

tests/TestableIO.System.IO.Abstractions.Api.Tests/ApiApprovalTests.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Collections.Generic;
2-
using aweXpect;
32

43
namespace TestableIO.System.IO.Abstractions.Api.Tests;
54

@@ -18,7 +17,7 @@ public async Task VerifyPublicApiForWrappers(string framework)
1817
var publicApi = Helper.CreatePublicApi(framework, assemblyName);
1918
var expectedApi = Helper.GetExpectedApi(framework, assemblyName);
2019

21-
await Expect.That(publicApi).IsEqualTo(expectedApi);
20+
await That(publicApi).IsEqualTo(expectedApi);
2221
}
2322

2423
[TestCaseSource(nameof(TargetFrameworksTheoryData))]
@@ -29,7 +28,7 @@ public async Task VerifyPublicApiForTestingHelpers(string framework)
2928
var publicApi = Helper.CreatePublicApi(framework, assemblyName);
3029
var expectedApi = Helper.GetExpectedApi(framework, assemblyName);
3130

32-
await Expect.That(publicApi).IsEqualTo(expectedApi);
31+
await That(publicApi).IsEqualTo(expectedApi);
3332
}
3433

3534
private static IEnumerable<string> TargetFrameworksTheoryData()

tests/TestableIO.System.IO.Abstractions.Api.Tests/TestableIO.System.IO.Abstractions.Api.Tests.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
<ItemGroup>
1313
<PackageReference Include="PublicApiGenerator"/>
14-
<PackageReference Include="aweXpect"/>
1514
</ItemGroup>
1615

1716
<ItemGroup>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
global using System;
22
global using System.Threading.Tasks;
33
global using NUnit.Framework;
4+
global using aweXpect;
5+
global using static aweXpect.Expect;

tests/TestableIO.System.IO.Abstractions.Parity.Tests/ApiParityTests.cs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Text.Json;
44
using System.Threading.Tasks;
55
using aweXpect;
6+
using static aweXpect.Expect;
67
using NUnit.Framework;
78
using static System.Reflection.BindingFlags;
89

@@ -14,57 +15,57 @@ public class ApiParityTests
1415
[Test]
1516
public async Task File() =>
1617
await AssertParity(
17-
typeof(System.IO.File),
18-
typeof(System.IO.Abstractions.FileBase)
18+
typeof(File),
19+
typeof(FileBase)
1920
);
2021

2122
[Test]
2223
public async Task FileInfo() =>
2324
await AssertParity(
24-
typeof(System.IO.FileInfo),
25-
typeof(System.IO.Abstractions.FileInfoBase)
25+
typeof(FileInfo),
26+
typeof(FileInfoBase)
2627
);
2728

2829
[Test]
2930
public async Task FileVersionInfo() =>
3031
await AssertParity(
31-
typeof(System.Diagnostics.FileVersionInfo),
32-
typeof(System.IO.Abstractions.FileVersionInfoBase)
32+
typeof(Diagnostics.FileVersionInfo),
33+
typeof(FileVersionInfoBase)
3334
);
3435

3536
[Test]
3637
public async Task Directory() =>
3738
await AssertParity(
38-
typeof(System.IO.Directory),
39-
typeof(System.IO.Abstractions.DirectoryBase)
39+
typeof(Directory),
40+
typeof(DirectoryBase)
4041
);
4142

4243
[Test]
4344
public async Task DirectoryInfo() =>
4445
await AssertParity(
45-
typeof(System.IO.DirectoryInfo),
46-
typeof(System.IO.Abstractions.DirectoryInfoBase)
46+
typeof(DirectoryInfo),
47+
typeof(DirectoryInfoBase)
4748
);
4849

4950
[Test]
5051
public async Task DriveInfo() =>
5152
await AssertParity(
52-
typeof(System.IO.DriveInfo),
53-
typeof(System.IO.Abstractions.DriveInfoBase)
53+
typeof(DriveInfo),
54+
typeof(DriveInfoBase)
5455
);
5556

5657
[Test]
5758
public async Task Path() =>
5859
await AssertParity(
59-
typeof(System.IO.Path),
60-
typeof(System.IO.Abstractions.PathBase)
60+
typeof(Path),
61+
typeof(PathBase)
6162
);
6263

6364
[Test]
6465
public async Task FileSystemWatcher() =>
6566
await AssertParity(
66-
typeof(System.IO.FileSystemWatcher),
67-
typeof(System.IO.Abstractions.FileSystemWatcherBase)
67+
typeof(FileSystemWatcher),
68+
typeof(FileSystemWatcherBase)
6869
);
6970

7071
private async Task AssertParity(Type referenceType, Type abstractionType)
@@ -97,7 +98,7 @@ static IEnumerable<string> GetMembers(Type type) => type
9798
var fileName = $"ApiParityTests.{referenceType.Name}_{snapshotSuffix}.snap";
9899
var fileContent = IO.File.ReadAllText(IO.Path.Combine(snapshotPath, fileName));
99100

100-
await Expect.That(fileContent).IsEqualTo(serializedDiff)
101+
await That(fileContent).IsEqualTo(serializedDiff)
101102
.IgnoringNewlineStyle()
102103
.IgnoringTrailingWhiteSpace();
103104
}

tests/TestableIO.System.IO.Abstractions.Parity.Tests/TestableIO.System.IO.Abstractions.Parity.Tests.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
</ItemGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="aweXpect"/>
1514
<PackageReference Include="System.Text.Json"/>
1615
</ItemGroup>
1716

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
using NUnit.Framework;
2-
3-
namespace System.IO.Abstractions.Tests
1+
namespace System.IO.Abstractions.Tests
42
{
53
[TestFixture]
64
public class DirectoryInfoFactoryTests
75
{
86
[Test]
9-
public void Wrap_WithNull_ShouldReturnNull()
7+
public async Task Wrap_WithNull_ShouldReturnNull()
108
{
119
var fileSystem = new FileSystem();
1210

1311
var result = fileSystem.DirectoryInfo.Wrap(null);
14-
15-
Assert.That(result, Is.Null);
12+
13+
await That(result).IsNull();
1614
}
1715
}
1816
}
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
using NUnit.Framework;
2-
3-
namespace System.IO.Abstractions.Tests
1+
namespace System.IO.Abstractions.Tests
42
{
53
[TestFixture]
64
public class DirectoryInfoTests
75
{
86
[Test]
9-
public void Parent_ForRootDirectory_ShouldReturnNull()
7+
public async Task Parent_ForRootDirectory_ShouldReturnNull()
108
{
119
var wrapperFilesystem = new FileSystem();
1210

1311
var current = wrapperFilesystem.Directory.GetCurrentDirectory();
1412
var root = wrapperFilesystem.DirectoryInfo.New(current).Root;
1513
var rootsParent = root.Parent;
16-
Assert.That(rootsParent, Is.Null);
14+
15+
await That(rootsParent).IsNull();
1716
}
1817
}
1918
}

0 commit comments

Comments
 (0)