comparison 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
comparison
equal deleted inserted replaced
1:bd448bb6e0ba 2:29ed98d659e9
4 using System.Text; 4 using System.Text;
5 using Xunit; 5 using Xunit;
6 using Stocks.Common; 6 using Stocks.Common;
7 using System.Threading.Tasks; 7 using System.Threading.Tasks;
8 using System.Threading; 8 using System.Threading;
9 using System.Net;
9 10
10 namespace Stocks.Service.Tests.Unit 11 namespace Stocks.Service.Tests.Unit
11 { 12 {
12 public class StockServiceTests 13 public class StockServiceTests
13 { 14 {
14 [Fact] 15 [Fact]
15 public void Service_IsActive_property() 16 public void Service_IsActive_property()
16 { 17 {
17 var file = "../../../Stocks.Service/companyData.json"; 18 var file = "../../../Stocks.Service/companyData.json";
18 var service = new StocksService(new ConfigurationService(file)); 19 var configurationService = new ConfigurationService(file);
20 var webClientShim = new WebClientShim(new WebClient());
21
22 var service = new StocksService(
23 configurationService,
24 webClientShim);
25
26 Assert.Equal(false, service.IsActive);
19 27
20 using (var task = Task.Factory.StartNew(() => 28 using (var task = Task.Factory.StartNew(() =>
21 { 29 {
22 Assert.Equal(false, service.IsActive);
23 service.Start(); 30 service.Start();
24 Assert.Equal(true, service.IsActive); 31 Assert.Equal(true, service.IsActive);
32
25 using (var task2 = Task.Factory.StartNew(() => Thread.Sleep(500))) 33 using (var task2 = Task.Factory.StartNew(() => Thread.Sleep(500)))
26 { task2.Wait(); } 34 { task2.Wait(); }
27 service.Stop(); 35 service.Stop();
28 Assert.Equal(false, service.IsActive); 36 Assert.Equal(false, service.IsActive);
29 })) 37 }))