-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8cc89d9
commit f907665
Showing
50 changed files
with
1,906 additions
and
201 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{5B0BCF64-81B6-4A33-8D00-C673A0EF3551}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>GoCommando.Tests</RootNamespace> | ||
<AssemblyName>GoCommando.Tests</AssemblyName> | ||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<TargetFramework>netcoreapp3.1</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> | ||
</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=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="TestArgParser.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="TestCommand.cs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
<PackageReference Include="microsoft.net.test.sdk" Version="16.7.0" /> | ||
<PackageReference Include="nunit" Version="3.12.0" /> | ||
<PackageReference Include="nunit3testadapter" Version="3.17.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\GoCommando\GoCommando.csproj"> | ||
<Project>{2839AA55-B40A-4BB8-BDA0-C5057E5A683F}</Project> | ||
<Name>GoCommando</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="..\GoCommando\GoCommando.csproj" /> | ||
</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> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{5B0BCF64-81B6-4A33-8D00-C673A0EF3551}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>GoCommando.Tests</RootNamespace> | ||
<AssemblyName>GoCommando.Tests</AssemblyName> | ||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</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=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="TestArgParser.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="TestCommand.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\GoCommando\GoCommando.csproj"> | ||
<Project>{2839AA55-B40A-4BB8-BDA0-C5057E5A683F}</Project> | ||
<Name>GoCommando</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. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using GoCommando.Internals; | ||
using NUnit.Framework; | ||
|
||
namespace GoCommando.Tests | ||
{ | ||
[TestFixture] | ||
public class TestArgParser | ||
{ | ||
[Test] | ||
public void CanReturnSimpleCommand() | ||
{ | ||
var arguments = Parse(new[] { "run" }); | ||
|
||
Assert.That(arguments.Command, Is.EqualTo("run")); | ||
} | ||
|
||
[Test] | ||
public void CommandIsNullWhenNoCommandIsGiven() | ||
{ | ||
var arguments = Parse(new[] { "-file", @"""C:\temp\file.json""" }); | ||
|
||
Assert.That(arguments.Command, Is.Null); | ||
} | ||
|
||
[Test, Ignore("arguments.Command should just be null")] | ||
public void DoesNotAcceptSwitchAsCommand() | ||
{ | ||
var ex = Assert.Throws<GoCommandoException>(() => | ||
{ | ||
Parse(new[] { "-file", @"""C:\temp\file.json""" }); | ||
}); | ||
|
||
Console.WriteLine(ex); | ||
} | ||
|
||
[Test] | ||
public void CanParseOrdinaryArguments() | ||
{ | ||
var args = @"run | ||
-path | ||
c:\Program Files | ||
-dir | ||
c:\Windows\Microsoft.NET\Framework | ||
-flag | ||
-moreflag".Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); | ||
|
||
var arguments = Parse(args); | ||
|
||
Console.WriteLine(arguments); | ||
|
||
Assert.That(arguments.Command, Is.EqualTo("run")); | ||
Assert.That(arguments.Switches.Count(), Is.EqualTo(4)); | ||
Assert.That(arguments.Get<string>("path"), Is.EqualTo(@"c:\Program Files")); | ||
Assert.That(arguments.Get<string>("dir"), Is.EqualTo(@"c:\Windows\Microsoft.NET\Framework")); | ||
|
||
Assert.That(arguments.Get<bool>("flag"), Is.True); | ||
Assert.That(arguments.Get<bool>("moreflag"), Is.True); | ||
Assert.That(arguments.Get<bool>("flag_not_specified_should_default_to_false"), Is.False); | ||
} | ||
|
||
[TestCase(@"-path:""c:\temp""")] | ||
[TestCase(@"-path=""c:\temp""")] | ||
[TestCase(@"-path""c:\temp""")] | ||
public void SupportsVariousSingleTokenAliases(string alias) | ||
{ | ||
var arguments = Parse(new[] { alias }); | ||
|
||
Assert.That(arguments.Switches.Count(), Is.EqualTo(1)); | ||
Assert.That(arguments.Switches.Single().Key, Is.EqualTo("path")); | ||
Assert.That(arguments.Switches.Single().Value, Is.EqualTo(@"c:\temp")); | ||
} | ||
|
||
[TestCase(@"-n23")] | ||
public void SupportsShortFormWithNumber(string alias) | ||
{ | ||
var arguments = Parse(new[] { alias }); | ||
|
||
Assert.That(arguments.Switches.Count(), Is.EqualTo(1)); | ||
Assert.That(arguments.Switches.Single().Key, Is.EqualTo("n")); | ||
Assert.That(arguments.Switches.Single().Value, Is.EqualTo(@"23")); | ||
} | ||
|
||
static Arguments Parse(IEnumerable<string> args) | ||
{ | ||
return Go.Parse(args, new Settings()); | ||
} | ||
} | ||
} |
Oops, something went wrong.