Skip to content

Commit

Permalink
Migrate tests to VS 2017
Browse files Browse the repository at this point in the history
Migrate the unit tests to the Visual Studio 2017 project system and
MSTest v2.
  • Loading branch information
martincostello committed Apr 17, 2017
1 parent 6bbb2fb commit bf11aec
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 201 deletions.
2 changes: 0 additions & 2 deletions CommonAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
// </summary>
// --------------------------------------------------------------------------------------------------------------------

using System;
using System.Reflection;
using System.Runtime.InteropServices;

[assembly: AssemblyCulture("")]
[assembly: AssemblyProduct("System.Data.SqlLocalDb")]
[assembly: AssemblyTrademark("")]

[assembly: CLSCompliant(true)]
[assembly: ComVisible(false)]
6 changes: 2 additions & 4 deletions src/SqlLocalDb.UnitTests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
// </summary>
// --------------------------------------------------------------------------------------------------------------------

using System.Reflection;
using System;

[assembly: AssemblyTitle("System.Data.SqlLocalDb.UnitTests")]
[assembly: AssemblyDescription("System.Data.SqlLocalDb Unit Tests")]
[assembly: AssemblyProduct("System.Data.SqlLocalDb.UnitTests")]
[assembly: CLSCompliant(false)]
3 changes: 1 addition & 2 deletions src/SqlLocalDb.UnitTests/SqlLocalDbApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -644,12 +644,11 @@ public void SqlLocalDbApi_GetVersionInfo_Returns_Version_Information()
Assert.IsNotNull(result.Name, "ISqlLocalDbVersionInfo.Name is null.");
Assert.IsNotNull(result.Version, "ISqlLocalDbVersionInfo.Version is null.");

StringAssert.StartsWith(result.Name, version, "ISqlLocalDbVersionInfo.Name is incorrect.");
StringAssert.StartsWith(result.Name, version.Split('.').FirstOrDefault(), "ISqlLocalDbVersionInfo.Name is incorrect.");

Version versionFromString = new Version(version);

Assert.AreEqual(versionFromString.Major, result.Version.Major, "ISqlLocalDbVersionInfo.Version.Major is incorrect.");
Assert.AreEqual(versionFromString.Minor, result.Version.Minor, "ISqlLocalDbVersionInfo.Version.Minor is incorrect.");
}

[TestMethod]
Expand Down
8 changes: 4 additions & 4 deletions src/SqlLocalDb.UnitTests/SqlLocalDbProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ public void SqlLocalDbProvider_CreateInstance_Creates_Instance()
Assert.IsFalse(info.IsRunning, "ISqlLocalDbInstanceInfo.IsRunning is incorrect.");

Assert.AreEqual(
new Version(target.Version),
new Version(info.LocalDbVersion.Major, info.LocalDbVersion.Minor),
new Version(target.Version).Major,
info.LocalDbVersion.Major,
"ISqlLocalDbInstanceInfo.LocalDbVersion is incorrect.");

Guid guid;
Expand Down Expand Up @@ -134,8 +134,8 @@ public void SqlLocalDbProvider_CreateInstance_Creates_Instance_With_Specified_Na
Assert.IsFalse(info.IsRunning, "ISqlLocalDbInstanceInfo.IsRunning is incorrect.");

Assert.AreEqual(
new Version(target.Version),
new Version(info.LocalDbVersion.Major, info.LocalDbVersion.Minor),
new Version(target.Version).Major,
info.LocalDbVersion.Major,
"ISqlLocalDbInstanceInfo.LocalDbVersion is incorrect.");
}
finally
Expand Down
200 changes: 17 additions & 183 deletions src/SqlLocalDb.UnitTests/System.Data.SqlLocalDb.UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,194 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\SqlLocalDb.Common.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{AA95196F-ADCA-4FF8-A52D-53B1E24DF81F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<Description>Tests for System.Data.SqlLocalDb.</Description>
<PreserveCompilationContext>true</PreserveCompilationContext>
<RootNamespace>System.Data.SqlLocalDb</RootNamespace>
<AssemblyName>System.Data.SqlLocalDb.UnitTests</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<TargetFrameworkProfile />
<TargetFramework>net451</TargetFramework>
</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>
<Prefer32Bit>false</Prefer32Bit>
</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>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Moq, Version=4.2.1502.911, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Moq.4.2.1502.0911\lib\net40\Moq.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Data.Entity" />
<Reference Include="System.XML" />
</ItemGroup>
<ItemGroup>
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
<Visible>False</Visible>
</CodeAnalysisDependentAssemblyPaths>
</ItemGroup>
<ItemGroup>
<Compile Include="..\AssemblyVersion.cs">
<Link>AssemblyVersion.cs</Link>
</Compile>
<Compile Include="..\CommonAssemblyInfo.cs">
<Link>CommonAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Configuration\SqlLocalDbConfigurationSectionTests.cs" />
<Compile Include="ErrorAssert.cs" />
<Compile Include="ExtensionsTests.cs" />
<Compile Include="Helpers.cs" />
<Compile Include="IntegrationTests.cs" />
<Compile Include="LoggerTests.cs" />
<Compile Include="NativeMethodsTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SqlLocalDbApiTests.cs" />
<Compile Include="SqlLocalDbConfigTests.cs" />
<Compile Include="SqlLocalDbExceptionTests.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="SqlLocalDbProviderTests.cs" />
<Compile Include="SqlLocalDbInstanceTests.cs" />
<Compile Include="SRHelperTests.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="TemporarySqlLocalDbInstanceTests.cs" />
<Compile Include="TestCategories.cs" />
<Compile Include="EmptyLogger.cs" />
<Compile Include="TestSetup.cs" />
<Compile Include="TraceSourceLoggerTests.cs" />
<Compile Include="..\..\CommonAssemblyInfo.cs" />
<None Include=".\*.config;.\Configuration\*.config;.\*.xml" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SqlLocalDb\System.Data.SqlLocalDb.csproj">
<Project>{B235F2A6-A8A2-4CE6-B3B0-54FFB89DE7DD}</Project>
<Name>System.Data.SqlLocalDb</Name>
</ProjectReference>
<ProjectReference Include="..\SqlLocalDb\System.Data.SqlLocalDb.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="..\AssemblyVersion.targets">
<Link>AssemblyVersion.targets</Link>
</None>
<None Include="..\SqlLocalDb.Common.targets">
<Link>SqlLocalDb.Common.targets</Link>
</None>
<None Include="app.config">
<SubType>Designer</SubType>
</None>
<None Include="Empty.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Configuration\SqlLocalDbConfigurationSectionTests.DefinedAndSpecified.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Configuration\SqlLocalDbConfigurationSectionTests.DefinedButNotSpecified.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ExtensionsTests.MultipleConnectionStrings.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ExtensionsTests.NoConnectionStrings.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="LoggerTests.CustomLoggerType.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
<None Include="SqlLocalDbApiTests.AutomaticallyDeleteInstanceFiles.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SqlLocalDbApiTests.DefaultInstanceName.2012.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SqlLocalDbApiTests.DefaultInstanceName.2016.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SqlLocalDbApiTests.DefaultInstanceName.2014.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SqlLocalDbApiTests.InvalidOverrideVersion.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SqlLocalDbApiTests.PropertiesOverridden.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SqlLocalDbConfigTests.DefinedAndSpecified.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SqlLocalDbConfigTests.DefinedAndSpecifiedWithLegacySettings.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SqlLocalDbConfigTests.DefinedButNotSpecified.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SqlLocalDbConfigTests.DefinedButNotSpecifiedWithLegacySettings.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TraceSourceLoggerTests.AllDisabled.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TraceSourceLoggerTests.AllEnabled.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TraceSourceLoggerTests.SomeDisabled.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Reference Include="System.Configuration" />
<Reference Include="System.Data.Entity" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.1.14" />
<PackageReference Include="MSTest.TestFramework" Version="1.1.14" />
<PackageReference Include="Moq" Version="4.7.8" />
<PackageReference Include="StyleCop.Analyzers" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<CodeAnalysisDictionary Include="..\FxCopDictionary.xml">
<Link>FxCopDictionary.xml</Link>
</CodeAnalysisDictionary>
<None Include="GetPhysicalFileNameTestCases.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType>
</None>
<None Include="SetPhysicalFileNameTestCases.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SetInitialCatalogNameTestCases.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="GetInitialCatalogNameTestCases.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)SqlLocalDb.Common.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>
</Project>
2 changes: 0 additions & 2 deletions src/SqlLocalDb.UnitTests/TemporarySqlLocalDbInstanceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,6 @@ private static ISqlLocalDbInstance CreateMockInstance()
/// </summary>
private sealed class SqlLocalDbInstanceThatCannotBeStarted : SqlLocalDbInstance, ISqlLocalDbInstance
{
/// <inheritdoc />
internal SqlLocalDbInstanceThatCannotBeStarted(string instanceName)
: base(instanceName)
{
Expand All @@ -669,7 +668,6 @@ void ISqlLocalDbInstance.Start()
/// </summary>
private sealed class SqlLocalDbInstanceThatCannotBeStopped : SqlLocalDbInstance, ISqlLocalDbInstance
{
/// <inheritdoc />
internal SqlLocalDbInstanceThatCannotBeStopped(string instanceName)
: base(instanceName)
{
Expand Down
4 changes: 0 additions & 4 deletions src/SqlLocalDb.UnitTests/packages.config

This file was deleted.

1 change: 1 addition & 0 deletions src/SqlLocalDb/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: CLSCompliant(true)]
[assembly: Guid("963628d3-b23b-4b98-9cec-b0a13b00ddef")]

[assembly: InternalsVisibleTo("System.Data.SqlLocalDb.TestApp, PublicKey=00240000048000009400000006020000002400005253413100040000010001004b0b2efbada897147aa03d2076278890aefe2f8023562336d206ec8a719b06e89461c31b43abec615918d509158629f93385930c030494509e418bf396d69ce7dbe0b5b2db1a81543ab42777cb98210677fed69dbeb3237492a7ad69e87a1911ed20eb2d7c300238dc6f6403e3d04a1351c5cb369de4e022b18fbec70f7d21ed")]
Expand Down
2 changes: 2 additions & 0 deletions src/TestApp/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
// </summary>
// --------------------------------------------------------------------------------------------------------------------

using System;
using System.Runtime.InteropServices;

[assembly: CLSCompliant(true)]
[assembly: Guid("b6649785-36c9-46d4-8f86-85bb6ee60c7e")]

[assembly: log4net.Config.XmlConfigurator]

0 comments on commit bf11aec

Please sign in to comment.