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
e5d46bb6cdb0 Initial commit
adminSH stevenhollidge@hotmail.com
parents:
diff changeset
5 using Xunit;
e5d46bb6cdb0 Initial commit
adminSH stevenhollidge@hotmail.com
parents:
diff changeset
6
e5d46bb6cdb0 Initial commit
adminSH stevenhollidge@hotmail.com
parents:
diff changeset
7 namespace Stocks.Service.Tests.Unit
e5d46bb6cdb0 Initial commit
adminSH stevenhollidge@hotmail.com
parents:
diff changeset
8 {
e5d46bb6cdb0 Initial commit
adminSH stevenhollidge@hotmail.com
parents:
diff changeset
9 public class StockServiceTests
e5d46bb6cdb0 Initial commit
adminSH stevenhollidge@hotmail.com
parents:
diff changeset
10 {
e5d46bb6cdb0 Initial commit
adminSH stevenhollidge@hotmail.com
parents:
diff changeset
11 [Fact]
e5d46bb6cdb0 Initial commit
adminSH stevenhollidge@hotmail.com
parents:
diff changeset
12 public void Service_IsActive_property()
e5d46bb6cdb0 Initial commit
adminSH stevenhollidge@hotmail.com
parents:
diff changeset
13 {
e5d46bb6cdb0 Initial commit
adminSH stevenhollidge@hotmail.com
parents:
diff changeset
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
e5d46bb6cdb0 Initial commit
adminSH stevenhollidge@hotmail.com
parents:
diff changeset
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
e5d46bb6cdb0 Initial commit
adminSH stevenhollidge@hotmail.com
parents:
diff changeset
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
e5d46bb6cdb0 Initial commit
adminSH stevenhollidge@hotmail.com
parents:
diff changeset
38 }
e5d46bb6cdb0 Initial commit
adminSH stevenhollidge@hotmail.com
parents:
diff changeset
39 }
e5d46bb6cdb0 Initial commit
adminSH stevenhollidge@hotmail.com
parents:
diff changeset
40 }
e5d46bb6cdb0 Initial commit
adminSH stevenhollidge@hotmail.com
parents:
diff changeset
41 }