11using System . Collections . Generic ;
22using System . Linq ;
3+ using System . Text . Json ;
4+ using System . Threading . Tasks ;
5+ using aweXpect ;
36using NUnit . Framework ;
4- using Snapshooter ;
5- using Snapshooter . NUnit ;
67using static System . Reflection . BindingFlags ;
78
89namespace System . IO . Abstractions . Tests
@@ -11,62 +12,62 @@ namespace System.IO.Abstractions.Tests
1112 public class ApiParityTests
1213 {
1314 [ Test ]
14- public void File ( ) =>
15- AssertParity (
15+ public async Task File ( ) =>
16+ await AssertParity (
1617 typeof ( System . IO . File ) ,
1718 typeof ( System . IO . Abstractions . FileBase )
1819 ) ;
1920
2021 [ Test ]
21- public void FileInfo ( ) =>
22- AssertParity (
22+ public async Task FileInfo ( ) =>
23+ await AssertParity (
2324 typeof ( System . IO . FileInfo ) ,
2425 typeof ( System . IO . Abstractions . FileInfoBase )
2526 ) ;
2627
2728 [ Test ]
28- public void FileVersionInfo ( ) =>
29- AssertParity (
29+ public async Task FileVersionInfo ( ) =>
30+ await AssertParity (
3031 typeof ( System . Diagnostics . FileVersionInfo ) ,
3132 typeof ( System . IO . Abstractions . FileVersionInfoBase )
3233 ) ;
3334
3435 [ Test ]
35- public void Directory ( ) =>
36- AssertParity (
36+ public async Task Directory ( ) =>
37+ await AssertParity (
3738 typeof ( System . IO . Directory ) ,
3839 typeof ( System . IO . Abstractions . DirectoryBase )
3940 ) ;
4041
4142 [ Test ]
42- public void DirectoryInfo ( ) =>
43- AssertParity (
43+ public async Task DirectoryInfo ( ) =>
44+ await AssertParity (
4445 typeof ( System . IO . DirectoryInfo ) ,
4546 typeof ( System . IO . Abstractions . DirectoryInfoBase )
4647 ) ;
4748
4849 [ Test ]
49- public void DriveInfo ( ) =>
50- AssertParity (
50+ public async Task DriveInfo ( ) =>
51+ await AssertParity (
5152 typeof ( System . IO . DriveInfo ) ,
5253 typeof ( System . IO . Abstractions . DriveInfoBase )
5354 ) ;
5455
5556 [ Test ]
56- public void Path ( ) =>
57- AssertParity (
57+ public async Task Path ( ) =>
58+ await AssertParity (
5859 typeof ( System . IO . Path ) ,
5960 typeof ( System . IO . Abstractions . PathBase )
6061 ) ;
6162
6263 [ Test ]
63- public void FileSystemWatcher ( ) =>
64- AssertParity (
64+ public async Task FileSystemWatcher ( ) =>
65+ await AssertParity (
6566 typeof ( System . IO . FileSystemWatcher ) ,
6667 typeof ( System . IO . Abstractions . FileSystemWatcherBase )
6768 ) ;
6869
69- private void AssertParity ( Type referenceType , Type abstractionType )
70+ private async Task AssertParity ( Type referenceType , Type abstractionType )
7071 {
7172 static IEnumerable < string > GetMembers ( Type type ) => type
7273 . GetMembers ( bindingAttr : Instance | Static | Public | FlattenHierarchy )
@@ -89,9 +90,23 @@ static IEnumerable<string> GetMembers(Type type) => type
8990 extraMembers : abstractionMembers . Except ( referenceMembers ) ,
9091 missingMembers : referenceMembers . Except ( abstractionMembers )
9192 ) ;
92- Snapshot . Match ( diff , SnapshotNameExtension . Create ( snapshotSuffix ) ) ;
93+
94+ var serializedDiff = JsonSerializer . Serialize ( diff , SerializerOptions ) ;
95+
96+ var snapshotPath = IO . Path . GetFullPath ( "../../../__snapshots__/" ) ;
97+ var fileName = $ "ApiParityTests.{ referenceType . Name } _{ snapshotSuffix } .snap";
98+ var fileContent = IO . File . ReadAllText ( IO . Path . Combine ( snapshotPath , fileName ) ) ;
99+
100+ await Expect . That ( fileContent ) . IsEqualTo ( serializedDiff )
101+ . IgnoringNewlineStyle ( )
102+ . IgnoringTrailingWhiteSpace ( ) ;
93103 }
94104
105+ private static JsonSerializerOptions SerializerOptions = new ( )
106+ {
107+ WriteIndented = true
108+ } ;
109+
95110 private readonly struct ApiDiff
96111 {
97112 public ApiDiff ( IEnumerable < string > extraMembers , IEnumerable < string > missingMembers )
0 commit comments