7
7
using Simplify . Web . Attributes ;
8
8
using Simplify . Web . Multipart . Model ;
9
9
10
- namespace TestServer . Controllers . Api . v1
10
+ namespace TestServer . Controllers . Api . v1 ;
11
+
12
+ [ Post ( "/api/v1/testIn" ) ]
13
+ public class TestInController : AsyncController < MultipartViewModel >
11
14
{
12
- [ Post ( "/api/v1/testIn" ) ]
13
- public class TestInController : AsyncController < MultipartViewModel >
15
+ public override async Task < ControllerResponse > Invoke ( )
14
16
{
15
- public override async Task < ControllerResponse > Invoke ( )
16
- {
17
- var file = Model . Files . FirstOrDefault ( ) ?? throw new ArgumentException ( "No files in model" ) ;
18
- using var stream = new StreamReader ( file . Data ) ;
19
- var fileData = await stream . ReadToEndAsync ( ) ;
17
+ var file = Model . Files . FirstOrDefault ( ) ?? throw new ArgumentException ( "No files in model" ) ;
18
+ using var stream = new StreamReader ( file . Data ) ;
19
+ var fileData = await stream . ReadToEndAsync ( ) ;
20
20
21
- Trace . WriteLine ( $ "Files count: '{ Model . Files . Count } '") ;
22
- Trace . WriteLine ( $ "File name: '{ file . FileName } '") ;
23
- Trace . WriteLine ( $ "File content: '{ fileData } '") ;
21
+ Trace . WriteLine ( $ "Files count: '{ Model . Files . Count } '") ;
22
+ Trace . WriteLine ( $ "File name: '{ file . FileName } '") ;
23
+ Trace . WriteLine ( $ "File content: '{ fileData } '") ;
24
24
25
- // Assert
25
+ // Assert
26
26
27
- if ( file . Name != "test file" )
28
- return Content ( $ "Wrong name, actual: '{ file . Name } '", 500 ) ;
27
+ if ( file . Name != "test file" )
28
+ return Content ( $ "Wrong name, actual: '{ file . Name } '", 500 ) ;
29
29
30
- if ( file . FileName != "MyFile.txt" )
31
- return Content ( $ "Wrong file name, actual: '{ file . FileName } '", 500 ) ;
30
+ if ( file . FileName != "MyFile.txt" )
31
+ return Content ( $ "Wrong file name, actual: '{ file . FileName } '", 500 ) ;
32
32
33
- if ( fileData != "Hello World!!!" )
34
- return Content ( $ "Wrong file data, actual: '{ fileData } '", 500 ) ;
33
+ if ( fileData != "Hello World!!!" )
34
+ return Content ( $ "Wrong file data, actual: '{ fileData } '", 500 ) ;
35
35
36
- return NoContent ( ) ;
37
- }
36
+ return NoContent ( ) ;
38
37
}
39
38
}
0 commit comments