Skip to content

Unitest for dependency bug with vs2013 project #10

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ projects/packages/*
projects/vs2008/slnStartupProject/obj/
projects/vs2008/slnStartupProjectLibrary/obj/
projects/vs2013/slnStartupProject/obj/
projects/vs2013/slnStartupProjectLibrary/obj/
projects/vs2013/slnStartupProjectLibrary/obj/
/tests/data/ExampleProject/.vs
*.db
15 changes: 10 additions & 5 deletions projects/slnStartupProject.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,26 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "slnStartupProject", "vs2013
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "slnStartupProjectLibrary", "vs2013\slnStartupProjectLibrary\slnStartupProjectLibrary.csproj", "{A01E2F2D-CCD1-46B4-82D7-EB4C7A503004}"
EndProject

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "slnStartupProjectUnitTest", "vs2013\slnStartupProjectUnitTest\slnStartupProjectUnitTest.csproj", "{BBE2A7B3-5A0F-4326-AD58-BD6D3F7B956C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A01E2F2D-CCD1-46B4-82D7-EB4C7A503004}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A01E2F2D-CCD1-46B4-82D7-EB4C7A503004}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A01E2F2D-CCD1-46B4-82D7-EB4C7A503004}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A01E2F2D-CCD1-46B4-82D7-EB4C7A503004}.Release|Any CPU.Build.0 = Release|Any CPU
{4DB074A8-D175-41C7-BAAF-00F2F73C970E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4DB074A8-D175-41C7-BAAF-00F2F73C970E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4DB074A8-D175-41C7-BAAF-00F2F73C970E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4DB074A8-D175-41C7-BAAF-00F2F73C970E}.Release|Any CPU.Build.0 = Release|Any CPU
{A01E2F2D-CCD1-46B4-82D7-EB4C7A503004}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A01E2F2D-CCD1-46B4-82D7-EB4C7A503004}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A01E2F2D-CCD1-46B4-82D7-EB4C7A503004}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A01E2F2D-CCD1-46B4-82D7-EB4C7A503004}.Release|Any CPU.Build.0 = Release|Any CPU
{BBE2A7B3-5A0F-4326-AD58-BD6D3F7B956C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BBE2A7B3-5A0F-4326-AD58-BD6D3F7B956C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BBE2A7B3-5A0F-4326-AD58-BD6D3F7B956C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BBE2A7B3-5A0F-4326-AD58-BD6D3F7B956C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
5 changes: 5 additions & 0 deletions projects/vs2013/slnStartupProjectUnitTest/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="3.6.1" targetFramework="net35" />
<package id="NUnit3TestAdapter" version="3.7.0" targetFramework="net35" />
</packages>
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{BBE2A7B3-5A0F-4326-AD58-BD6D3F7B956C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>slnStartupProjectUnitTest</RootNamespace>
<AssemblyName>slnStartupProjectUnitTest</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
</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="nunit.framework, Version=3.6.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnit.3.6.1\lib\net35\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\..\src\slnStartupProjectUnitTest\Properties\AssemblyInfo.cs">
<Link>AssemblyInfo.cs</Link>
</Compile>
<Compile Include="..\..\..\src\slnStartupProjectUnitTest\UnitTest.cs">
<Link>UnitTest.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<ProjectReference Include="..\slnStartupProjectLibrary\slnStartupProjectLibrary.csproj">
<Project>{a01e2f2d-ccd1-46b4-82d7-eb4c7a503004}</Project>
<Name>slnStartupProjectLibrary</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</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>
16 changes: 16 additions & 0 deletions src/slnStartupProjectUnitTest/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("slnStartupProjectUnitTest")]
[assembly: AssemblyDescription("A .NET library to set the default StartUp project of a Visual Studio solution file")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("iVoltage")]
[assembly: AssemblyProduct("sln StartUp Project UnitTest")]
[assembly: AssemblyCopyright("Copyright © Michel Courtine 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("bbe2a7b3-5a0f-4326-ad58-bd6d3f7b956c")]
[assembly: AssemblyVersion("1.1.1.0")]
[assembly: AssemblyFileVersion("1.1.1.0")]
101 changes: 101 additions & 0 deletions src/slnStartupProjectUnitTest/UnitTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Reflection;
using NUnit.Framework;
using slnStartupProjectLibrary;

namespace slnStartupUnitTest
{
[TestFixture]
public class UnitTest
{
readonly Assembly assemby = Assembly.GetAssembly(typeof(UnitTest));
private string testSolutionDirectory;

/// <summary>
/// SetUp
/// </summary>
[SetUp]
public void SetUp()
{
testSolutionDirectory = GetTestSolutionDirectory();
}

/// <summary>
/// TearDown
/// </summary>
[TearDown]
public void TearDown()
{
}

/// <summary>
/// Run Test when the solution has dependencies and doesn't have BOM.
/// </summary>
[Test]
public void Run()
{
var baseSolution = Path.Combine(testSolutionDirectory, "ExampleProject.sln");
var processedSolution = Path.Combine(testSolutionDirectory, "ExampleProjectProcessed.sln");
var tempSolution = Path.Combine(testSolutionDirectory, "ExampleProjectTemp.sln");

if (File.Exists(tempSolution))
{
File.Delete(tempSolution);
}
File.Copy(baseSolution, tempSolution);
Parser.SetStartupProject(tempSolution, "ExampleProject");

FileAssert.AreEqual(processedSolution, tempSolution);

File.Delete(tempSolution);
}


/// <summary>
/// Run Test when the solution has dependencies and has BOM.
/// </summary>
[Test]
public void RunWithBOM()
{
var baseSolution = Path.Combine(testSolutionDirectory, "ExampleProjectBOM.sln");
var processedSolution = Path.Combine(testSolutionDirectory, "ExampleProjectProcessedBOM.sln");
var tempSolution = Path.Combine(testSolutionDirectory, "ExampleProjectTemp.sln");

if (File.Exists(tempSolution))
{
File.Delete(tempSolution);
}
File.Copy(baseSolution, tempSolution);
Parser.SetStartupProject(tempSolution, "ExampleProject");

FileAssert.AreEqual(processedSolution, tempSolution);

File.Delete(tempSolution);
}

/// <summary>
/// Get the Directory of the Assemby
/// </summary>
/// <returns></returns>
private string GetAssembyDirectory()
{
var assembyPath = this.assemby.Location;
var assembyDirecctory = Path.GetDirectoryName(assembyPath);
return assembyDirecctory;
}

/// <summary>
/// Get the Directory of test solution
/// </summary>
/// <returns></returns>
private string GetTestSolutionDirectory()
{
var testSolutionDirecotry = Path.GetFullPath(Path.Combine(GetAssembyDirectory(), @"..\..\tests\data\ExampleProject"));
return testSolutionDirecotry;
}
}
}
139 changes: 139 additions & 0 deletions tests/data/ExampleProject/ExampleLibrary/ExampleLibrary.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Library.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Library.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{7C961FE3-7761-4E1D-B533-4FD5F6D1AC82}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>ExampleLibrary</RootNamespace>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
Loading