comparison Stocks/Stocks.Service.Tests.Unit/StockServiceTests.cs @ 0:e5d46bb6cdb0

Initial commit
author adminSH stevenhollidge@hotmail.com
date Mon, 20 Feb 2012 13:52:35 +0700
parents
children 29ed98d659e9
comparison
equal deleted inserted replaced
-1:000000000000 0:e5d46bb6cdb0
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;
9
10 namespace Stocks.Service.Tests.Unit
11 {
12 public class StockServiceTests
13 {
14 [Fact]
15 public void Service_IsActive_property()
16 {
17 var file = "../../../Stocks.Service/companyData.json";
18 var service = new StocksService(new ConfigurationService(file));
19
20 using (var task = Task.Factory.StartNew(() =>
21 {
22 Assert.Equal(false, service.IsActive);
23 service.Start();
24 Assert.Equal(true, service.IsActive);
25 using (var task2 = Task.Factory.StartNew(() => Thread.Sleep(500)))
26 { task2.Wait(); }
27 service.Stop();
28 Assert.Equal(false, service.IsActive);
29 }))
30 {
31 task.Wait();
32 }
33 }
34 }
35 }