diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/MemoryFileSystem.cs b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/MemoryFileSystem.cs index e0cbe3ab..0369cbc3 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/MemoryFileSystem.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/MemoryFileSystem.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage; @@ -12,17 +13,17 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common public static IFileStreamFactory GetFileStreamFactory() { - return GetFileStreamFactory(new Dictionary()); + return GetFileStreamFactory(new ConcurrentDictionary()); } - public static IFileStreamFactory GetFileStreamFactory(Dictionary storage) + public static IFileStreamFactory GetFileStreamFactory(ConcurrentDictionary storage) { Mock mock = new Mock(); mock.Setup(fsf => fsf.CreateFile()) .Returns(() => { string fileName = Guid.NewGuid().ToString(); - storage.Add(fileName, new byte[8192]); + storage.TryAdd(fileName, new byte[8192]); return fileName; }); mock.Setup(fsf => fsf.GetReader(It.IsAny())) diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/QueryExecution/Common.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/QueryExecution/Common.cs index fd6b02d8..04487716 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/QueryExecution/Common.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/QueryExecution/Common.cs @@ -2,6 +2,7 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System.Collections.Concurrent; using System.Collections.Generic; using System.Data; using System.Data.Common; @@ -212,10 +213,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution public static QueryExecutionService GetPrimedExecutionService(TestResultSet[] data, bool isConnected, bool throwOnRead, WorkspaceService workspaceService, - out Dictionary storage) + out ConcurrentDictionary storage) { // Create a place for the temp "files" to be written - storage = new Dictionary(); + storage = new ConcurrentDictionary(); // Mock the connection service var connectionService = new Mock(); @@ -231,7 +232,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution public static QueryExecutionService GetPrimedExecutionService(TestResultSet[] data, bool isConnected, bool throwOnRead, WorkspaceService workspaceService) { - Dictionary storage; + ConcurrentDictionary storage; return GetPrimedExecutionService(data, isConnected, throwOnRead, workspaceService, out storage); } diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/QueryExecution/SaveResults/ServiceIntegrationTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/QueryExecution/SaveResults/ServiceIntegrationTests.cs index 33d3d28c..4ae8c36f 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/QueryExecution/SaveResults/ServiceIntegrationTests.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/QueryExecution/SaveResults/ServiceIntegrationTests.cs @@ -3,6 +3,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. // +using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Threading.Tasks; @@ -52,7 +53,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.SaveResults // Given: // ... A working query and workspace service WorkspaceService ws = Common.GetPrimedWorkspaceService(Constants.StandardQuery); - Dictionary storage; + ConcurrentDictionary storage; QueryExecutionService qes = Common.GetPrimedExecutionService(Common.ExecutionPlanTestDataSet, true, false, ws, out storage); // ... The query execution service has executed a query with results @@ -97,7 +98,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.SaveResults // Given: // ... A working query and workspace service WorkspaceService ws = Common.GetPrimedWorkspaceService(Constants.StandardQuery); - Dictionary storage; + ConcurrentDictionary storage; QueryExecutionService qes = Common.GetPrimedExecutionService(Common.ExecutionPlanTestDataSet, true, false, ws, out storage); // ... The query execution service has executed a query with results @@ -164,7 +165,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.SaveResults // Given: // ... A working query and workspace service WorkspaceService ws = Common.GetPrimedWorkspaceService(Constants.StandardQuery); - Dictionary storage; + ConcurrentDictionary storage; QueryExecutionService qes = Common.GetPrimedExecutionService(Common.StandardTestDataSet, true, false, ws, out storage); // ... The query execution service has executed a query with results @@ -207,7 +208,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.SaveResults // Given: // ... A working query and workspace service WorkspaceService ws = Common.GetPrimedWorkspaceService(Constants.StandardQuery); - Dictionary storage; + ConcurrentDictionary storage; QueryExecutionService qes = Common.GetPrimedExecutionService(Common.StandardTestDataSet, true, false, ws, out storage); // ... The query execution service has executed a query with results @@ -273,7 +274,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.SaveResults // Given: // ... A working query and workspace service WorkspaceService ws = Common.GetPrimedWorkspaceService(Constants.StandardQuery); - Dictionary storage; + ConcurrentDictionary storage; QueryExecutionService qes = Common.GetPrimedExecutionService(Common.StandardTestDataSet, true, false, ws, out storage); // ... The query execution service has executed a query with results @@ -316,7 +317,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.SaveResults // Given: // ... A working query and workspace service WorkspaceService ws = Common.GetPrimedWorkspaceService(Constants.StandardQuery); - Dictionary storage; + ConcurrentDictionary storage; QueryExecutionService qes = Common.GetPrimedExecutionService(Common.StandardTestDataSet, true, false, ws, out storage); // ... The query execution service has executed a query with results