Skip to content

Commit edbd8c2

Browse files
author
Per Gårdebrink
committed
Add test for #70
1 parent 9372d96 commit edbd8c2

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information.
2+
3+
namespace CommandLine.Tests.Fakes
4+
{
5+
class Mutable_Without_Empty_Constructor
6+
{
7+
[Option("amend", HelpText = "Used to amend the tip of the current branch.")]
8+
public bool Amend { get; set; }
9+
10+
private Mutable_Without_Empty_Constructor()
11+
{
12+
}
13+
14+
public static Mutable_Without_Empty_Constructor Create()
15+
{
16+
return new Mutable_Without_Empty_Constructor();
17+
}
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System.Linq;
2+
using CommandLine.Tests.Fakes;
3+
using CommandLine.Text;
4+
using FluentAssertions;
5+
using Xunit;
6+
using Xunit.Abstractions;
7+
8+
//Issue #70
9+
//When the factory overload is used for ParseArguments, there should be no constraint not having an empty constructor.
10+
11+
namespace CommandLine.Tests.Unit
12+
{
13+
public class Issue70Tests
14+
{
15+
[Fact]
16+
public void Create_instance_with_factory_method_should_not_fail()
17+
{
18+
bool actual = false;
19+
20+
var arguments = new[] { "--amend" };
21+
var result = Parser.Default.ParseArguments(() => Mutable_Without_Empty_Constructor.Create(), arguments);
22+
result.WithParsed(options => {
23+
actual = options.Amend;
24+
});
25+
26+
actual.Should().BeTrue();
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)