Minor improvements (#2250)

This commit is contained in:
Cheena Malhotra
2023-09-26 10:16:20 -07:00
committed by GitHub
parent c86b149a1f
commit 78581e8508
6 changed files with 37 additions and 37 deletions

View File

@@ -4,7 +4,7 @@
//
using System;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Globalization;
namespace Microsoft.SqlTools.Utility
@@ -13,7 +13,7 @@ namespace Microsoft.SqlTools.Utility
{
public GeneralRequestDetails()
{
Options = new Dictionary<string, object>(StringComparer.InvariantCultureIgnoreCase);
Options = new ConcurrentDictionary<string, object>(StringComparer.InvariantCultureIgnoreCase);
}
public T GetOptionValue<T>(string name, T defaultValue = default(T))
@@ -96,21 +96,21 @@ namespace Microsoft.SqlTools.Utility
protected void SetOptionValue<T>(string name, T value)
{
Options = Options ?? new Dictionary<string, object>();
Options = Options ?? new ConcurrentDictionary<string, object>();
if (Options.ContainsKey(name))
{
Options[name] = value;
}
else
{
Options.Add(name, value);
Options.TryAdd(name, value);
}
}
/// <summary>
/// Gets or Sets the options
/// </summary>
public Dictionary<string, object> Options { get; set; }
public ConcurrentDictionary<string, object> Options { get; set; }
}
}

View File

@@ -56,7 +56,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
/// <summary>
/// default text size
/// </summary>
private const int DefaultTextSize = 2147483647;
private const int DefaultTextSize = int.MaxValue; // 2147483647;
/// <summary>
/// default execution timeout

View File

@@ -394,9 +394,9 @@ SELECT '$(VAR2)'";
}
catch (Exception e)
{
Assert.True(false, $"Unexpected error consuming token : {e.Message}");
Assert.Fail($"Unexpected error consuming token : {e.Message}");
}
// we doesn't expect any exception or testCase failures
// we don't expect any exception or testCase failures
}

View File

@@ -165,7 +165,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
{
if (!request.Options.ContainsKey(item.Key))
{
request.Options.Add(item.Key, item.Value);
request.Options.TryAdd(item.Key, item.Value);
}
}
}

View File

@@ -610,7 +610,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
{
if (!request.Options.ContainsKey(item.Key))
{
request.Options.Add(item.Key, item.Value);
request.Options.TryAdd(item.Key, item.Value);
}
}
}

View File

@@ -289,33 +289,33 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
private RestoreParams CreateOptionsTestData()
{
RestoreParams optionValues = new RestoreParams();
optionValues.Options.Add(RestoreOptionsHelper.CloseExistingConnections, false);
optionValues.Options.Add(RestoreOptionsHelper.DataFileFolder, "Data file folder");
optionValues.Options.Add("DbFiles", new List<DbFile>() { new DbFile("", '1', "") });
optionValues.Options.Add("DefaultDataFileFolder", "Default data file folder");
optionValues.Options.Add("DefaultLogFileFolder", "Default log file folder");
optionValues.Options.Add("DefaultBackupFolder", "Default backup folder");
optionValues.Options.Add("IsTailLogBackupPossible", true);
optionValues.Options.Add("IsTailLogBackupWithNoRecoveryPossible", true);
optionValues.Options.Add("GetDefaultStandbyFile", "default standby file");
optionValues.Options.Add("GetDefaultTailLogbackupFile", "default tail log backup file");
optionValues.Options.Add(RestoreOptionsHelper.LogFileFolder, "Log file folder");
optionValues.Options.Add(RestoreOptionsHelper.RelocateDbFiles, true);
optionValues.Options.Add("TailLogBackupFile", "tail log backup file");
optionValues.Options.Add("TailLogWithNoRecovery", false);
optionValues.Options.Add(RestoreOptionsHelper.BackupTailLog, false);
optionValues.Options.Add(RestoreOptionsHelper.KeepReplication, false);
optionValues.Options.Add(RestoreOptionsHelper.ReplaceDatabase, false);
optionValues.Options.Add(RestoreOptionsHelper.SetRestrictedUser, false);
optionValues.Options.Add(RestoreOptionsHelper.StandbyFile, "Stand by file");
optionValues.Options.Add(RestoreOptionsHelper.RecoveryState, DatabaseRecoveryState.WithNoRecovery.ToString());
optionValues.Options.Add(RestoreOptionsHelper.TargetDatabaseName, "target db name");
optionValues.Options.Add(RestoreOptionsHelper.SourceDatabaseName, "source db name");
optionValues.Options.Add("CanChangeTargetDatabase", true);
optionValues.Options.Add("DefaultSourceDbName", "DefaultSourceDbName");
optionValues.Options.Add("DefaultTargetDbName", "DefaultTargetDbName");
optionValues.Options.Add("SourceDbNames", new List<string>());
optionValues.Options.Add("CanDropExistingConnections", true);
optionValues.Options.TryAdd(RestoreOptionsHelper.CloseExistingConnections, false);
optionValues.Options.TryAdd(RestoreOptionsHelper.DataFileFolder, "Data file folder");
optionValues.Options.TryAdd("DbFiles", new List<DbFile>() { new DbFile("", '1', "") });
optionValues.Options.TryAdd("DefaultDataFileFolder", "Default data file folder");
optionValues.Options.TryAdd("DefaultLogFileFolder", "Default log file folder");
optionValues.Options.TryAdd("DefaultBackupFolder", "Default backup folder");
optionValues.Options.TryAdd("IsTailLogBackupPossible", true);
optionValues.Options.TryAdd("IsTailLogBackupWithNoRecoveryPossible", true);
optionValues.Options.TryAdd("GetDefaultStandbyFile", "default standby file");
optionValues.Options.TryAdd("GetDefaultTailLogbackupFile", "default tail log backup file");
optionValues.Options.TryAdd(RestoreOptionsHelper.LogFileFolder, "Log file folder");
optionValues.Options.TryAdd(RestoreOptionsHelper.RelocateDbFiles, true);
optionValues.Options.TryAdd("TailLogBackupFile", "tail log backup file");
optionValues.Options.TryAdd("TailLogWithNoRecovery", false);
optionValues.Options.TryAdd(RestoreOptionsHelper.BackupTailLog, false);
optionValues.Options.TryAdd(RestoreOptionsHelper.KeepReplication, false);
optionValues.Options.TryAdd(RestoreOptionsHelper.ReplaceDatabase, false);
optionValues.Options.TryAdd(RestoreOptionsHelper.SetRestrictedUser, false);
optionValues.Options.TryAdd(RestoreOptionsHelper.StandbyFile, "Stand by file");
optionValues.Options.TryAdd(RestoreOptionsHelper.RecoveryState, DatabaseRecoveryState.WithNoRecovery.ToString());
optionValues.Options.TryAdd(RestoreOptionsHelper.TargetDatabaseName, "target db name");
optionValues.Options.TryAdd(RestoreOptionsHelper.SourceDatabaseName, "source db name");
optionValues.Options.TryAdd("CanChangeTargetDatabase", true);
optionValues.Options.TryAdd("DefaultSourceDbName", "DefaultSourceDbName");
optionValues.Options.TryAdd("DefaultTargetDbName", "DefaultTargetDbName");
optionValues.Options.TryAdd("SourceDbNames", new List<string>());
optionValues.Options.TryAdd("CanDropExistingConnections", true);
return optionValues;
}