forked from commandlineparser/commandline
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelpTextAutoBuildFix.cs
More file actions
92 lines (78 loc) · 3.63 KB
/
Copy pathHelpTextAutoBuildFix.cs
File metadata and controls
92 lines (78 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using System;
using System.Linq;
using Xunit;
using FluentAssertions;
using CommandLine.Tests.Fakes;
using CommandLine.Text;
namespace CommandLine.Tests.Unit.Text
{
public class HelpTextAutoBuildFix
{
[Fact]
public void HelpText_with_AdditionalNewLineAfterOption_true_should_have_newline()
{
// Fixture setup
// Exercize system
var sut = new HelpText { AdditionalNewLineAfterOption = true }
.AddOptions(new NotParsed<Simple_Options>(TypeInfo.Create(typeof(Simple_Options)),
Enumerable.Empty<Error>()));
// Verify outcome
var lines = sut.ToString().ToLines();
lines[2].Should().BeEquivalentTo(" stringvalue Define a string value here.");
lines[3].Should().BeEquivalentTo(String.Empty);
lines[4].Should().BeEquivalentTo(" s, shortandlong Example with both short and long name.");
lines[5].Should().BeEquivalentTo(String.Empty);
lines[7].Should().BeEquivalentTo(String.Empty);
lines[9].Should().BeEquivalentTo(String.Empty);
lines[11].Should().BeEquivalentTo(String.Empty);
lines[13].Should().BeEquivalentTo(String.Empty);
lines[14].Should().BeEquivalentTo(" value pos. 0 Define a long value here.");
// Teardown
}
[Fact]
public void HelpText_with_AdditionalNewLineAfterOption_false_should_not_have_newline()
{
// Fixture setup
// Exercize system
var sut = new HelpText { AdditionalNewLineAfterOption = false }
.AddOptions(new NotParsed<Simple_Options>(TypeInfo.Create(typeof(Simple_Options)),
Enumerable.Empty<Error>()));
// Verify outcome
var lines = sut.ToString().ToLines();
lines[2].Should().BeEquivalentTo(" stringvalue Define a string value here.");
lines[3].Should().BeEquivalentTo(" s, shortandlong Example with both short and long name.");
lines[8].Should().BeEquivalentTo(" value pos. 0 Define a long value here.");
// Teardown
}
[Fact]
public void HelpText_with_by_default_should_include_help_version_option()
{
// Fixture setup
// Exercize system
var sut = new HelpText ()
.AddOptions(new NotParsed<Simple_Options>(TypeInfo.Create(typeof(Simple_Options)),
Enumerable.Empty<Error>()));
// Verify outcome
var lines = sut.ToString().ToNotEmptyLines();
lines.Should().HaveCount(c => c ==7);
lines.Should().Contain(" help Display more information on a specific command.");
lines.Should().Contain(" version Display version information.");
// Teardown
}
[Fact]
public void HelpText_with_AutoHelp_false_should_hide_help_option()
{
// Fixture setup
// Exercize system
var sut = new HelpText { AutoHelp = false,AutoVersion = false}
.AddOptions(new NotParsed<Simple_Options>(TypeInfo.Create(typeof(Simple_Options)),
Enumerable.Empty<Error>()));
// Verify outcome
var lines = sut.ToString().ToNotEmptyLines();
lines.Should().HaveCount(c => c ==5);
lines.Should().NotContain(" help Display more information on a specific command.");
lines.Should().NotContain(" version Display version information.");
// Teardown
}
}
}