BadScript 2
Loading...
Searching...
No Matches
VerbAttributeTests.cs
Go to the documentation of this file.
1using System;
2using Xunit;
3
4namespace CommandLine.Tests
5{
6 //Test localization of VerbAttribute
7 public class VerbAttributeTests
8 {
9 [Theory]
10 [InlineData("", null, "")]
11 [InlineData("", typeof(Fakes.StaticResource), "")]
12 [InlineData("Help text", null, "Help text")]
13 [InlineData("HelpText", typeof(Fakes.StaticResource), "Localized HelpText")]
14 [InlineData("HelpText", typeof(Fakes.NonStaticResource), "Localized HelpText")]
15 public static void VerbHelpText(string helpText, Type resourceType, string expected)
16 {
17 TestVerbAttribute verbAttribute = new TestVerbAttribute
18 {
19 HelpText = helpText,
20 ResourceType = resourceType
21 };
22
23 Assert.Equal(expected, verbAttribute.HelpText);
24 }
25
26 [Theory]
27 [InlineData("HelpText", typeof(Fakes.NonStaticResource_WithNonStaticProperty))]
28 [InlineData("WriteOnlyText", typeof(Fakes.NonStaticResource))]
29 [InlineData("PrivateOnlyText", typeof(Fakes.NonStaticResource))]
30 [InlineData("HelpText", typeof(Fakes.InternalResource))]
31 public void ThrowsHelpText(string helpText, Type resourceType)
32 {
33 TestVerbAttribute verbAttribute = new TestVerbAttribute
34 {
35 HelpText = helpText,
36 ResourceType = resourceType
37 };
38
39 // Verify exception
40 Assert.Throws<ArgumentException>(() => verbAttribute.HelpText);
41 }
42
44 {
45 public TestVerbAttribute() : base("verb")
46 {
47 // Do nothing
48 }
49 }
50 }
51}
void ThrowsHelpText(string helpText, Type resourceType)
static void VerbHelpText(string helpText, Type resourceType, string expected)
Models a verb command specification.
string HelpText
Gets or sets a short description of this command line option. Usually a sentence summary.