Mercurial > silverbladetech
annotate Stocks/Stocks.Service.Tests.Unit/StockServiceTests.cs @ 2:29ed98d659e9
Adding WebClientShim files
author | stevenh7776 stevenhollidge@hotmail.com |
---|---|
date | Mon, 20 Feb 2012 22:04:50 +0700 |
parents | e5d46bb6cdb0 |
children | 57f20ba55884 |
rev | line source |
---|---|
0 | 1 using System; |
2 using System.Collections.Generic; | |
3 using System.Linq; | |
4 using System.Text; | |
5 using Xunit; | |
6 using Stocks.Common; | |
7 using System.Threading.Tasks; | |
8 using System.Threading; | |
2
29ed98d659e9
Adding WebClientShim files
stevenh7776 stevenhollidge@hotmail.com
parents:
0
diff
changeset
|
9 using System.Net; |
0 | 10 |
11 namespace Stocks.Service.Tests.Unit | |
12 { | |
13 public class StockServiceTests | |
14 { | |
15 [Fact] | |
16 public void Service_IsActive_property() | |
17 { | |
18 var file = "../../../Stocks.Service/companyData.json"; | |
2
29ed98d659e9
Adding WebClientShim files
stevenh7776 stevenhollidge@hotmail.com
parents:
0
diff
changeset
|
19 var configurationService = new ConfigurationService(file); |
29ed98d659e9
Adding WebClientShim files
stevenh7776 stevenhollidge@hotmail.com
parents:
0
diff
changeset
|
20 var webClientShim = new WebClientShim(new WebClient()); |
29ed98d659e9
Adding WebClientShim files
stevenh7776 stevenhollidge@hotmail.com
parents:
0
diff
changeset
|
21 |
29ed98d659e9
Adding WebClientShim files
stevenh7776 stevenhollidge@hotmail.com
parents:
0
diff
changeset
|
22 var service = new StocksService( |
29ed98d659e9
Adding WebClientShim files
stevenh7776 stevenhollidge@hotmail.com
parents:
0
diff
changeset
|
23 configurationService, |
29ed98d659e9
Adding WebClientShim files
stevenh7776 stevenhollidge@hotmail.com
parents:
0
diff
changeset
|
24 webClientShim); |
29ed98d659e9
Adding WebClientShim files
stevenh7776 stevenhollidge@hotmail.com
parents:
0
diff
changeset
|
25 |
29ed98d659e9
Adding WebClientShim files
stevenh7776 stevenhollidge@hotmail.com
parents:
0
diff
changeset
|
26 Assert.Equal(false, service.IsActive); |
0 | 27 |
28 using (var task = Task.Factory.StartNew(() => | |
29 { | |
30 service.Start(); | |
31 Assert.Equal(true, service.IsActive); | |
2
29ed98d659e9
Adding WebClientShim files
stevenh7776 stevenhollidge@hotmail.com
parents:
0
diff
changeset
|
32 |
0 | 33 using (var task2 = Task.Factory.StartNew(() => Thread.Sleep(500))) |
34 { task2.Wait(); } | |
35 service.Stop(); | |
36 Assert.Equal(false, service.IsActive); | |
37 })) | |
38 { | |
39 task.Wait(); | |
40 } | |
41 } | |
42 } | |
43 } |