Permalink
Browse files

Added tests, including failing test for #800

  • Loading branch information...
khellang committed May 28, 2014
1 parent 8f05d51 commit 0fe7d0e72de89b5e90cf312b803318451b1eda3c
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30110.0
VisualStudioVersion = 12.0.30501.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{CCFACE51-18FA-4C5D-9F89-EC58881786A9}"
EndProject
@@ -113,11 +113,14 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Glimpse.WindowsAzure.WebRole.Sample", "source\Glimpse.WindowsAzure.WebRole.Sample\Glimpse.WindowsAzure.WebRole.Sample.csproj", "{FE76DB8B-5FE3-4F25-B816-4EF2E6F20FFB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Glimpse.Mvc5.MusicStore.Sample", "source\Glimpse.Mvc5.MusicStore.Sample\Glimpse.Mvc5.MusicStore.Sample.csproj", "{B373218F-19BB-4D5E-9EA7-000FDFD9BE5D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".items", ".items", "{EC933034-7250-4B53-A041-0D5DF203712B}"
ProjectSection(SolutionItems) = preProject
source\Settings.StyleCop = source\Settings.StyleCop
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Glimpse.Test.Ado", "Glimpse.Test.Ado\Glimpse.Test.Ado.csproj", "{A38DA38F-8669-4B99-9DE8-51BF747B9A67}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -588,29 +591,37 @@ Global
{B373218F-19BB-4D5E-9EA7-000FDFD9BE5D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{B373218F-19BB-4D5E-9EA7-000FDFD9BE5D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{B373218F-19BB-4D5E-9EA7-000FDFD9BE5D}.Release|x86.ActiveCfg = Release|Any CPU
{A38DA38F-8669-4B99-9DE8-51BF747B9A67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A38DA38F-8669-4B99-9DE8-51BF747B9A67}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A38DA38F-8669-4B99-9DE8-51BF747B9A67}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{A38DA38F-8669-4B99-9DE8-51BF747B9A67}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{A38DA38F-8669-4B99-9DE8-51BF747B9A67}.Debug|x86.ActiveCfg = Debug|Any CPU
{A38DA38F-8669-4B99-9DE8-51BF747B9A67}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A38DA38F-8669-4B99-9DE8-51BF747B9A67}.Release|Any CPU.Build.0 = Release|Any CPU
{A38DA38F-8669-4B99-9DE8-51BF747B9A67}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{A38DA38F-8669-4B99-9DE8-51BF747B9A67}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{A38DA38F-8669-4B99-9DE8-51BF747B9A67}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{32DCD27D-A84C-4250-B657-408B3620A9AC} = {CCFACE51-18FA-4C5D-9F89-EC58881786A9}
{C2C38EE9-01B7-4929-B7E9-086077D1AB58} = {CCFACE51-18FA-4C5D-9F89-EC58881786A9}
{214472C2-5C93-440A-8E14-BADC49CA6FE6} = {CCFACE51-18FA-4C5D-9F89-EC58881786A9}
{4288D838-C35F-4226-AEAD-766A19CF31CD} = {CCFACE51-18FA-4C5D-9F89-EC58881786A9}
{B373218F-19BB-4D5E-9EA7-000FDFD9BE5D} = {CCFACE51-18FA-4C5D-9F89-EC58881786A9}
{13FEFF53-9CD2-4BF1-9128-A60F99E5532F} = {44EAFB31-C422-4B52-BBCE-18A3E95713DC}
{9923BFBD-EA73-4719-A418-213003862550} = {A3097EAF-9D1B-416A-822E-F679D768BC55}
{76714E46-AFE9-49F0-AEE8-C8A966195914} = {A3097EAF-9D1B-416A-822E-F679D768BC55}
{FE12BC0C-CD22-4D24-BFC7-13ED1C428BAD} = {A3097EAF-9D1B-416A-822E-F679D768BC55}
{BC28BB90-8BF2-4D54-B96E-0E0181DDF432} = {A3097EAF-9D1B-416A-822E-F679D768BC55}
{13FEFF53-9CD2-4BF1-9128-A60F99E5532F} = {44EAFB31-C422-4B52-BBCE-18A3E95713DC}
{32DCD27D-A84C-4250-B657-408B3620A9AC} = {CCFACE51-18FA-4C5D-9F89-EC58881786A9}
{22E8C0B0-E32F-4598-896F-81F3A6BD9862} = {44EAFB31-C422-4B52-BBCE-18A3E95713DC}
{E242E3FC-DEF4-45E2-A129-A5DC3B0B8F9B} = {13FEFF53-9CD2-4BF1-9128-A60F99E5532F}
{971143D1-B40E-4AF4-AD3D-D4FFAD3FE444} = {44EAFB31-C422-4B52-BBCE-18A3E95713DC}
{6B8B535F-923B-4083-A5BD-31A34F5230A1} = {44EAFB31-C422-4B52-BBCE-18A3E95713DC}
{BC28BB90-8BF2-4D54-B96E-0E0181DDF432} = {A3097EAF-9D1B-416A-822E-F679D768BC55}
{DD93B23C-E2D7-4283-9F3F-88F87271018B} = {44EAFB31-C422-4B52-BBCE-18A3E95713DC}
{2CB2400F-BC66-4074-B6E4-177A6F78163E} = {44EAFB31-C422-4B52-BBCE-18A3E95713DC}
{DED28E26-8A57-472A-A454-E45643F1DEA0} = {44EAFB31-C422-4B52-BBCE-18A3E95713DC}
{DD576747-CD93-43F0-8648-6CDC5CD9C548} = {44EAFB31-C422-4B52-BBCE-18A3E95713DC}
{585C1C27-8D37-4CB6-BD0F-464487845661} = {44EAFB31-C422-4B52-BBCE-18A3E95713DC}
{C2C38EE9-01B7-4929-B7E9-086077D1AB58} = {CCFACE51-18FA-4C5D-9F89-EC58881786A9}
{D3644A2E-1A2D-42DB-9646-8EDF2855C478} = {44EAFB31-C422-4B52-BBCE-18A3E95713DC}
{1594ADD8-62F8-417B-BD69-131AFBBF51BC} = {44EAFB31-C422-4B52-BBCE-18A3E95713DC}
{EE152A2E-E27F-4329-A40A-6951387D3629} = {44EAFB31-C422-4B52-BBCE-18A3E95713DC}
@@ -620,6 +631,7 @@ Global
{1C1FABFD-768A-4E03-88DD-14E04F6B4DD8} = {44EAFB31-C422-4B52-BBCE-18A3E95713DC}
{90D8F914-7271-466E-8A87-218176C39719} = {44EAFB31-C422-4B52-BBCE-18A3E95713DC}
{6F3F9D55-2BE0-47E8-83D2-0F488504CF4A} = {44EAFB31-C422-4B52-BBCE-18A3E95713DC}
{214472C2-5C93-440A-8E14-BADC49CA6FE6} = {CCFACE51-18FA-4C5D-9F89-EC58881786A9}
{BCDCF0D0-77CF-4589-BE46-C86FE11781E5} = {44EAFB31-C422-4B52-BBCE-18A3E95713DC}
{971143D1-B40E-4AF4-AD3D-D4FFAD3FE555} = {44EAFB31-C422-4B52-BBCE-18A3E95713DC}
{DED28E26-8A57-472A-A454-E45643F1D555} = {44EAFB31-C422-4B52-BBCE-18A3E95713DC}
@@ -628,8 +640,10 @@ Global
{D0A04D21-2403-4458-905E-027F6651823D} = {44EAFB31-C422-4B52-BBCE-18A3E95713DC}
{98DDA3F0-13CC-428E-ABC0-0729C7C55F80} = {44EAFB31-C422-4B52-BBCE-18A3E95713DC}
{DB3BB9CB-F577-42E8-8108-DB17EA0DE113} = {44EAFB31-C422-4B52-BBCE-18A3E95713DC}
{E242E3FC-DEF4-45E2-A129-A5DC3B0B8F9B} = {13FEFF53-9CD2-4BF1-9128-A60F99E5532F}
{4288D838-C35F-4226-AEAD-766A19CF31CD} = {CCFACE51-18FA-4C5D-9F89-EC58881786A9}
{9872CF80-D354-4A19-A28B-B5FE62DA3DF5} = {4288D838-C35F-4226-AEAD-766A19CF31CD}
{FE76DB8B-5FE3-4F25-B816-4EF2E6F20FFB} = {4288D838-C35F-4226-AEAD-766A19CF31CD}
{B373218F-19BB-4D5E-9EA7-000FDFD9BE5D} = {CCFACE51-18FA-4C5D-9F89-EC58881786A9}
{A38DA38F-8669-4B99-9DE8-51BF747B9A67} = {A3097EAF-9D1B-416A-822E-F679D768BC55}
EndGlobalSection
EndGlobal
@@ -0,0 +1,80 @@
using System;
using System.Globalization;
using System.Linq;
using Glimpse.Ado.Model;
using Glimpse.Ado.Tab.Support;
using Xunit;

namespace Glimpse.Test.Ado
{
public class CommandSanitizerShould
{
[Fact]
public void ReplaceParameterPlaceholders()
{
var sut = new CommandSanitizer();

var parameter = new CommandParameterMetadata
{
Name = "@SomeParameter",
Type = typeof(int).Name,
Value = 1234
};

var command = string.Format("SELECT * FROM Table WHERE Id = {0}", parameter.Name);

var result = sut.Process(command, new[] { parameter });

var expected = string.Format(CommandParameterParser.UnquotedFormat, parameter.Value, parameter.Name);

Assert.Contains(expected, result);
}

[Fact]
public void WrapStringsInQuotes()
{
var sut = new CommandSanitizer();

var parameter = new CommandParameterMetadata
{
Name = "@StringParameter",
Type = typeof(string).Name,
Value = "This is the parameter value."
};

var command = string.Format("SELECT * FROM Table WHERE StringColumn = {0}", parameter.Name);

var result = sut.Process(command, new[] { parameter });

var expected = string.Format(CommandParameterParser.QuotedFormat, parameter.Value, parameter.Name);

Assert.Contains(expected, result);
}

[Fact]
public void NotReplacePartialMatches()
{
var sut = new CommandSanitizer();

var parameters = Enumerable.Range(1, 30).Select(x => new CommandParameterMetadata
{
Name = "@Id" + x,
Type = typeof(int).Name,
Value = x
}).ToList();

var parameterList = string.Join(", ", parameters.Select(x => x.Name));

var command = string.Format("SELECT * FROM Table WHERE Id IN ({0})", parameterList);

var result = sut.Process(command, parameters);

foreach (var parameter in parameters)
{
var expected = string.Format(CommandParameterParser.UnquotedFormat, parameter.Value, parameter.Name);

Assert.Contains(expected, result);
}
}
}
}
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A38DA38F-8669-4B99-9DE8-51BF747B9A67}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Glimpse.Test.Ado</RootNamespace>
<AssemblyName>Glimpse.Test.Ado</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Ploeh.AutoFixture">
<HintPath>..\packages\AutoFixture.2.13.3\lib\net35\Ploeh.AutoFixture.dll</HintPath>
</Reference>
<Reference Include="Ploeh.AutoFixture.Xunit">
<HintPath>..\packages\AutoFixture.Xunit.2.13.3\lib\net35\Ploeh.AutoFixture.Xunit.dll</HintPath>
</Reference>
<Reference Include="Ploeh.SemanticComparison">
<HintPath>..\packages\AutoFixture.2.13.3\lib\net35\Ploeh.SemanticComparison.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="xunit">
<HintPath>..\packages\xunit.1.9.1\lib\net20\xunit.dll</HintPath>
</Reference>
<Reference Include="xunit.extensions">
<HintPath>..\packages\xunit.extensions.1.9.1\lib\net20\xunit.extensions.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="CommandSanitizerShould.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\source\Glimpse.Ado\Glimpse.Ado.csproj">
<Project>{4c993b73-d03a-4080-b31e-c04f23372997}</Project>
<Name>Glimpse.Ado</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
@@ -0,0 +1,37 @@
using System;
using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Glimpse.Test.Ado")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Glimpse.Test.Ado")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("b553177e-ac3e-45c6-b2c1-d5679515a1f2")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: CLSCompliant(false)]
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="xunit.extensions" publicKeyToken="8d05b1bb7a6fdb6c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.9.1.1600" newVersion="1.9.1.1600" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AutoFixture" version="2.13.3" targetFramework="net45" />
<package id="AutoFixture.Xunit" version="2.13.3" targetFramework="net45" />
<package id="xunit" version="1.9.1" targetFramework="net45" />
<package id="xunit.extensions" version="1.9.1" targetFramework="net45" />
</packages>
@@ -4,8 +4,8 @@ namespace Glimpse.Ado.Tab.Support
{
internal class CommandParameterParser : ICommandParameterParser
{
private const string QuotedFormat = "'{0}' /* {1} */";
private const string UnquotedFormat = "{0} /* {1} */";
internal const string QuotedFormat = "'{0}' /* {1} */";
internal const string UnquotedFormat = "{0} /* {1} */";

public CommandParameterParser(bool useQuotes)
{

0 comments on commit 0fe7d0e

Please sign in to comment.