3
3
using System . Collections . Generic ;
4
4
using System . Linq ;
5
5
using System . Net ;
6
- using System . Text ;
7
6
using System . Text . Json ;
8
7
using System . Threading . Tasks ;
9
8
@@ -98,8 +97,9 @@ public void ResponseSerializationWorksBidirectional(string _, E5EResponse input)
98
97
public void ResponseSerializationRecognisesCorrectType ( )
99
98
{
100
99
Assert . Equal ( E5EResponseType . Text , E5EResponse . From ( "test" ) . Type ) ;
101
- Assert . Equal ( E5EResponseType . Binary , E5EResponse . From ( Encoding . UTF8 . GetBytes ( "test" ) ) . Type ) ;
102
- Assert . Equal ( E5EResponseType . Binary , E5EResponse . From ( Encoding . UTF8 . GetBytes ( "test" ) . AsEnumerable ( ) ) . Type ) ;
100
+ Assert . Equal ( E5EResponseType . Binary , E5EResponse . From ( "test"u8 . ToArray ( ) ) . Type ) ;
101
+ Assert . Equal ( E5EResponseType . Binary , E5EResponse . From ( "test"u8 . ToArray ( ) . AsEnumerable ( ) ) . Type ) ;
102
+ Assert . Equal ( E5EResponseType . Binary , E5EResponse . From ( new E5EFileData ( "something"u8 . ToArray ( ) ) ) . Type ) ;
103
103
Assert . Equal ( E5EResponseType . StructuredObject , E5EResponse . From ( new E5ERuntimeMetadata ( ) ) . Type ) ;
104
104
}
105
105
@@ -159,6 +159,7 @@ private class SerializationTestsData : IEnumerable<object[]>
159
159
new E5EContext ( "generic" , DateTimeOffset . FromUnixTimeSeconds ( 0 ) , true ) ,
160
160
new E5ERequestParameters ( ) ,
161
161
new E5ERuntimeMetadata ( ) ,
162
+ new E5EFileData ( "data"u8 . ToArray ( ) ) ,
162
163
} ;
163
164
164
165
private IEnumerable < object [ ] > Data => _objects . Select ( obj => new [ ] { obj } ) ;
@@ -179,11 +180,8 @@ private class RequestSerializationTestsData : IEnumerable<object[]>
179
180
private readonly Dictionary < string , E5EEvent > _tests = new ( )
180
181
{
181
182
{ "simple text request" , new TestRequestBuilder ( ) . WithData ( "test" ) . BuildEvent ( ) } ,
182
- { "simple binary request" , new TestRequestBuilder ( ) . WithData ( Encoding . UTF8 . GetBytes ( "test" ) ) . BuildEvent ( ) } ,
183
- {
184
- "simple object request" ,
185
- new TestRequestBuilder ( ) . WithData ( new Dictionary < string , string > { { "test" , "value" } } ) . BuildEvent ( )
186
- } ,
183
+ { "simple binary request" , new TestRequestBuilder ( ) . WithData ( new E5EFileData ( "hello"u8 . ToArray ( ) ) ) . BuildEvent ( ) } ,
184
+ { "simple object request" , new TestRequestBuilder ( ) . WithData ( new Dictionary < string , string > { { "test" , "value" } } ) . BuildEvent ( ) } ,
187
185
{
188
186
"request with headers and parameters" , new TestRequestBuilder ( ) . WithData ( "test" )
189
187
. AddParam ( "param" , "value" )
@@ -210,12 +208,15 @@ private class ResponseSerializationTestsData : IEnumerable<object[]>
210
208
private readonly Dictionary < string , E5EResponse > _tests = new ( )
211
209
{
212
210
{ "simple text response" , E5EResponse . From ( "test" ) } ,
213
- { "simple binary response" , E5EResponse . From ( Encoding . UTF8 . GetBytes ( "test" ) ) } ,
214
- { "simple object response" , E5EResponse . From ( new Dictionary < string , int > { { "a" , 1 } , { "b" , 2 } } ) } ,
211
+ { "simple binary response" , E5EResponse . From ( "hello"u8 . ToArray ( ) ) } ,
215
212
{
216
- "text response with headers and status code" , E5EResponse . From ( "test" , HttpStatusCode . Moved ,
217
- new E5EHttpHeaders { { "Location" , "https://example.com" } } )
213
+ "simple object response" , E5EResponse . From ( new Dictionary < string , int >
214
+ {
215
+ { "a" , 1 } ,
216
+ { "b" , 2 } ,
217
+ } )
218
218
} ,
219
+ { "text response with headers and status code" , E5EResponse . From ( "test" , HttpStatusCode . Moved , new E5EHttpHeaders { { "Location" , "https://example.com" } } ) } ,
219
220
} ;
220
221
221
222
private IEnumerable < object [ ] > Data => _tests . Select ( obj => new object [ ] { obj . Key , obj . Value } ) ;
0 commit comments