0
|
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 }
|