diff Stocks/Stocks.Service.Tests.Unit/StockServiceTests.cs @ 6:c812bca7b1ac

"Restore packages on build" enabled by Nuget 1.6 General refactoring based on code analysis
author stevenh7776 stevenhollidge@hotmail.com
date Tue, 21 Feb 2012 01:00:34 +0700
parents 57f20ba55884
children
line wrap: on
line diff
--- a/Stocks/Stocks.Service.Tests.Unit/StockServiceTests.cs	Mon Feb 20 23:07:37 2012 +0700
+++ b/Stocks/Stocks.Service.Tests.Unit/StockServiceTests.cs	Tue Feb 21 01:00:34 2012 +0700
@@ -1,12 +1,8 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
+using System.Net;
+using System.Threading;
+using System.Threading.Tasks;
+using Stocks.Common;
 using Xunit;
-using Stocks.Common;
-using System.Threading.Tasks;
-using System.Threading;
-using System.Net;
 
 namespace Stocks.Service.Tests.Unit
 {
@@ -17,26 +13,28 @@
     {
       var file = "../../../Stocks.Service/companyData.json";
       var configurationService = new ConfigurationService(file);
-      var webClientShim = new WebClientShim(new WebClient());
-      
-      var service = new StocksService(
-        configurationService, 
-        webClientShim);
+      using (var webClientShim = new WebClientShim(new WebClient()))
+      {
+
+        var service = new StocksService(
+          configurationService,
+          webClientShim);
+
+        Assert.Equal(false, service.IsActive);
 
-      Assert.Equal(false, service.IsActive);
+        using (var task = Task.Factory.StartNew(() =>
+          {
+            service.Start();
+            Assert.Equal(true, service.IsActive);
 
-      using (var task = Task.Factory.StartNew(() =>
+            using (var task2 = Task.Factory.StartNew(() => Thread.Sleep(50)))
+            { task2.Wait(); }
+            service.Stop();
+            Assert.Equal(false, service.IsActive);
+          }))
         {
-          service.Start();
-          Assert.Equal(true, service.IsActive);
-      
-          using (var task2 = Task.Factory.StartNew(() => Thread.Sleep(50)))
-            { task2.Wait(); }
-          service.Stop();
-          Assert.Equal(false, service.IsActive);
-        })) 
-      {
-        task.Wait();
+          task.Wait();
+        }
       }
     }
   }