Skip to content
This repository was archived by the owner on Sep 13, 2023. It is now read-only.
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
43 changes: 36 additions & 7 deletions src/SlimJim.Test/Infrastructure/ArgsOptionsBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public void SpecifiedTargetProject()

Assert.That(options.TargetProjectNames, Is.EqualTo(new[] { "MyProject" }));
Assert.That(options.SolutionName, Is.EqualTo("MyProject"));

}

[Test]
Expand All @@ -48,7 +47,7 @@ public void SpecifiedMultipleTargetProjects()
options = ArgsOptionsBuilder.BuildOptions(new[] { "--target", "MyProject", "--target", "YourProject" }, WorkingDirectory);

Assert.That(options.TargetProjectNames, Is.EqualTo(new[] { "MyProject", "YourProject" }));
Assert.That(options.SolutionName, Is.StringMatching("MyProject_YourProject"));
Assert.That(options.SolutionName, Does.Match("MyProject_YourProject"));
}

[Test]
Expand Down Expand Up @@ -86,15 +85,47 @@ public void SpecifiedVisualStudioVersion2010()
Assert.That(options.VisualStudioVersion, Is.EqualTo(VisualStudioVersion.VS2010));
}

[Test]
[Test]
public void SpecifiedVisualStudioVersion2012()
{
options = ArgsOptionsBuilder.BuildOptions(new[] { "--version", "2012" }, WorkingDirectory);

Assert.That(options.VisualStudioVersion, Is.EqualTo(VisualStudioVersion.VS2012));
}

[Test]
public void SpecifiedVisualStudioVersion2013()
{
options = ArgsOptionsBuilder.BuildOptions(new[] { "--version", "2013" }, WorkingDirectory);

Assert.That(options.VisualStudioVersion, Is.EqualTo(VisualStudioVersion.VS2013));
}

[Test]
public void SpecifiedVisualStudioVersion2015()
{
options = ArgsOptionsBuilder.BuildOptions(new[] { "--version", "2015" }, WorkingDirectory);

Assert.That(options.VisualStudioVersion, Is.EqualTo(VisualStudioVersion.VS2015));
}

[Test]
public void SpecifiedVisualStudioVersion2017()
{
options = ArgsOptionsBuilder.BuildOptions(new[] { "--version", "2017" }, WorkingDirectory);

Assert.That(options.VisualStudioVersion, Is.EqualTo(VisualStudioVersion.VS2017));
}

[Test]
public void InvalidVisualStudioVersionNumber()
{
options = ArgsOptionsBuilder.BuildOptions(new[] { "--version", "dumb" }, WorkingDirectory);

Assert.That(options.VisualStudioVersion, Is.EqualTo(VisualStudioVersion.VS2015));
Assert.That(options.VisualStudioVersion, Is.EqualTo(VisualStudioVersion.VS2017));
}

[Test]
[Test]
public void SpecifiedSolutionName()
{
options = ArgsOptionsBuilder.BuildOptions(new[] { "--name", "MyProjects" }, WorkingDirectory);
Expand All @@ -106,14 +137,12 @@ public void SpecifiedSolutionName()
public void UnspecifiedSolutionNameWithSingleTargetProject()
{
options = ArgsOptionsBuilder.BuildOptions(new[] { "--target", "MyProject" }, WorkingDirectory);

}

[Test]
public void UnspecifiedSolutionNameWithMultipleTargetProjectsUsesFirstProjectNamePlusSuffix()
{
options = ArgsOptionsBuilder.BuildOptions(new[] { "--target", "MyProject", "--target", "YourProject" }, WorkingDirectory);

}

[Test]
Expand Down
4 changes: 2 additions & 2 deletions src/SlimJim.Test/Infrastructure/ProjectFileFinderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void ReturnsFileInfosForEachProjectInFileSystem()
[Test]
public void IgnoresRelativePath()
{
finder.IgnorePatterns("Theirs");
finder.IgnorePatterns("Their");
projectFiles = finder.FindAllProjectFiles(SampleFileSystemPath);

AssertFilesMatching(new[]
Expand Down Expand Up @@ -80,7 +80,7 @@ public void IgnoresFileName()
[Test]
public void IgnoresRelativePathWithDifferentCase()
{
finder.IgnorePatterns("ThEiRs");
finder.IgnorePatterns("ThEiR");
projectFiles = finder.FindAllProjectFiles(SampleFileSystemPath);

AssertFilesMatching(new[]
Expand Down
25 changes: 22 additions & 3 deletions src/SlimJim.Test/Infrastructure/SlnFileRendererTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,36 @@ public void VisualStudio2008Solution()
TestRender();
}

private void MakeSolution(string name, params CsProj[] csProjs)
[Test]
public void VisualStudio2015Solution()
{
MakeSolution("VS2015");
solution.Version = VisualStudioVersion.VS2015;

TestRender();
}

[Test]
public void VisualStudio2017Solution()
{
MakeSolution("VS2017");
solution.Version = VisualStudioVersion.VS2017;

TestRender();
}

private void MakeSolution(string name, params CsProj[] csProjs)
{
solution = new Sln(name, "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}");
solution.Version = VisualStudioVersion.VS2010;
solution.AddProjects(csProjs);
}

private void TestRender()
{
renderer = new SlnFileRenderer(solution);
renderer = new SlnFileRenderer(solution);

string actualContents = renderer.Render().Replace("\r\n", "\n").Replace("\n\n", "\n");
string actualContents = renderer.Render().Replace("\r\n", "\n").Replace("\n\n", "\n");
string expectedContents = SampleFileHelper.GetSlnFileContents(solution.Name).Replace("\r\n", "\n").Replace("\n\n", "\n");

Assert.That(actualContents, Is.EqualTo(expectedContents));
Expand Down
8 changes: 4 additions & 4 deletions src/SlimJim.Test/Model/SlnTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ namespace SlimJim.Test.Model
public class SlnTests
{
[Test]
public void VersionDefaultsTo2010()
public void VersionDefaultsTo2017()
{
Assert.That(new Sln("sln").Version, Is.EqualTo(VisualStudioVersion.VS2010));
Assert.That(new Sln("sln").Version, Is.EqualTo(VisualStudioVersion.VS2017));
}

[Test]
public void GuidFormatIncludesCurlyBraces()
{
Assert.That(new Sln("sample").Guid, Is.StringStarting("{"));
Assert.That(new Sln("sample").Guid, Is.StringEnding("}"));
Assert.That(new Sln("sample").Guid, Does.StartWith("{"));
Assert.That(new Sln("sample").Guid, Does.EndWith("}"));
}

[Test]
Expand Down
9 changes: 9 additions & 0 deletions src/SlimJim.Test/SampleFiles/Sln/VS2015.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14


Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
9 changes: 9 additions & 0 deletions src/SlimJim.Test/SampleFiles/Sln/VS2017.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15


Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
28 changes: 18 additions & 10 deletions src/SlimJim.Test/SlimJim.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,21 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.5.9.10348\lib\nunit.framework.dll</HintPath>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.8\lib\net40-full\log4net.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nunit.mocks">
<HintPath>..\packages\NUnit.2.5.9.10348\lib\nunit.mocks.dll</HintPath>
<Reference Include="nunit.framework, Version=3.8.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.8.1\lib\net40\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Rhino.Mocks">
<HintPath>..\packages\RhinoMocks.3.6\lib\Rhino.Mocks.dll</HintPath>
<Reference Include="nunit.mocks, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.Mocks.2.6.4\lib\nunit.mocks.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Rhino.Mocks, Version=3.6.0.0, Culture=neutral, PublicKeyToken=0b3305902db7183f, processorArchitecture=MSIL">
<HintPath>..\packages\RhinoMocks.3.6.1\lib\net\Rhino.Mocks.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -47,9 +54,6 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\build\VersionInfo.cs">
Expand Down Expand Up @@ -103,8 +107,12 @@
<Content Include="SampleFiles\Sln\ThreeProjects.sln" />
<Content Include="SampleFiles\Sln\BlankSolution.sln" />
<Content Include="SampleFiles\Sln\SingleProject.sln" />
<Content Include="SampleFiles\Sln\VS2015.sln" />
<Content Include="SampleFiles\Sln\VS2017.sln" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<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.
Expand Down
10 changes: 6 additions & 4 deletions src/SlimJim.Test/SlnFileGeneratorTests.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
using System;
using System.Collections.Generic;

using NUnit.Framework;
using Rhino.Mocks;
using SlimJim.Infrastructure;
using SlimJim.Model;


namespace SlimJim.Test
{
[TestFixture]
using SlimJim.Infrastructure;
using SlimJim.Model;

[TestFixture]
public class SlnFileGeneratorTests : TestBase
{
private const string TargetProject = "MyProject";
Expand Down
7 changes: 1 addition & 6 deletions src/SlimJim.Test/TestBase.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
using Rhino.Mocks;
using SlimJim.Infrastructure;
using SlimJim.Model;

using System.IO;

namespace SlimJim.Test
Expand Down
8 changes: 5 additions & 3 deletions src/SlimJim.Test/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.3" targetFramework="net40" />
<package id="NUnit" version="2.5.9.10348" />
<package id="RhinoMocks" version="3.6" />
<package id="log4net" version="2.0.8" targetFramework="net40" />
<package id="NUnit" version="3.8.1" targetFramework="net40" />
<package id="NUnit.Mocks" version="2.6.4" targetFramework="net40" />
<package id="NUnitTestAdapter" version="2.1.1" targetFramework="net40" />
<package id="RhinoMocks" version="3.6.1" targetFramework="net40" />
</packages>
9 changes: 7 additions & 2 deletions src/SlimJim/CsProjConverter.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@

using System.Xml;

using log4net;
using SlimJim.Model;


namespace SlimJim
{
public abstract class CsProjConverter
using Model;


public abstract class CsProjConverter
{
protected const string MSBuildXmlNamespace = "http://schemas.microsoft.com/developer/msbuild/2003";
protected readonly ILog log;
Expand Down
6 changes: 3 additions & 3 deletions src/SlimJim/HintPathConverter.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using System;
using System.IO;
using System.Linq;
using System.Xml;
using System.Xml.XPath;
using SlimJim.Model;

namespace SlimJim
{
public class HintPathConverter : CsProjConverter
using Model;

public class HintPathConverter : CsProjConverter
{
private const string NuGetPackagesDirectoryName = @"packages\";
private enum Mode { Convert, Restore }
Expand Down
2 changes: 1 addition & 1 deletion src/SlimJim/Infrastructure/ArgsOptionsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private void ProcessArguments(string[] args)
v => options.AddAdditionalSearchPaths(v) },
{ "o|out=", "directory {PATH} where you want the .sln file written",
v => options.SlnOutputPath = v },
{ "version=", "Visual Studio {VERSION} compatibility (2008, 2010, 2012, 2013, 2015 default)",
{ "version=", "Visual Studio {VERSION} compatibility (2008, 2010, 2012, 2013, 2015, 2017 default)",
v => options.VisualStudioVersion = TryParseVersionNumber(v) },
{ "n|name=", "alternate {NAME} for solution file",
v => options.SolutionName = v},
Expand Down
13 changes: 8 additions & 5 deletions src/SlimJim/Infrastructure/CsProjReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
using System.IO;
using System.Linq;
using System.Xml.Linq;
using SlimJim.Model;
using log4net;
using System.Reflection;

using log4net;

namespace SlimJim.Infrastructure
{
public class CsProjReader
using Model;

public class CsProjReader
{
private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly XNamespace Ns = "http://schemas.microsoft.com/developer/msbuild/2003";
Expand Down Expand Up @@ -96,8 +98,9 @@ private string ReadProjectGuid(XElement projectReference, FileInfo csprojFile)

private bool FindImportedNuGetTargets(XElement xml)
{
var importPaths = (from import in xml.DescendantsAndSelf(Ns + "Import")
select import.Attribute("Project").Value);
var importPaths = xml.DescendantsAndSelf(Ns + "Import")
.Where(i => i.Attribute("Project") != null)
.Select(i => i.Attribute("Project").Value);
return importPaths.Any(p => p.EndsWith(@"\.nuget\nuget.targets", StringComparison.InvariantCultureIgnoreCase));
}

Expand Down
Loading