File tree Expand file tree Collapse file tree 7 files changed +136
-36
lines changed
Expand file tree Collapse file tree 7 files changed +136
-36
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ Options:
3636 --timeout=< VALUE> Sets the timeout of the request using System.TimeSpan.TryParse (https://docs.microsoft.com/en-us/dotnet/api/system.timespan.parse)
3737 --version Displays the application verison.
3838 --xml=< ROOT_NAME> Renders the content arguments as application/xml using the optional xml root name.
39+ --stop-auto-redirects Prevents redirects from automatically being processed.
3940
4041Content:
4142Repeat as many content arguments to create content sent with the HTTP request. Alternatively pipe raw content send as the HTTP request content.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -10,12 +10,6 @@ variables:
1010 buildConfiguration : ' Release'
1111
1212steps :
13- - task : PowerShell@2
14- displayName : Test Readme
15- inputs :
16- filePath : ' TestReadmeVersion.ps1'
17- failOnStderr : true
18-
1913- task : DotNetCoreCLI@2
2014 displayName : Pack https
2115 inputs :
Original file line number Diff line number Diff line change 1+ using System . Xml . Linq ;
2+
3+ namespace Https . Tests
4+ {
5+ public class HttpsCsprojFixture
6+ {
7+ public XDocument Document { get ; }
8+
9+ public HttpsCsprojFixture ( )
10+ {
11+ var path = "../../../../../src/https/https.csproj" ;
12+
13+ Document = XDocument . Load ( path ) ;
14+ }
15+ }
16+ }
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . IO ;
3+ using System . Text ;
4+ using System . Text . RegularExpressions ;
5+
6+ namespace Https . Tests
7+ {
8+ public class Readme
9+ {
10+ public string InstallationVersion { get ; }
11+ public string UsageDocumentation { get ; }
12+
13+ public Readme ( string path )
14+ {
15+ if ( string . IsNullOrWhiteSpace ( path ) ) throw new ArgumentNullException ( nameof ( path ) ) ;
16+
17+ var sb = new StringBuilder ( ) ;
18+ InstallationVersion = "" ;
19+ UsageDocumentation = "" ;
20+
21+ var lines = File . ReadLines ( path ) ;
22+ var record = false ;
23+ foreach ( var line in lines )
24+ {
25+
26+ if ( line . StartsWith ( "```bash" ) )
27+ {
28+ record = true ;
29+ }
30+ else if ( line . StartsWith ( "```" ) )
31+ {
32+ var text = sb . ToString ( ) ;
33+ sb . Clear ( ) ;
34+
35+ if ( text . StartsWith ( "dotnet tool" ) )
36+ {
37+ var match = Regex . Match ( text , "dotnet tool install --global https --version (.+)-\\ *" ) ;
38+ if ( match . Success )
39+ {
40+ InstallationVersion = match . Groups [ 1 ] . Value ;
41+ }
42+ }
43+ else if ( text . StartsWith ( "Usage" ) )
44+ {
45+ UsageDocumentation = text ;
46+ }
47+
48+ record = false ;
49+ }
50+ else if ( record )
51+ {
52+ sb . AppendLine ( line ) ;
53+ }
54+ }
55+ }
56+ }
57+ }
Original file line number Diff line number Diff line change 1+ namespace Https . Tests
2+ {
3+ public class ReadmeFixture
4+ {
5+ public Readme Readme { get ; }
6+ public ReadmeFixture ( )
7+ {
8+ Readme = new Readme (
9+ "../../../../../README.md"
10+ ) ;
11+ }
12+ }
13+ }
Original file line number Diff line number Diff line change 1+ using System . IO ;
2+ using System . Linq ;
3+ using System . Threading . Tasks ;
4+ using System . Xml . Linq ;
5+ using Xunit ;
6+
7+ namespace Https . Tests
8+ {
9+ public class ReadmeTests : IClassFixture < HttpsCsprojFixture > , IClassFixture < ReadmeFixture >
10+ {
11+ readonly HttpsCsprojFixture _httpsCsprojFixture ;
12+ readonly ReadmeFixture _readmeFixture ;
13+ public ReadmeTests ( HttpsCsprojFixture httpsCsprojFixture , ReadmeFixture readmeFixture )
14+ {
15+ _httpsCsprojFixture = httpsCsprojFixture ;
16+ _readmeFixture = readmeFixture ;
17+ }
18+
19+ [ Fact ]
20+ public void Installation_ShouldListSameVersionAsCsproj ( )
21+ {
22+ var versionPrefixElement = _httpsCsprojFixture . Document
23+ . Root
24+ . Elements ( "PropertyGroup" )
25+ . Elements ( "VersionPrefix" )
26+ . FirstOrDefault ( ) ;
27+
28+ Assert . NotNull ( versionPrefixElement ) ;
29+
30+ var expected = versionPrefixElement . Value ;
31+ var actual = _readmeFixture . Readme . InstallationVersion ;
32+
33+ Assert . Equal ( expected , actual ) ;
34+ }
35+
36+ [ Fact ]
37+ public async Task Usage_ShouldListHelpDocument ( )
38+ {
39+ var httpsResult = await Https . ExecuteAsync ( "--help" ) ;
40+
41+ using var reader = new StreamReader ( httpsResult . StdOut ) ;
42+
43+ var expected = reader . ReadToEnd ( ) . TrimEnd ( ) ;
44+ var actual = _readmeFixture . Readme . UsageDocumentation . TrimEnd ( ) ;
45+
46+ Assert . Equal ( expected , actual ) ;
47+ }
48+ }
49+ }
You can’t perform that action at this time.
0 commit comments