1
1
using System ;
2
- using System . Text ;
3
2
using System . Threading . Tasks ;
4
3
using WebApiClientCore . Exceptions ;
5
4
using WebApiClientCore . Implementations ;
6
- using WebApiClientCore . Internals ;
7
5
using Xunit ;
8
6
9
7
namespace WebApiClientCore . Test . Implementations
@@ -112,9 +110,9 @@ public async Task AddFormFiledAsyncTest()
112
110
[ Fact ]
113
111
public async Task AddFormDataTextTest ( )
114
112
{
115
- string get ( string name , string value )
113
+ static string get ( string name , string value )
116
114
{
117
- return $@ "Content-Disposition: form-data; name=""{ name } ""{ "\r \n \r \n " } { HttpUtil . UrlEncode ( value , Encoding . UTF8 ) } ";
115
+ return $@ "Content-Disposition: form-data; name=""{ name } ""{ "\r \n \r \n " } { value } ";
118
116
}
119
117
120
118
var reqeust = new HttpApiRequestMessageImpl ( ) ;
@@ -130,5 +128,19 @@ string get(string name, string value)
130
128
Assert . Contains ( get ( "age" , "18" ) , body ) ;
131
129
Assert . Equal ( "multipart/form-data" , reqeust . Content . Headers . ContentType ! . MediaType ) ;
132
130
}
131
+
132
+
133
+ [ Fact ]
134
+ public void AddFormDataTextEmptyCollectionTest ( )
135
+ {
136
+ var reqeust = new HttpApiRequestMessageImpl
137
+ {
138
+ Method = System . Net . Http . HttpMethod . Post ,
139
+ RequestUri = new Uri ( "http://webapiclient.com" )
140
+ } ;
141
+
142
+ reqeust . AddFormDataText ( [ ] ) ;
143
+ Assert . Null ( reqeust . Content ) ;
144
+ }
133
145
}
134
146
}
0 commit comments