11using System . IO ;
22using System . Threading . Tasks ;
3- using AwesomeAssertions ;
4- using AwesomeAssertions . Execution ;
53using NuGet . Common ;
64
75namespace nugraph . Tests ;
@@ -15,34 +13,33 @@ public async Task Diagnose()
1513
1614 await File . WriteAllTextAsync ( $ "{ nugraph . GetType ( ) . Name } .diagnostics.txt", result . StdOut ) ;
1715
18- result . Should ( ) . Succeed ( "nugraph:*" ) ;
16+ result . Should ( ) . Match ( stdOutPattern : "nugraph:*" ) ;
1917 }
2018
2119 [ Test ]
2220 public async Task Version ( )
2321 {
2422 var result = await nugraph . RunAsync ( [ "--version" ] ) ;
2523
26- result . Should ( ) . Succeed ( nugraph . Version ) ;
24+ result . Should ( ) . Match ( stdOutPattern : nugraph . Version ) ;
2725 }
2826
2927 [ Test ]
3028 public async Task Help ( )
3129 {
3230 var result = await nugraph . RunAsync ( [ "--help" ] ) ;
3331
34- result . Should ( ) . Succeed ( "*nugraph*[SOURCE]*" ) ;
32+ result . Should ( ) . Match ( stdOutPattern : "*nugraph*[SOURCE]*" ) ;
3533 }
3634
3735 [ Test ]
3836 public async Task Package_Serilog ( )
3937 {
4038 var result = await nugraph . RunAsync ( [ "Serilog" ] ) ;
4139
42- result . Should ( ) . Succeed ( """
40+ result . Should ( ) . Match ( stdOutPattern : "https://mermaid.live/view#pako:*" , stdErrPattern : """
4341 Generating dependency graph for Serilog
4442 Generating dependency graph for Serilog *
45- https://mermaid.live/view#pako:*
4643 """ ) ;
4744 }
4845
@@ -51,10 +48,9 @@ public async Task Package_Serilog_430_net60()
5148 {
5249 var result = await nugraph . RunAsync ( [ "Serilog/4.3.0" , "--framework" , "net6.0" ] ) ;
5350
54- result . Should ( ) . Succeed ( """
51+ result . Should ( ) . Match ( stdOutPattern : "https://mermaid.live/view#pako:*" , stdErrPattern : """
5552 Generating dependency graph for Serilog 4.3.0
5653 Generating dependency graph for Serilog 4.3.0 (net6.0)
57- https://mermaid.live/view#pako:*
5854 """ )
5955 . And . UrlHasDiagram ( """
6056 ---
@@ -81,10 +77,9 @@ public async Task Package_DockerRunner_MermaidSvg()
8177 {
8278 var result = await nugraph . RunAsync ( [ "DockerRunner" , "--format" , "mmd.svg" ] ) ;
8379
84- result . Should ( ) . Succeed ( """
80+ result . Should ( ) . Match ( stdOutPattern : "https://mermaid.ink/svg/pako:*" , stdErrPattern : """
8581 Generating dependency graph for DockerRunner
8682 Generating dependency graph for DockerRunner 1.0.0-beta.2 (netstandard2.0)
87- https://mermaid.ink/svg/pako:*
8883 """ ) ;
8984 }
9085
@@ -93,10 +88,9 @@ public async Task Package_DockerRunner_GraphvizSvg()
9388 {
9489 var result = await nugraph . RunAsync ( [ "DockerRunner" , "--format" , "dot.svg" ] ) ;
9590
96- result . Should ( ) . Succeed ( """
91+ result . Should ( ) . Match ( stdOutPattern : "https://kroki.io/graphviz/svg/*" , stdErrPattern : """
9792 Generating dependency graph for DockerRunner
9893 Generating dependency graph for DockerRunner 1.0.0-beta.2 (netstandard2.0)
99- https://kroki.io/graphviz/svg/*
10094 """ ) ;
10195 }
10296
@@ -105,47 +99,35 @@ public async Task Package_DoesNotExist()
10599 {
106100 var result = await nugraph . RunAsync ( [ "DoesNotExist" ] , logLevel : LogLevel . Debug ) ;
107101
108- using ( new AssertionScope ( ) )
109- {
110- result . Should ( ) . Fail ( 66 , "Package DoesNotExist was not found*nuget.org [https://api.nuget.org/v3/index.json]*" ) ;
111- result . StdOut . Should ( ) . ContainAll (
112- "Retrieving DependencyInfoResource for nuget.org" ,
113- "Resolving DoesNotExist with NuGet.Protocol.DependencyInfoResourceV3" ,
114- "Generating dependency graph for DoesNotExist" ) ;
115- }
102+ result . Should ( ) . Match ( 66 , stdErrPattern : """
103+ *Retrieving DependencyInfoResource for nuget.org*
104+ *Resolving DoesNotExist with NuGet.Protocol.DependencyInfoResourceV3*
105+ *Package DoesNotExist was not found*nuget.org [https://api.nuget.org/v3/index.json]*
106+ """ ) ;
116107 }
117108
118109 [ Test ]
119110 public async Task Project_nugraph_WorkingDirectory ( )
120111 {
121112 var result = await nugraph . RunAsync ( [ "-m" , "gv" ] , workingDirectory : RepositoryDirectories . GetPath ( "src" , "nugraph" ) ) ;
122113
123- result . Should ( ) . Succeed ( """
124- Generating dependency graph for nugraph
125- https://edotor.net/#deflate:*
126- """ ) ;
114+ result . Should ( ) . Match ( stdOutPattern : "https://edotor.net/#deflate:*" , stdErrPattern : "Generating dependency graph for nugraph" ) ;
127115 }
128116
129117 [ Test ]
130118 public async Task Project_nugraph_ExplicitDirectory ( )
131119 {
132120 var result = await nugraph . RunAsync ( [ RepositoryDirectories . GetPath ( "src" , "nugraph" ) , "-m" , "graphviz" ] ) ;
133121
134- result . Should ( ) . Succeed ( """
135- Generating dependency graph for nugraph
136- https://edotor.net/#deflate:*
137- """ ) ;
122+ result . Should ( ) . Match ( stdOutPattern : "https://edotor.net/#deflate:*" , stdErrPattern : "Generating dependency graph for nugraph" ) ;
138123 }
139124
140125 [ Test ]
141126 public async Task Project_mmd_ProjectFile ( )
142127 {
143128 var result = await nugraph . RunAsync ( [ RepositoryDirectories . GetPath ( "tools" , "mmd" , "mmd.csproj" ) , "-m" , "dot" ] ) ;
144129
145- result . Should ( ) . Succeed ( """
146- Generating dependency graph for mmd.csproj
147- https://edotor.net/#deflate:*
148- """ )
130+ result . Should ( ) . Match ( stdOutPattern : "https://edotor.net/#deflate:*" , stdErrPattern : "Generating dependency graph for mmd.csproj" )
149131 . And . UrlHasDiagram ( """
150132 # Generated by https://github.com/0xced/nugraph
151133
@@ -169,20 +151,22 @@ public async Task Project_SolutionFile()
169151 {
170152 var result = await nugraph . RunAsync ( [ ] , workingDirectory : RepositoryDirectories . GetPath ( ) ) ;
171153
172- result . Should ( ) . Fail ( 65 , """
173- Solution files are not supported.
174- Please run nugraph in a directory that contains a single project file or pass an explicit project file as the first argument.
175- """ ) ;
154+ result . Should ( ) . Match ( 65 , stdErrPattern : """
155+ Generating dependency graph for nugraph
156+ Solution files are not supported.
157+ Please run nugraph in a directory that contains a single project file or pass an explicit project file as the first argument.
158+ """ ) ;
176159 }
177160
178161 [ Test ]
179162 public async Task Project_NoProject ( )
180163 {
181164 var result = await nugraph . RunAsync ( [ ] , workingDirectory : RepositoryDirectories . GetPath ( "resources" ) ) ;
182165
183- result . Should ( ) . Fail ( 65 , """
184- The current working directory does not contain a project file.
185- Please run nugraph in a directory that contains a single project file or pass an explicit project file as the first argument.
186- """ ) ;
166+ result . Should ( ) . Match ( 65 , stdErrPattern : """
167+ Generating dependency graph for resources
168+ The current working directory does not contain a project file.
169+ Please run nugraph in a directory that contains a single project file or pass an explicit project file as the first argument.
170+ """ ) ;
187171 }
188172}
0 commit comments