BadScript 2
Loading...
Searching...
No Matches
BaseAttributeTests.cs
Go to the documentation of this file.
1using System;
2using Xunit;
3
5{
6 public class BaseAttributeTests
7 {
8 [Theory]
9 [InlineData(null)]
10 [InlineData(1)]
11 public static void Default(object defaultValue)
12 {
13 TestBaseAttribute baseAttribute = new TestBaseAttribute();
14 baseAttribute.Default = defaultValue;
15 Assert.Equal(defaultValue, baseAttribute.Default);
16 }
17
18 [Theory]
19 [InlineData("", null, "")]
20 [InlineData("", typeof(Fakes.StaticResource), "")]
21 [InlineData("Help text", null, "Help text")]
22 [InlineData("HelpText", typeof(Fakes.StaticResource), "Localized HelpText")]
23 [InlineData("HelpText", typeof(Fakes.NonStaticResource), "Localized HelpText")]
24 [InlineData("ImplicitCastHelpText", typeof(Fakes.StaticResource), "Localized HelpText")]
25 [InlineData("ImplicitCastHelpText", typeof(Fakes.NonStaticResource), "Localized HelpText")]
26 [InlineData("ExplicitCastHelpText", typeof(Fakes.StaticResource), "Localized HelpText")]
27 [InlineData("ExplicitCastHelpText", typeof(Fakes.NonStaticResource), "Localized HelpText")]
28 public static void HelpText(string helpText, Type resourceType, string expected)
29 {
30 TestBaseAttribute baseAttribute = new TestBaseAttribute();
31 baseAttribute.HelpText = helpText;
32 baseAttribute.ResourceType = resourceType;
33
34 Assert.Equal(expected, baseAttribute.HelpText);
35 }
36
37 [Theory]
38 [InlineData("HelpText", typeof(Fakes.NonStaticResource_WithNonStaticProperty))]
39 [InlineData("WriteOnlyText", typeof(Fakes.NonStaticResource))]
40 [InlineData("PrivateOnlyText", typeof(Fakes.NonStaticResource))]
41 [InlineData("HelpText", typeof(Fakes.InternalResource))]
42 [InlineData("WrongImplicitCastHelpText", typeof(Fakes.StaticResource))]
43 [InlineData("WrongExplicitCastHelpText", typeof(Fakes.StaticResource))]
44 [InlineData("WrongImplicitCastHelpText", typeof(Fakes.NonStaticResource))]
45 [InlineData("WrongExplicitCastHelpText", typeof(Fakes.NonStaticResource))]
46 public void ThrowsHelpText(string helpText, Type resourceType)
47 {
48 TestBaseAttribute baseAttribute = new TestBaseAttribute();
49 baseAttribute.HelpText = helpText;
50 baseAttribute.ResourceType = resourceType;
51
52 // Verify exception
53 Assert.Throws<ArgumentException>(() => baseAttribute.HelpText.ToString());
54 }
55
56
58 {
60 {
61 // Do nothing
62 }
63 }
64
65 }
66}
Models a base attribute to define command line syntax.
string HelpText
Gets or sets a short description of this command line option. Usually a sentence summary.
object Default
Gets or sets mapped property default value.
void ThrowsHelpText(string helpText, Type resourceType)
static void Default(object defaultValue)
static void HelpText(string helpText, Type resourceType, string expected)