1
- using System ;
2
- using System . IO ;
3
- using System . Linq ;
4
- using System . Reflection ;
5
- using System . Runtime . CompilerServices ;
6
- using ApprovalTests ;
7
- using ApprovalTests . Core ;
1
+ using System . Runtime . CompilerServices ;
2
+ using NServiceBus . Metrics . ServiceControl . Msmq . Tests ;
8
3
using NUnit . Framework ;
9
4
using PublicApiGenerator ;
10
5
@@ -15,40 +10,7 @@ public class APIApprovals
15
10
[ MethodImpl ( MethodImplOptions . NoInlining ) ]
16
11
public void Approve ( )
17
12
{
18
- var combine = Path . Combine ( TestContext . CurrentContext . TestDirectory , "NServiceBus.Metrics.ServiceControl.Msmq.dll" ) ;
19
- var assembly = Assembly . LoadFile ( combine ) ;
20
- var publicApi = Filter ( ApiGenerator . GeneratePublicApi ( assembly ) ) ;
21
- Approvals . Verify ( BuildWriter ( publicApi ) ) ;
22
- }
23
-
24
- static IApprovalWriter BuildWriter ( string api , [ CallerFilePath ] string path = null )
25
- {
26
- var directory = Path . GetDirectoryName ( path ) ;
27
- return new LocalApprovalTextWriter ( api , "cs" , directory ) ;
28
- }
29
-
30
- string Filter ( string text )
31
- {
32
- return string . Join ( Environment . NewLine , text . Split ( new [ ]
33
- {
34
- Environment . NewLine
35
- } , StringSplitOptions . RemoveEmptyEntries )
36
- . Where ( l => ! l . StartsWith ( "[assembly: System.Runtime.Versioning" ) )
37
- . Where ( l => ! string . IsNullOrWhiteSpace ( l ) )
38
- ) ;
39
- }
40
-
41
- class LocalApprovalTextWriter : ApprovalTextWriter
42
- {
43
- readonly string directory ;
44
-
45
- public LocalApprovalTextWriter ( string data , string extensionWithoutDot , string directory )
46
- : base ( data , extensionWithoutDot )
47
- {
48
- this . directory = directory ;
49
- }
50
-
51
- public override string GetApprovalFilename ( string basename ) => Path . Combine ( directory , base . GetApprovalFilename ( basename ) ) ;
52
- public override string GetReceivedFilename ( string basename ) => Path . Combine ( directory , base . GetReceivedFilename ( basename ) ) ;
13
+ var publicApi = ApiGenerator . GeneratePublicApi ( typeof ( MsmqNativeQueueLengthReporter ) . Assembly ) ;
14
+ TestApprover . Verify ( publicApi ) ;
53
15
}
54
16
}
0 commit comments