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 @@ -4,6 +4,7 @@
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="System.IO.FileSystem.AccessControl" Version="5.0.0" />
<PackageVersion Include="System.Text.Json" Version="9.0.2"/>
<PackageVersion Include="IsExternalInit" Version="1.0.3" />
<PackageVersion Include="Nullable" Version="1.3.1" />
<PackageVersion Include="Testably.Abstractions.FileSystem.Interface" Version="9.0.0" />
Expand All @@ -17,7 +18,6 @@
<PackageVersion Include="NUnit" Version="4.3.2" />
<PackageVersion Include="NUnit.Analyzers" Version="4.6.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="5.0.0" />
<PackageVersion Include="Snapshooter.NUnit" Version="1.0.1" />
<PackageVersion Include="PublicApiGenerator" Version="11.4.2"/>
<PackageVersion Include="aweXpect" Version="1.0.1"/>
</ItemGroup>
Expand Down
8 changes: 8 additions & 0 deletions System.IO.Abstractions.sln
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B66A0B3F-6A0
ProjectSection(SolutionItems) = preProject
src\Directory.Build.props = src\Directory.Build.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Benchmarks", "Benchmarks", "{10F39E91-97F2-4812-9D2F-79BE18EC6B08}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestableIO.System.IO.Abstractions.Api.Tests", "tests\TestableIO.System.IO.Abstractions.Api.Tests\TestableIO.System.IO.Abstractions.Api.Tests.csproj", "{7DE6AD74-E2B3-498E-90C5-DDF3188F333A}"
Expand All @@ -53,6 +54,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{5971F640
tests\Directory.Build.props = tests\Directory.Build.props
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestableIO.System.IO.Abstractions.Parity.Tests", "tests\TestableIO.System.IO.Abstractions.Parity.Tests\TestableIO.System.IO.Abstractions.Parity.Tests.csproj", "{93B79631-E220-414B-8F0D-3885825DE1AC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -95,6 +98,10 @@ Global
{7DE6AD74-E2B3-498E-90C5-DDF3188F333A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7DE6AD74-E2B3-498E-90C5-DDF3188F333A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7DE6AD74-E2B3-498E-90C5-DDF3188F333A}.Release|Any CPU.Build.0 = Release|Any CPU
{93B79631-E220-414B-8F0D-3885825DE1AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{93B79631-E220-414B-8F0D-3885825DE1AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{93B79631-E220-414B-8F0D-3885825DE1AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{93B79631-E220-414B-8F0D-3885825DE1AC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -111,6 +118,7 @@ Global
{015B3812-E01D-479C-895D-BDDF16E798CA} = {10F39E91-97F2-4812-9D2F-79BE18EC6B08}
{7DE6AD74-E2B3-498E-90C5-DDF3188F333A} = {BCEC61BD-4941-41EC-975A-ACEFC7AC1780}
{5971F640-8BBA-4264-BCD6-60A97DD54B4A} = {BBF7AD8D-5522-48C0-A906-00CBB72308A0}
{93B79631-E220-414B-8F0D-3885825DE1AC} = {BCEC61BD-4941-41EC-975A-ACEFC7AC1780}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8885C59C-F6A0-4C2F-A3BC-B720E9BD161F}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
using aweXpect;
using NUnit.Framework;
using Snapshooter;
using Snapshooter.NUnit;
using static System.Reflection.BindingFlags;

namespace System.IO.Abstractions.Tests
Expand All @@ -11,62 +12,62 @@ namespace System.IO.Abstractions.Tests
public class ApiParityTests
{
[Test]
public void File() =>
AssertParity(
public async Task File() =>
await AssertParity(
typeof(System.IO.File),
typeof(System.IO.Abstractions.FileBase)
);

[Test]
public void FileInfo() =>
AssertParity(
public async Task FileInfo() =>
await AssertParity(
typeof(System.IO.FileInfo),
typeof(System.IO.Abstractions.FileInfoBase)
);

[Test]
public void FileVersionInfo() =>
AssertParity(
public async Task FileVersionInfo() =>
await AssertParity(
typeof(System.Diagnostics.FileVersionInfo),
typeof(System.IO.Abstractions.FileVersionInfoBase)
);

[Test]
public void Directory() =>
AssertParity(
public async Task Directory() =>
await AssertParity(
typeof(System.IO.Directory),
typeof(System.IO.Abstractions.DirectoryBase)
);

[Test]
public void DirectoryInfo() =>
AssertParity(
public async Task DirectoryInfo() =>
await AssertParity(
typeof(System.IO.DirectoryInfo),
typeof(System.IO.Abstractions.DirectoryInfoBase)
);

[Test]
public void DriveInfo() =>
AssertParity(
public async Task DriveInfo() =>
await AssertParity(
typeof(System.IO.DriveInfo),
typeof(System.IO.Abstractions.DriveInfoBase)
);

[Test]
public void Path() =>
AssertParity(
public async Task Path() =>
await AssertParity(
typeof(System.IO.Path),
typeof(System.IO.Abstractions.PathBase)
);

[Test]
public void FileSystemWatcher() =>
AssertParity(
public async Task FileSystemWatcher() =>
await AssertParity(
typeof(System.IO.FileSystemWatcher),
typeof(System.IO.Abstractions.FileSystemWatcherBase)
);

private void AssertParity(Type referenceType, Type abstractionType)
private async Task AssertParity(Type referenceType, Type abstractionType)
{
static IEnumerable<string> GetMembers(Type type) => type
.GetMembers(bindingAttr: Instance | Static | Public | FlattenHierarchy)
Expand All @@ -89,9 +90,23 @@ static IEnumerable<string> GetMembers(Type type) => type
extraMembers: abstractionMembers.Except(referenceMembers),
missingMembers: referenceMembers.Except(abstractionMembers)
);
Snapshot.Match(diff, SnapshotNameExtension.Create(snapshotSuffix));

var serializedDiff = JsonSerializer.Serialize(diff, SerializerOptions);

var snapshotPath = IO.Path.GetFullPath("../../../__snapshots__/");
var fileName = $"ApiParityTests.{referenceType.Name}_{snapshotSuffix}.snap";
var fileContent = IO.File.ReadAllText(IO.Path.Combine(snapshotPath, fileName));

await Expect.That(fileContent).IsEqualTo(serializedDiff)
.IgnoringNewlineStyle()
.IgnoringTrailingWhiteSpace();
}

private static JsonSerializerOptions SerializerOptions = new()
{
WriteIndented = true
};

private readonly struct ApiDiff
{
public ApiDiff(IEnumerable<string> extraMembers, IEnumerable<string> missingMembers)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>The unit tests for our the parity checks</Description>
<AssemblyName>System.IO.Abstractions.Parity.Tests</AssemblyName>
<RootNamespace>System.IO.Abstractions.Parity.Tests</RootNamespace>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\TestableIO.System.IO.Abstractions.Wrappers\TestableIO.System.IO.Abstractions.Wrappers.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="aweXpect"/>
<PackageReference Include="System.Text.Json"/>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,4 @@
<ProjectReference Include="..\..\src\TestableIO.System.IO.Abstractions.Wrappers\TestableIO.System.IO.Abstractions.Wrappers.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Snapshooter.NUnit" />
</ItemGroup>

</Project>