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