public void Multiple_aliases_via_attribute_on_command(Type utilType) { const string cSharpCode = @" [Aliases(""xyz"", ""abc"")] public class MyClass { public int MyPropertyArg { get; set; } }"; const string vBasicCode = @" <Aliases(""xyz"", ""abc"")> Public Class [MyClass] Public Property MyPropertyArg As Integer End Class "; var actualCli = LanguageUtils.Choose(utilType, cSharpCode, vBasicCode) .WrapInNamespace() .CliDescriptorForClass(out var code); var actual = actualCli.CommandDescriptor; actual.Aliases.Count().Should().Be(2); actual.Aliases.First().Should().Be("xyz"); actual.Aliases.Last().Should().Be("abc"); }
public void Command_source_is_correct(Type utilType) { const string cSharpCode = "public int MyProperty { get; set; }"; const string vBasicCode = "Public Property MyProperty As Integer"; var actualCli = LanguageUtils.Choose(utilType, cSharpCode, vBasicCode) .WrapInClass() .CliDescriptorForClass(out var code); var actual = actualCli.CommandDescriptor; actual.RawInfo.Should().BeOfType <RawInfoForType>(); }
public void Command_names_are_as_expected(Type utilType) { const string cSharpCode = "public int MyProperty { get; set; }"; const string vBasicCode = "Public Property MyProperty As Integer"; var actualCli = LanguageUtils.Choose(utilType, cSharpCode, vBasicCode) .WrapInClass() .CliDescriptorForClass(out var code); var actual = actualCli.CommandDescriptor; actual.OriginalName.Should().Be(LanguageUtils.StandardClassName); actual.Name.Should().Be(LanguageUtils.StandardClassName); actual.CliName.Should().Be(LanguageUtils.StandardClassName.ToKebabCase()); }
public void Command_source_is_correct(Type utilType) { var cSharpCode = @" public int MyMethod () { return 0; }"; var vBasicCode = @" Public Function MyMethod() As Integer Return 0 End Function"; var actualCli = LanguageUtils.Choose(utilType, cSharpCode, vBasicCode) .WrapInClass() .CliDescriptorForMethod(out var code); var actual = actualCli.CommandDescriptor; actual.RawInfo.Should().BeOfType <RawInfoForMethod>(); }
public void No_alias_when_none_given_on_command(Type utilType) { const string cSharpCode = @"public void MyMethod () { return; }"; const string vBasicCode = @" Public Sub MyMethod() Return End Sub "; var actualCli = LanguageUtils.Choose(utilType, cSharpCode, vBasicCode) .WrapInClass() .CliDescriptorForClass(out var code); var actual = actualCli.CommandDescriptor.SubCommands.First(); actual.Aliases.Count().Should().Be(0); }
public void Hidden_is_false_when_Hidden_attribute_not_on_command(Type utilType) { var cSharpCode = @" public int MyMethod () { return 0; }"; var vBasicCode = @" Public Function MyMethod() As Integer Return 0 End Function"; var actualCli = LanguageUtils.Choose(utilType, cSharpCode, vBasicCode) .WrapInClass() .CliDescriptorForMethod(out var code); var actual = actualCli.CommandDescriptor; actual.IsHidden.Should().Be(false); }
public void Hidden_is_false_when_Hidden_attribute_not_on_command(Type utilType) { const string cSharpCode = @"public int MyMethod () { return 0; }"; const string vBasicCode = @" Public Sub MyMethod() Return End Sub "; var actualCli = LanguageUtils.Choose(utilType, cSharpCode, vBasicCode) .WrapInClass() .CliDescriptorForClass(out var code); var actual = actualCli.CommandDescriptor.SubCommands.First(); actual.IsHidden.Should().Be(false); }
public void No_alias_when_none_given_on_command(Type utilType) { var cSharpCode = @" public void MyMethod () { return; }"; var vBasicCode = @" <Aliases()> Public Function MyMethod() As Integer Return 0 End Function"; var actualCli = LanguageUtils.Choose(utilType, cSharpCode, vBasicCode) .WrapInClass() .CliDescriptorForMethod(out var code); var actual = actualCli.CommandDescriptor; actual.Aliases.Count().Should().Be(0); }
public void Option_names_are_as_expected(Type utilType, bool useArg) { var name = useArg ? "MyPropertyArg" : "MyProperty"; var cSharpCode = @$ "public int {name} {{ get; set; }}"; var vBasicCode = @$ "Public Property {name} As Integer"; var actualCli = LanguageUtils.Choose(utilType, cSharpCode, vBasicCode) .WrapInClass() .CliDescriptorForClass(out var code); SymbolDescriptor actual = useArg ? actualCli.CommandDescriptor.Arguments.First() : actualCli.CommandDescriptor.Options.First(); actual.OriginalName.Should().Be(name); actual.Name.Should().Be("MyProperty"); actual.CliName.Should().Be(useArg ? "my-property" : "--my-property"); }
public void Command_names_are_as_expected(Type utilType) { const string cSharpCode = @"public int MyMethod () { return 0; }"; const string vBasicCode = @" Public Function MyMethod() As Integer Return 0 End Function "; var actualCli = LanguageUtils.Choose(utilType, cSharpCode, vBasicCode) .WrapInClass() .CliDescriptorForClass(out var code); var actual = actualCli.CommandDescriptor.SubCommands.First(); actual.OriginalName.Should().Be("MyMethod"); actual.Name.Should().Be("MyMethod"); actual.CliName.Should().Be("my-method"); }
public void Hidden_is_true_when_Hidden_attribute_with_true_value_used_on_command(Type utilType) { var cSharpCode = @" [Hidden(true)] public void MyMethod () { return; }"; var vBasicCode = @" <Hidden(True)> Public Function MyMethod() As Integer Return 0 End Function"; var actualCli = LanguageUtils.Choose(utilType, cSharpCode, vBasicCode) .WrapInClass() .CliDescriptorForMethod(out var code); var actual = actualCli.CommandDescriptor; actual.IsHidden.Should().Be(true); }
public void Single_alias_via_attribute_on_command(Type utilType) { const string cSharpCode = @" [Aliases(""x"")] public void MyMethod () { return; }"; const string vBasicCode = @" <Aliases(""x"")> Public Sub MyMethod() Return End Sub"; var actualCli = LanguageUtils.Choose(utilType, cSharpCode, vBasicCode) .WrapInClass() .CliDescriptorForClass(out var code); var actual = actualCli.CommandDescriptor.SubCommands.First(); actual.Aliases.Count().Should().Be(1); actual.Aliases.First().Should().Be("x"); }
public void Single_alias_via_attribute_on_command(Type utilType) { var cSharpCode = @" [Aliases(""x"")] public void MyMethod () { return; }"; var vBasicCode = @" <Aliases(""x"")> Public Function MyMethod() As Integer Return 0 End Function"; var actualCli = LanguageUtils.Choose(utilType, cSharpCode, vBasicCode) .WrapInClass() .CliDescriptorForMethod(out var code); var actual = actualCli.CommandDescriptor; actual.Aliases.Count().Should().Be(1); actual.Aliases.First().Should().Be("x"); }
public void Hidden_is_true_when_Hidden_attribute_with_true_value_used_on_command(Type utilType) { const string cSharpCode = @" [Hidden(true)] public void MyMethod () { return; }"; const string vBasicCode = @" < Hidden(true) > Public Sub MyMethod() Return End Sub "; var actualCli = LanguageUtils.Choose(utilType, cSharpCode, vBasicCode) .WrapInClass() .CliDescriptorForClass(out var code); var actual = actualCli.CommandDescriptor.SubCommands.First(); actual.IsHidden.Should().Be(true); }
public void Hidden_is_false_when_Hidden_attribute_not_on_command(Type utilType) { const string cSharpCode = @" public class MyClass { public int MyPropertyArg { get; set; } }"; const string vBasicCode = @" Public Class [MyClass] Public Property MyPropertyArg As Integer End Class "; var actualCli = LanguageUtils.Choose(utilType, cSharpCode, vBasicCode) .WrapInNamespace() .CliDescriptorForClass(out var code); var actual = actualCli.CommandDescriptor; actual.IsHidden.Should().Be(false); }
public void Required_is_false_when_Required_attribute_not_on_argument(Type utilType) { var cSharpCode = @" public class MyClass { public MyClass(int myParamArg) {} }"; var vBasicCode = @" Public Class [MyClass] Public Sub New(myParamArg As Integer) End Sub End Class"; var actualCli = LanguageUtils.Choose(utilType, cSharpCode, vBasicCode) .WrapInNamespace() .CliDescriptorForClass(out var code); var actual = actualCli.CommandDescriptor.Arguments.First(); actual.Required.Should().Be(false); }
public void No_alias_when_none_given_on_command(Type utilType) { const string cSharpCode = @" public class MyClass { public int MyPropertyArg { get; set; } }"; const string vBasicCode = @" Public Class [MyClass] Public Property MyPropertyArg As Integer End Class "; var actualCli = LanguageUtils.Choose(utilType, cSharpCode, vBasicCode) .WrapInNamespace() .CliDescriptorForClass(out var code); var actual = actualCli.CommandDescriptor; actual.Aliases.Count().Should().Be(0); }
public void Hidden_is_false_when_Hidden_attribute_with_false_value_used_on_argument(Type utilType) { var cSharpCode = @" public class MyClass { public MyClass([Hidden(false)] int myParamArg) {} }"; var vBasicCode = @" Public Class [MyClass] Public Sub New(<Hidden(False)> myParamArg As Integer) End Sub End Class"; var actualCli = LanguageUtils.Choose(utilType, cSharpCode, vBasicCode) .WrapInNamespace() .CliDescriptorForClass(out var code); var actual = actualCli.CommandDescriptor.Arguments.First(); actual.IsHidden.Should().Be(false); }
public void ArgumentType_is_bool_when_int_on_argument(Type utilType) { var cSharpCode = @" public class MyClass { public MyClass(bool myParamArg) {} }"; var vBasicCode = @" Public Class [MyClass] Public Sub New(myParamArg As Boolean) End Sub End Class"; var actualCli = LanguageUtils.Choose(utilType, cSharpCode, vBasicCode) .WrapInNamespace() .CliDescriptorForClass(out var code); var actual = actualCli.CommandDescriptor.Arguments.First(); actual.ArgumentType.TypeAsString().Should().Be("Boolean"); }
public void Argument_names_are_as_expected(Type utilType) { var cSharpCode = @" public class MyClass { public MyClass(int myParamArg) {} }"; var vBasicCode = @" Public Class [MyClass] Public Sub New(myParamArg As Integer) End Sub End Class"; var actualCli = LanguageUtils.Choose(utilType, cSharpCode, vBasicCode) .WrapInNamespace() .CliDescriptorForClass(out var code); var actual = actualCli.CommandDescriptor.Arguments.First(); actual.OriginalName.Should().Be("myParamArg"); actual.Name.Should().Be("myParam"); actual.CliName.Should().Be("my-param"); }