Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for csv x64 scenario #329

Merged
merged 5 commits into from
Dec 8, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions TestFx.sln
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ParallelMethodsTestProject"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ParallelClassesTestProject", "test\E2ETests\TestAssets\ParallelTestClass\ParallelClassesTestProject.csproj", "{CD0CA7CD-CED3-45FF-9F36-B1C8DF7A9220}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataSourceTestProject", "test\E2ETests\TestAssets\DataSourceTestProject\DataSourceTestProject.csproj", "{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\TestFramework\Extension.Shared\Extension.Shared.projitems*{272ca5e1-8e81-4825-9e47-86cce02f700d}*SharedItemsImports = 13
Expand Down Expand Up @@ -909,6 +911,30 @@ Global
{CD0CA7CD-CED3-45FF-9F36-B1C8DF7A9220}.Release|x64.Build.0 = Release|Any CPU
{CD0CA7CD-CED3-45FF-9F36-B1C8DF7A9220}.Release|x86.ActiveCfg = Release|Any CPU
{CD0CA7CD-CED3-45FF-9F36-B1C8DF7A9220}.Release|x86.Build.0 = Release|Any CPU
{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}.Code Analysis Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}.Code Analysis Debug|Any CPU.Build.0 = Debug|Any CPU
{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}.Code Analysis Debug|ARM.ActiveCfg = Debug|Any CPU
{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}.Code Analysis Debug|ARM.Build.0 = Debug|Any CPU
{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}.Code Analysis Debug|x64.ActiveCfg = Debug|Any CPU
{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}.Code Analysis Debug|x64.Build.0 = Debug|Any CPU
{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}.Code Analysis Debug|x86.ActiveCfg = Debug|Any CPU
{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}.Code Analysis Debug|x86.Build.0 = Debug|Any CPU
{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}.Debug|ARM.ActiveCfg = Debug|Any CPU
{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}.Debug|ARM.Build.0 = Debug|Any CPU
{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}.Debug|x64.ActiveCfg = Debug|Any CPU
{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}.Debug|x64.Build.0 = Debug|Any CPU
{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}.Debug|x86.ActiveCfg = Debug|Any CPU
{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}.Debug|x86.Build.0 = Debug|Any CPU
{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}.Release|Any CPU.Build.0 = Release|Any CPU
{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}.Release|ARM.ActiveCfg = Release|Any CPU
{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}.Release|ARM.Build.0 = Release|Any CPU
{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}.Release|x64.ActiveCfg = Release|Any CPU
{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}.Release|x64.Build.0 = Release|Any CPU
{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}.Release|x86.ActiveCfg = Release|Any CPU
{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -963,6 +989,7 @@ Global
{655001BB-C00F-4EF7-A324-7F7C48656D35} = {F2D0BF2C-38F2-4244-80E3-4AAD1C3F4C89}
{4004757A-0082-4410-B94A-6166B20F153C} = {D53BD452-F69F-4FB3-8B98-386EDA28A4C8}
{CD0CA7CD-CED3-45FF-9F36-B1C8DF7A9220} = {D53BD452-F69F-4FB3-8B98-386EDA28A4C8}
{1A63671D-FD36-4880-AF13-C2AF13F7E3DA} = {D53BD452-F69F-4FB3-8B98-386EDA28A4C8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {31E0F4D5-975A-41CC-933E-545B2201FAF9}
Expand Down
12 changes: 11 additions & 1 deletion src/Adapter/PlatformServices.Desktop/Data/CsvDataConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ internal sealed class CsvDataConnection : TestDataConnection
{
// Template used to map from a filename to a DB connection string
private const string CsvConnectionTemplate = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Persist Security Info=False;Extended Properties=\"text;HDR=YES;FMT=Delimited\"";
private const string CsvConnectionTemplate64 = "Provider=Microsoft.Ace.OLEDB.12.0;Data Source={0};Persist Security Info=False;Extended Properties=\"text;HDR=YES;FMT=Delimited\"";

private string fileName;

Expand Down Expand Up @@ -93,7 +94,16 @@ public DataTable ReadTable(string tableName, IEnumerable columns, int maxRows)
using (OleDbCommand command = new OleDbCommand())
{
// We have to use the name of the folder which contains the CSV file in the connection string
connection.ConnectionString = string.Format(CultureInfo.InvariantCulture, CsvConnectionTemplate, Path.GetDirectoryName(fullPath));
// If target platform is x64, then use CsvConnectionTemplate64 connection string.
if (IntPtr.Size == 8)
{
connection.ConnectionString = string.Format(CultureInfo.InvariantCulture, CsvConnectionTemplate64, Path.GetDirectoryName(fullPath));
}
else
{
connection.ConnectionString = string.Format(CultureInfo.InvariantCulture, CsvConnectionTemplate, Path.GetDirectoryName(fullPath));
}

WriteDiagnostics("Connection String: {0}", connection.ConnectionString);

// We have to open the connection now, before we try to quote
Expand Down
28 changes: 28 additions & 0 deletions test/E2ETests/Smoke.E2E.Tests/DataSourceTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace MSTestAdapter.Smoke.E2ETests
{
using Microsoft.MSTestV2.CLIAutomation;
using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass]
public class DataSourceTests : CLITestBase
{
private const string TestAssembly = "DataSourceTestProject.dll";

[TestMethod]
public void ExecuteCsvTestDataSourceTests()
{
this.InvokeVsTestForExecution(new string[] { TestAssembly });

this.ValidatePassedTestsContain(
"CsvTestMethod (Data Row 0)",
"CsvTestMethod (Data Row 2)");

this.ValidateFailedTestsContain(
"CsvTestMethod (Data Row 1)",
"CsvTestMethod (Data Row 3)");
}
}
}
1 change: 1 addition & 0 deletions test/E2ETests/Smoke.E2E.Tests/Smoke.E2E.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="AssertExtensibilityTests.cs" />
<Compile Include="DataSourceTests.cs" />
<Compile Include="DesktopCSharpCLITests.cs" />
<Compile Include="ParallelExecutionTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TestFxRoot Condition="$(TestFxRoot) == ''">..\..\..\..\</TestFxRoot>
</PropertyGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1A63671D-FD36-4880-AF13-C2AF13F7E3DA}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DataSourceTestProject</RootNamespace>
<AssemblyName>DataSourceTestProject</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<OutputPath>$(TestFxRoot)artifacts\TestAssets\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
</ItemGroup>
<ItemGroup>
<Compile Include="UnitTest1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\src\TestFramework\Extension.Desktop\Extension.Desktop.csproj">
<Project>{a7ea583b-a2b0-47da-a058-458f247c7575}</Project>
<Name>Extension.Desktop</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\src\TestFramework\MSTest.Core\MSTest.Core.csproj">
<Project>{7252d9e3-267d-442c-96bc-c73aef3241d6}</Project>
<Name>MSTest.Core</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="a.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

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

[assembly: AssemblyTitle("DataSourceTestProject")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DataSourceTestProject")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: ComVisible(false)]

[assembly: Guid("1a63671d-fd36-4880-af13-c2af13f7e3da")]

// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
23 changes: 23 additions & 0 deletions test/E2ETests/TestAssets/DataSourceTestProject/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace DataSourceTestProject
{
using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass]
public class UnitTest1
{
public TestContext TestContext
{
get;
set;
}

[TestMethod, DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "a.csv", "a#csv", DataAccessMethod.Sequential)]
public void CsvTestMethod()
{
Assert.AreEqual(1, TestContext.DataRow["Item1"]);
}
}
}
5 changes: 5 additions & 0 deletions test/E2ETests/TestAssets/DataSourceTestProject/a.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Item1,Item2,Item3
1,2,3
4,5,6
1,7,8
9,10,11