Mercurial > silverbladetech
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Stocks/Stocks.Service.Tests.Unit/StockServiceTests.cs Mon Feb 20 13:52:35 2012 +0700 @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Xunit; +using Stocks.Common; +using System.Threading.Tasks; +using System.Threading; + +namespace Stocks.Service.Tests.Unit +{ + public class StockServiceTests + { + [Fact] + public void Service_IsActive_property() + { + var file = "../../../Stocks.Service/companyData.json"; + var service = new StocksService(new ConfigurationService(file)); + + using (var task = Task.Factory.StartNew(() => + { + Assert.Equal(false, service.IsActive); + service.Start(); + Assert.Equal(true, service.IsActive); + using (var task2 = Task.Factory.StartNew(() => Thread.Sleep(500))) + { task2.Wait(); } + service.Stop(); + Assert.Equal(false, service.IsActive); + })) + { + task.Wait(); + } + } + } +}