mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -05:00
Use a concurrent dict when mocking file stream factory (#465)
This commit is contained in:
@@ -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<string, byte[]>());
|
||||
return GetFileStreamFactory(new ConcurrentDictionary<string, byte[]>());
|
||||
}
|
||||
|
||||
public static IFileStreamFactory GetFileStreamFactory(Dictionary<string, byte[]> storage)
|
||||
public static IFileStreamFactory GetFileStreamFactory(ConcurrentDictionary<string, byte[]> storage)
|
||||
{
|
||||
Mock<IFileStreamFactory> mock = new Mock<IFileStreamFactory>();
|
||||
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<string>()))
|
||||
|
||||
Reference in New Issue
Block a user