Files
sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/BatchParser/TestVariableResolver.cs
Karl Burtram 022282800a Move managed parser into its own project (test code coverage) (#774)
* Created New ManagedBatchParser project in .NetStandard

* Addressing PR Comments

* Resolve 'No Repository' warning.

* Move batch parser tests to integrations test project

* Fix SLN file
2019-02-07 20:13:03 -08:00

49 lines
1.3 KiB
C#

//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlTools.ServiceLayer.BatchParser;
namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
{
internal sealed class TestVariableResolver : IVariableResolver
{
Dictionary<string, string> variables = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
private StringBuilder outputString;
public TestVariableResolver(StringBuilder outputString)
{
this.outputString = outputString;
}
public string GetVariable(PositionStruct pos, string name)
{
if (variables.ContainsKey(name))
{
return variables[name];
}
else
{
return null;
}
}
public void SetVariable(PositionStruct pos, string name, string value)
{
outputString.AppendFormat("Setting variable {0} to [{1}]\n", name, value);
if (value == null)
{
variables.Remove(name);
}
else
{
variables[name] = value;
}
}
}
}