Skip to content

Commit 93c9007

Browse files
committed
add testcase of issue# 424
1 parent 6a01d6c commit 93c9007

File tree

4 files changed

+63
-6
lines changed

4 files changed

+63
-6
lines changed

Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<NoWarn>CS1591;8002;NU5125</NoWarn>
3+
<NoWarn>CS1591;CS0219;8002;NU5125</NoWarn>
44
</PropertyGroup>
55
<PropertyGroup Condition="$(TargetFramework.StartsWith('net4'))">
66
<DefineConstants>$(DefineConstants);NETFRAMEWORK</DefineConstants>

src/CommandLine/CommandLine.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<Authors>gsscoder;nemec;ericnewton76</Authors>
1515
<Title>Command Line Parser Library</Title>
1616
<Version Condition="'$(VersionSuffix)' != ''">$(VersionSuffix)</Version>
17-
<Version Condition="'$(VersionSuffix)' == ''">0.0.0</Version>
17+
<Version Condition="'$(VersionSuffix)' == ''">2.5.0-Dev</Version>
1818
<Description Condition="'$(BuildTarget)' != 'fsharp'">Terse syntax C# command line parser for .NET. For FSharp support see CommandLineParser.FSharp. The Command Line Parser Library offers to CLR applications a clean and concise API for manipulating command line arguments and related tasks.</Description>
1919
<Description Condition="'$(BuildTarget)' == 'fsharp'">Terse syntax C# command line parser for .NET with F# support. The Command Line Parser Library offers to CLR applications a clean and concise API for manipulating command line arguments and related tasks.</Description>
2020
<Copyright>Copyright (c) 2005 - 2018 Giacomo Stelluti Scala &amp; Contributors</Copyright>

tests/CommandLine.Tests/CommandLine.Tests.csproj

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<PropertyGroup>
44
<OutputType>Library</OutputType>
55
<TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
6-
<DefineConstants>$(DefineConstants);PLATFORM_DOTNET</DefineConstants>
76
<DefineConstants Condition="'$(BuildTarget)' != 'fsharp'">$(DefineConstants);SKIP_FSHARP</DefineConstants>
87
<AssemblyOriginatorKeyFile>..\..\CommandLine.snk</AssemblyOriginatorKeyFile>
98
<SignAssembly>true</SignAssembly>
@@ -12,12 +11,15 @@
1211
<Version Condition="'$(VersionSuffix)' != ''">$(VersionSuffix)</Version>
1312
<Version Condition="'$(VersionSuffix)' == ''">2.5.0</Version>
1413
<Copyright>Copyright (c) 2005 - 2018 Giacomo Stelluti Scala &amp; Contributors</Copyright>
14+
<IsTestProject>true</IsTestProject>
1515
</PropertyGroup>
1616
<ItemGroup Condition="'$(BuildTarget)' != 'fsharp'">
1717
<Compile Remove="Fakes\Options_With_FSharpOption.cs" />
1818
<Compile Remove="Unit\Infrastructure\FSharpOptionHelperTests.cs" />
1919
</ItemGroup>
20-
20+
<PropertyGroup Condition="$(TargetFramework.StartsWith('netcoreapp'))">
21+
<DefineConstants>$(DefineConstants);PLATFORM_DOTNET</DefineConstants>
22+
</PropertyGroup>
2123
<ItemGroup>
2224
<ProjectReference Include="..\..\src\CommandLine\CommandLine.csproj" />
2325
</ItemGroup>
@@ -26,8 +28,8 @@
2628
<PackageReference Include="FluentAssertions" Version="5.4.1" />
2729
<PackageReference Include="FsCheck" Version="2.11.0" />
2830
<PackageReference Include="FSharp.Core" Version="4.5.1" Condition="'$(BuildTarget)' == 'fsharp'" />
29-
<PackageReference Include="xunit" Version="2.4.0" />
30-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
31+
<PackageReference Include="xunit" Version="2.4.1" />
32+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
3133
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
3234

3335
</ItemGroup>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Xunit;
4+
5+
namespace CommandLine.Tests.Unit
6+
{
7+
8+
//MailAndSmsWarningSenderTests
9+
public class Issue424Tests
10+
{
11+
private MailAndSmsWarningSender _sut;
12+
13+
public Issue424Tests()
14+
{
15+
_sut = new MailAndSmsWarningSender();
16+
}
17+
18+
[Fact]
19+
public void SendSmsOnWarning()
20+
{
21+
//Arrange
22+
void Action() => _sut.ParseArgumentsAndRun(
23+
new[] { "--task", "MailAndSmsWarningSender", "--test", "hejtest" });
24+
// Act & Assert
25+
Assert.Throws<NotImplementedException>((Action)Action);
26+
}
27+
}
28+
29+
public class MailAndSmsWarningSender
30+
{
31+
internal class Options
32+
{
33+
[Option("task")]
34+
public string Task { get; set; }
35+
}
36+
37+
public void ParseArgumentsAndRun(string[] args)
38+
{
39+
Parser.Default.ParseArguments<Options>(args)
40+
.WithParsed(ExecuteTaskWithOptions)
41+
.WithNotParsed(HandleParseError);
42+
}
43+
44+
private void HandleParseError(IEnumerable<Error> errs)
45+
{
46+
throw new NotImplementedException();
47+
}
48+
49+
private void ExecuteTaskWithOptions(Options opts)
50+
{
51+
Console.WriteLine("Executing");
52+
}
53+
54+
}
55+
}

0 commit comments

Comments
 (0)