@@ -40,28 +40,72 @@ public async Task MirrorTest_ShouldReflectJson()
4040 Assert . Equal ( "{\" foo\" :\" bar\" ,\" lorem\" :\" ipsum\" }" , actual ) ;
4141 }
4242
43+ static async Task RunXmlTestAsync ( string [ ] args , XDocument expected )
44+ {
45+ var result = await Https . ExecuteAsync ( args ) ;
46+
47+ var actual = XDocument . Load (
48+ new StreamReader ( result . StdOut )
49+ ) . ToString ( ) ;
50+
51+ Assert . Equal ( expected . ToString ( ) , actual ) ;
52+ }
53+
4354 [ Fact ]
44- public async Task MirrorTest_ShouldReflectXml ( )
55+ public async Task MirrorTest_ShouldReflectXmlWithDefaultRootElementName ( )
4556 {
4657 var args = new [ ]
4758 {
48- "post" , $ "{ _fixture . HttpUrl } /Mirror", "--xml=root " , "foo=bar" , "lorem=ipsum"
59+ "post" , $ "{ _fixture . HttpUrl } /Mirror", "--xml" , "foo=bar" , "lorem=ipsum"
4960 } ;
5061
51- var result = await Https . ExecuteAsync ( args ) ;
62+ var expected = new XDocument (
63+ new XElement (
64+ "xml" ,
65+ new XElement ( "foo" , "bar" ) ,
66+ new XElement ( "lorem" , "ipsum" )
67+ )
68+ ) ;
69+
70+ await RunXmlTestAsync ( args , expected ) ;
71+ }
72+
73+ [ Fact ]
74+ public async Task MirrorTest_ShouldReflectXmlWithEmptyRootElementName ( )
75+ {
76+ var args = new [ ]
77+ {
78+ "post" , $ "{ _fixture . HttpUrl } /Mirror", "--xml= " , "foo=bar" , "lorem=ipsum"
79+ } ;
80+
81+ var expected = new XDocument (
82+ new XElement (
83+ "xml" ,
84+ new XElement ( "foo" , "bar" ) ,
85+ new XElement ( "lorem" , "ipsum" )
86+ )
87+ ) ;
88+
89+ await RunXmlTestAsync ( args , expected ) ;
90+ }
91+
92+ [ Fact ]
93+ public async Task MirrorTest_ShouldReflectXmlWithRootElementName ( )
94+ {
95+ var args = new [ ]
96+ {
97+ "post" , $ "{ _fixture . HttpUrl } /Mirror", "--xml=root" , "foo=bar" , "lorem=ipsum"
98+ } ;
5299
53100 var expected = new XDocument (
54101 new XElement (
55102 "root" ,
56103 new XElement ( "foo" , "bar" ) ,
57104 new XElement ( "lorem" , "ipsum" )
58105 )
59- ) . ToString ( ) ;
60- var actual = XDocument . Load (
61- new StreamReader ( result . StdOut )
62- ) . ToString ( ) ;
106+ ) ;
63107
64- Assert . Equal ( expected , actual ) ;
108+ await RunXmlTestAsync ( args , expected ) ;
65109 }
66110 }
67111}
0 commit comments