Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #7 from GoEddie/UniqueTests
Browse files Browse the repository at this point in the history
visual studio 2017 version
  • Loading branch information
GoEddie authored May 18, 2017
2 parents 5f577f9 + aaf9199 commit 43f328c
Show file tree
Hide file tree
Showing 18 changed files with 209 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AgileSQLClub.tSQLtTestController</RootNamespace>
<AssemblyName>AgileSQLClub.tSQLtTestController</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
Expand Down Expand Up @@ -62,7 +62,7 @@
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestWindow.Core">
<HintPath>..\..\..\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestWindow.Core.dll</HintPath>
<HintPath>..\..\..\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestWindow.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down Expand Up @@ -103,9 +103,6 @@
</Compile>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>C:\"Program Files (x86)"\"Windows Kits"\10\bin\x64\signtool.exe sign /t "http://timestamp.globalsign.com/scripts/timstamp.dll" $(TargetPath)</PostBuildEvent>
</PropertyGroup>
<!-- 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">
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion AgileSQLClub.tSQLtTestController/TestClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ public class FileScanner
{
private readonly TSqlParser _parser;

public FileScanner()
{
_parser = new TSql130Parser(true);
}

public FileScanner(TSqlParser parser)
{
_parser = parser;
}

public ScanResults ScanCode(string code, ScanResults results, string path)
public virtual ScanResults ScanCode(string code, ScanResults results, string path)
{
var batches = code.Split(new[] {"\r\nGO\r\n", "\nGO\n"}, StringSplitOptions.None);
var offset = 0;
Expand Down
42 changes: 42 additions & 0 deletions Test/UnitTests/TestCacheTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AgileSQLClub.tSQLtTestController;
using Moq;
using NUnit.Framework;
using tSQLtTestAdapter;

namespace UnitTests
{
[TestFixture]
public class TestCacheTests
{
[Test]
public void DiscardsDuplicates()
{
var mockScanner = new Mock<FileScanner>();

mockScanner.Setup(p => p.ScanCode(It.IsAny<string>(), It.IsAny<ScanResults>(), It.IsAny<string>())).Returns((
string a, ScanResults result, string b) =>
{
result.FoundClasses.Add(new SqlSchema("Schema", "PathA"));
result.FoundClasses.Add(new SqlSchema("Schema", "PathB"));
result.FoundClasses.Add(new SqlSchema("Schema", "PathB"));

result.FoundPotentialTests.Add(new SqlProcedure(new SqlObjectName() {Object = "test", Schema = "Schema"}, "Patha", 0, 100, 1));
result.FoundPotentialTests.Add(new SqlProcedure(new SqlObjectName() { Object = "test", Schema = "Schema" }, "Pathb", 0, 100, 1));
return result;
});

var mockFileReader = new Mock<IFileReader>();
mockFileReader.Setup(p => p.ReadAll(It.IsAny<string>())).Returns("Blah");
mockFileReader.Setup(p => p.GetLastWriteTimeUtc(It.IsAny<string>())).Returns(DateTime.MaxValue);

var testCache = new TestCache(mockScanner.Object, mockFileReader.Object);
testCache.AddPath("path");
Assert.AreEqual(1, testCache.GetTests().Count);
}
}
}
16 changes: 15 additions & 1 deletion Test/UnitTests/UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>UnitTests</RootNamespace>
<AssemblyName>UnitTests</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -30,6 +31,10 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<HintPath>..\..\packages\Castle.Core.4.0.0\lib\net45\Castle.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Tools.Schema.Sql, Version=13.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.SqlServer.DacFx.x64.130.3411.1\lib\net40\Microsoft.Data.Tools.Schema.Sql.dll</HintPath>
<Private>True</Private>
Expand All @@ -54,6 +59,10 @@
<HintPath>..\..\packages\Microsoft.SqlServer.DacFx.x64.130.3411.1\lib\net40\Microsoft.SqlServer.Types.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Moq, Version=4.7.1.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\..\packages\Moq.4.7.1\lib\net45\Moq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nunit.framework, Version=3.2.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnit.3.2.1\lib\net45\nunit.framework.dll</HintPath>
<Private>True</Private>
Expand All @@ -69,6 +78,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="FileScannerTests.cs" />
<Compile Include="TestCacheTests.cs" />
<Compile Include="tSQLtTestFinderTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand All @@ -80,6 +90,10 @@
<Project>{35E9ACF7-2A97-4160-AB4E-42F4C4EA16CD}</Project>
<Name>AgileSQLClub.tSQLtTestController</Name>
</ProjectReference>
<ProjectReference Include="..\..\XmlTestAdapter\tSQLtTestAdapter.csproj">
<Project>{BC4B3BED-9241-4DD6-8070-A9B66DFC08C1}</Project>
<Name>tSQLtTestAdapter</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.
Expand Down
2 changes: 2 additions & 0 deletions Test/UnitTests/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Castle.Core" version="4.0.0" targetFramework="net452" />
<package id="Microsoft.SqlServer.DacFx.x64" version="130.3411.1" targetFramework="net452" />
<package id="Moq" version="4.7.1" targetFramework="net452" />
<package id="NUnit" version="3.2.1" targetFramework="net452" />
</packages>
17 changes: 11 additions & 6 deletions XMLTestAdapterVSIX/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="AgileSQLClub.tSQLtTestAdapter" Version="0.63" Language="en-US" Publisher="EdElliott" />
<DisplayName>tSQLt Test Adapter</DisplayName>
<Identity Id="AgileSQLClub.tSQLtTestAdapter15" Version="0.80" Language="en-US" Publisher="EdElliott" />
<DisplayName>tSQLt Test Adapter for Visual Studio 2017</DisplayName>
<Description xml:space="preserve">Unit Test Adapter for tSQLt Tests</Description>
<MoreInfo>https://the.agilsql.club/projects/tSQLt-Test-Adapter</MoreInfo>
<License>LICENSE</License>
<Tags>tSQLt, Test, Adapter</Tags>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Pro" Version="[14.0,15.0)" />
<InstallationTarget Version="[14.0,15.0)" Id="Microsoft.VisualStudio.Ultimate" />
<InstallationTarget Version="[14.0,15.0)" Id="Microsoft.VisualStudio.Premium" />

<InstallationTarget Version="[15.0,16.0)" Id="Microsoft.VisualStudio.Pro" />
<InstallationTarget Version="[15.0,16.0)" Id="Microsoft.VisualStudio.Ultimate" />
<InstallationTarget Version="[15.0,16.0)" Id="Microsoft.VisualStudio.Community" />
<InstallationTarget Version="[15.0,16.0)" Id="Microsoft.VisualStudio.Enterprise" />
</Installation>
<Dependencies>
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="4.5" />
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="4.6" />
</Dependencies>
<Assets>
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="tSQLtTestAdapter" Path="|tSQLtTestAdapter|" />
<Asset Type="UnitTestExtension" d:Source="Project" d:ProjectName="tSQLtTestAdapter" Path="|tSQLtTestAdapter|" />
<Asset Type="Microsoft.VisualStudio.Assembly" d:Source="Project" d:ProjectName="AgileSQLClub.tSQLtTestController" Path="|AgileSQLClub.tSQLtTestController|" AssemblyName="|AgileSQLClub.tSQLtTestController;AssemblyName|" />
</Assets>
<Prerequisites>
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[15.0,16.0)" />
</Prerequisites>
</PackageManifest>
6 changes: 3 additions & 3 deletions XMLTestAdapterVSIX/tSQLtTestAdapterVSIX.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">11.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>4.0</OldToolsVersion>
<OldToolsVersion>12.0</OldToolsVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
Expand All @@ -22,7 +22,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>tSQLtTestAdapterVSIX</RootNamespace>
<AssemblyName>tSQLtTestAdapter</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<GeneratePkgDefFile>false</GeneratePkgDefFile>
<IncludeAssemblyInVSIXContainer>false</IncludeAssemblyInVSIXContainer>
<IncludeDebugSymbolsInVSIXContainer>false</IncludeDebugSymbolsInVSIXContainer>
Expand Down
1 change: 1 addition & 0 deletions XmlTestAdapter/Helpers/RunSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Xml.Linq;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter;


namespace tSQLtTestAdapter.Helpers
{
class RunSettings
Expand Down
9 changes: 6 additions & 3 deletions XmlTestAdapter/Helpers/SolutionEventsListener.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;


namespace tSQLtTestAdapter.Helpers
{
[Export(typeof(ISolutionEventsListener))]

[Export(typeof(ISolutionEventsListener))]
public class SolutionEventsListener : IVsSolutionEvents, ISolutionEventsListener
{
private readonly IVsSolution solution;
Expand All @@ -23,7 +25,8 @@ public class SolutionEventsListener : IVsSolutionEvents, ISolutionEventsListener
[ImportingConstructor]
public SolutionEventsListener([Import(typeof(SVsServiceProvider))]IServiceProvider serviceProvider)
{
ValidateArg.NotNull(serviceProvider, "serviceProvider");
//Has been made internal in 2017 agghhhhh!
// ValidateArg.NotNull(serviceProvider, "serviceProvider");
this.solution = serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
}

Expand Down
4 changes: 2 additions & 2 deletions XmlTestAdapter/Helpers/TestFileAddRemoveListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;


namespace tSQLtTestAdapter.Helpers
{
Expand All @@ -18,7 +18,7 @@ public sealed class TestFileAddRemoveListener : IVsTrackProjectDocumentsEvents2,
[ImportingConstructor]
public TestFileAddRemoveListener([Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider)
{
ValidateArg.NotNull(serviceProvider, "serviceProvider");
// ValidateArg.NotNull(serviceProvider, "serviceProvider");

projectDocTracker = serviceProvider.GetService(typeof(SVsTrackProjectDocuments)) as IVsTrackProjectDocuments2;
}
Expand Down
5 changes: 2 additions & 3 deletions XmlTestAdapter/Helpers/TestFilesUpdateWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.ComponentModel.Composition;
using System.IO;
using System.Windows.Forms;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;

namespace tSQLtTestAdapter.Helpers
{
Expand Down Expand Up @@ -32,7 +31,7 @@ public TestFilesUpdateWatcher()

public void AddWatch(string path)
{
ValidateArg.NotNullOrEmpty(path, "path");
//ValidateArg.NotNullOrEmpty(path, "path");

if (!String.IsNullOrEmpty(path))
{
Expand Down Expand Up @@ -63,7 +62,7 @@ public void AddWatch(string path)

public void RemoveWatch(string path)
{
ValidateArg.NotNullOrEmpty(path, "path");
//ValidateArg.NotNullOrEmpty(path, "path");

if (!String.IsNullOrEmpty(path))
{
Expand Down
10 changes: 10 additions & 0 deletions XmlTestAdapter/IFileReader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

namespace tSQLtTestAdapter
{
public interface IFileReader
{
DateTime GetLastWriteTimeUtc(string path);
string ReadAll(string path);
}
}
4 changes: 2 additions & 2 deletions XmlTestAdapter/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// 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("0.0.0.2")]
[assembly: AssemblyFileVersion("0.0.0.2")]
[assembly: AssemblyVersion("0.0.0.3")]
[assembly: AssemblyFileVersion("0.0.0.3")]
Loading

0 comments on commit 43f328c

Please sign in to comment.