11using System . IO ;
2+ using System . Text ;
23using System . Threading . Tasks ;
4+ using System . Xml ;
5+ using System . Xml . Linq ;
36using Xunit ;
47
58namespace Https . Tests
@@ -11,7 +14,21 @@ public IntegrationTests(WebHostFixture fixture) =>
1114 _fixture = fixture ;
1215
1316 [ Fact ]
14- public async Task MirrorTests ( )
17+ public async Task MirrorTest_ShouldReflectFormUrlEncoded ( )
18+ {
19+ var args = new [ ]
20+ {
21+ "post" , $ "{ _fixture . Url } /Mirror", "--form" , "foo=bar" , "lorem=ipsum"
22+ } ;
23+
24+ var result = await Https . ExecuteAsync ( args ) ;
25+
26+ var actual = new StreamReader ( result . StdOut ) . ReadToEnd ( ) ;
27+ Assert . Equal ( "foo=bar&lorem=ipsum" , actual ) ;
28+ }
29+
30+ [ Fact ]
31+ public async Task MirrorTest_ShouldReflectJson ( )
1532 {
1633 var args = new [ ]
1734 {
@@ -20,8 +37,32 @@ public async Task MirrorTests()
2037
2138 var result = await Https . ExecuteAsync ( args ) ;
2239
23- var json = new StreamReader ( result . StdOut ) . ReadToEnd ( ) ;
24- Assert . Equal ( "{\" foo\" :\" bar\" ,\" lorem\" :\" ipsum\" }" , json ) ;
40+ var actual = new StreamReader ( result . StdOut ) . ReadToEnd ( ) ;
41+ Assert . Equal ( "{\" foo\" :\" bar\" ,\" lorem\" :\" ipsum\" }" , actual ) ;
42+ }
43+
44+ [ Fact ]
45+ public async Task MirrorTest_ShouldReflectXml ( )
46+ {
47+ var args = new [ ]
48+ {
49+ "post" , $ "{ _fixture . Url } /Mirror", "--xml=root" , "foo=bar" , "lorem=ipsum"
50+ } ;
51+
52+ var result = await Https . ExecuteAsync ( args ) ;
53+
54+ var expected = new XDocument (
55+ new XElement (
56+ "root" ,
57+ new XElement ( "foo" , "bar" ) ,
58+ new XElement ( "lorem" , "ipsum" )
59+ )
60+ ) . ToString ( ) ;
61+ var actual = XDocument . Load (
62+ new StreamReader ( result . StdOut )
63+ ) . ToString ( ) ;
64+
65+ Assert . Equal ( expected , actual ) ;
2566 }
2667
2768 [ Fact ]
0 commit comments