public void EnumValueHelp_ShouldReturnOptionSetup() { var commandParser = A.Fake <CommandParser <DataTypesCommandOptions> >(); var targetProperty = typeof(DataTypesCommandOptions).GetProperty("Enums"); var optionParser = A.Fake <EnumListOptionParser <LogLevel> >(ob => ob.WithArgumentsForConstructor(() => new EnumListOptionParser <LogLevel>(targetProperty, "enums"))); var setup = new EnumListOptionSetup <DataTypesCommandOptions, LogLevel>(commandParser, optionParser); setup.EnumValueHelp(LogLevel.Trace, "newEnumValueHelp").Should().Be(setup); }
public void Help_ShouldAssignHelpToOptionParser() { var commandParser = A.Fake <CommandParser <DataTypesCommandOptions> >(); var targetProperty = typeof(DataTypesCommandOptions).GetProperty("Enums"); var optionParser = A.Fake <EnumListOptionParser <LogLevel> >(ob => ob.WithArgumentsForConstructor(() => new EnumListOptionParser <LogLevel>(targetProperty, "enums"))); var setup = new EnumListOptionSetup <DataTypesCommandOptions, LogLevel>(commandParser, optionParser); setup.Help("newHelpText"); A.CallToSet(() => optionParser.OptionHelp).To("newHelpText").MustHaveHappened(); }
public void Name_ShouldReturnOptionSetup() { var commandParser = A.Fake <CommandParser <DataTypesCommandOptions> >(); var targetProperty = typeof(DataTypesCommandOptions).GetProperty("Enums"); var optionParser = A.Fake <EnumListOptionParser <LogLevel> >(ob => ob.WithArgumentsForConstructor(() => new EnumListOptionParser <LogLevel>(targetProperty, "enums"))); var setup = new EnumListOptionSetup <DataTypesCommandOptions, LogLevel>(commandParser, optionParser); A.CallTo(() => commandParser.CanOptionParserUseOptionName(optionParser, "newName")).Returns(true); setup.Name("newName").Should().Be(setup); }
public void IsRequired_ShouldSetIsRequiredFlagOnOptionParser() { var commandParser = A.Fake <CommandParser <DataTypesCommandOptions> >(); var targetProperty = typeof(DataTypesCommandOptions).GetProperty("Enums"); var optionParser = A.Fake <EnumListOptionParser <LogLevel> >(ob => ob.WithArgumentsForConstructor(() => new EnumListOptionParser <LogLevel>(targetProperty, "enums"))); var setup = new EnumListOptionSetup <DataTypesCommandOptions, LogLevel>(commandParser, optionParser); setup.IsRequired(); A.CallToSet(() => optionParser.IsOptionRequired).To(true).MustHaveHappened(); }
public void DefaultValue_ShouldAssignDefaultValueToOptionParser() { var commandParser = A.Fake <CommandParser <DataTypesCommandOptions> >(); var targetProperty = typeof(DataTypesCommandOptions).GetProperty("Enums"); var optionParser = A.Fake <EnumListOptionParser <LogLevel> >(ob => ob.WithArgumentsForConstructor(() => new EnumListOptionParser <LogLevel>(targetProperty, "enums"))); var setup = new EnumListOptionSetup <DataTypesCommandOptions, LogLevel>(commandParser, optionParser); var defaultValue = new List <LogLevel>(); setup.DefaultValue(defaultValue); A.CallToSet(() => optionParser.OptionDefaultValue).To(defaultValue).MustHaveHappened(); }
public void Name_DuplicateName_ShouldThrowException() { var commandParser = A.Fake <CommandParser <DataTypesCommandOptions> >(); var targetProperty = typeof(DataTypesCommandOptions).GetProperty("Enums"); var optionParser = A.Fake <EnumListOptionParser <LogLevel> >(ob => ob.WithArgumentsForConstructor(() => new EnumListOptionParser <LogLevel>(targetProperty, "enums"))); var setup = new EnumListOptionSetup <DataTypesCommandOptions, LogLevel>(commandParser, optionParser); A.CallTo(() => commandParser.CanOptionParserUseOptionName(optionParser, "newName")).Returns(false); setup.Invoking(a => a.Name("newName")) .Should() .Throw <ArgumentException>(); }
public void EnumValueHelp_ShouldAssignEnumValueHelpToOptionParser() { var commandParser = A.Fake <CommandParser <DataTypesCommandOptions> >(); var targetProperty = typeof(DataTypesCommandOptions).GetProperty("Enums"); var optionParser = A.Fake <EnumListOptionParser <LogLevel> >(ob => ob.WithArgumentsForConstructor(() => new EnumListOptionParser <LogLevel>(targetProperty, "enums"))); var enumValueHelps = A.Fake <IDictionary <LogLevel, String> >(); var setup = new EnumListOptionSetup <DataTypesCommandOptions, LogLevel>(commandParser, optionParser); A.CallTo(() => optionParser.EnumValuesHelps).Returns(enumValueHelps); setup.EnumValueHelp(LogLevel.Trace, "newEnumValueHelp"); A.CallTo(() => enumValueHelps.Add(LogLevel.Trace, "newEnumValueHelp")).MustHaveHappened(); }