1
- using Unosquare . Labs . EmbedIO . Tests . TestObjects ;
2
-
3
- namespace Unosquare . Labs . EmbedIO . Tests
1
+ namespace Unosquare . Labs . EmbedIO . Tests
4
2
{
5
3
using NUnit . Framework ;
4
+ using System ;
6
5
using System . Globalization ;
7
6
using System . Linq ;
7
+ using System . Threading ;
8
8
using Unosquare . Labs . EmbedIO . Log ;
9
9
using Unosquare . Labs . EmbedIO . Modules ;
10
10
using Unosquare . Labs . EmbedIO . Tests . Properties ;
11
- using System . Threading ;
12
- using System ;
11
+ using Unosquare . Labs . EmbedIO . Tests . TestObjects ;
13
12
14
13
[ TestFixture ]
15
14
public class WebServerTest
@@ -20,7 +19,6 @@ public class WebServerTest
20
19
[ Test ]
21
20
public void WebServerDefaultConstructor ( )
22
21
{
23
-
24
22
var instance = new WebServer ( ) ;
25
23
Assert . AreEqual ( instance . Log . GetType ( ) , typeof ( NullLog ) , "Default log is NullLog" ) ;
26
24
Assert . IsNotNull ( instance . Listener , "It has a HttpListener" ) ;
@@ -30,25 +28,28 @@ public void WebServerDefaultConstructor()
30
28
[ Test ]
31
29
public void WebserverCanBeDisposed ( )
32
30
{
33
- CancellationTokenSource cts = new CancellationTokenSource ( ) ;
34
- var instance = new WebServer ( "http://localhost:" + DefaultPort ) ;
35
- var task = instance . RunAsync ( cts . Token ) ;
36
- cts . Cancel ( ) ;
37
- try
38
- {
39
- task . Wait ( ) ;
40
- } catch ( AggregateException e )
41
- {
42
- if ( e . GetBaseException ( ) is OperationCanceledException )
31
+ // TODO: I need to test
32
+ var cts = new CancellationTokenSource ( ) ;
33
+ var instance = new WebServer ( "http://localhost:" + DefaultPort ) ;
34
+ var task = instance . RunAsync ( cts . Token ) ;
35
+ cts . Cancel ( ) ;
36
+
37
+ try
43
38
{
44
- instance . Dispose ( ) ;
45
- return ;
46
- } else
39
+ task . Wait ( ) ;
40
+ }
41
+ catch ( AggregateException e )
47
42
{
48
- Assert . Fail ( "Must fail because of an OperationCanceledException" ) ;
43
+ if ( e . GetBaseException ( ) is OperationCanceledException )
44
+ {
45
+ instance . Dispose ( ) ;
46
+ return ;
47
+ }
48
+
49
+ Assert . Fail ( "Must fail because of an OperationCanceledException" ) ;
49
50
}
50
- }
51
- Assert . Fail ( "Must throw an AggregateException" ) ;
51
+
52
+ Assert . Fail ( "Must throw an AggregateException" ) ;
52
53
}
53
54
54
55
[ Test ]
@@ -99,7 +100,7 @@ public void WebServerStaticMethodWithConsole()
99
100
const string errorMessage = "THIS IS AN ERROR" ;
100
101
var instance = WebServer . CreateWithConsole ( Resources . ServerAddress ) ;
101
102
102
- Assert . AreEqual ( instance . Log . GetType ( ) , typeof ( SimpleConsoleLog ) , "Log is SimpleConsoleLog" ) ;
103
+ Assert . AreEqual ( instance . Log . GetType ( ) , typeof ( SimpleConsoleLog ) , "Log is SimpleConsoleLog" ) ;
103
104
104
105
// TODO: Grab console output
105
106
instance . Log . Error ( errorMessage ) ;
0 commit comments