public void IsRequired_ShouldReturnOptionSetup() { var commandParser = A.Fake <CommandParser <DataTypesCommandOptions> >(); var targetProperty = typeof(DataTypesCommandOptions).GetProperty("Strings"); var optionParser = A.Fake <StringListOptionParser>(ob => ob.WithArgumentsForConstructor(() => new StringListOptionParser(targetProperty, "strings"))); var setup = new StringListOptionSetup <DataTypesCommandOptions>(commandParser, optionParser); setup.IsRequired().Should().Be(setup); }
public void Help_ShouldAssignHelpToOptionParser() { var commandParser = A.Fake <CommandParser <DataTypesCommandOptions> >(); var targetProperty = typeof(DataTypesCommandOptions).GetProperty("Strings"); var optionParser = A.Fake <StringListOptionParser>(ob => ob.WithArgumentsForConstructor(() => new StringListOptionParser(targetProperty, "strings"))); var setup = new StringListOptionSetup <DataTypesCommandOptions>(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("Strings"); var optionParser = A.Fake <StringListOptionParser>(ob => ob.WithArgumentsForConstructor(() => new StringListOptionParser(targetProperty, "strings"))); var setup = new StringListOptionSetup <DataTypesCommandOptions>(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("Strings"); var optionParser = A.Fake <StringListOptionParser>(ob => ob.WithArgumentsForConstructor(() => new StringListOptionParser(targetProperty, "strings"))); var setup = new StringListOptionSetup <DataTypesCommandOptions>(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("Strings"); var optionParser = A.Fake <StringListOptionParser>(ob => ob.WithArgumentsForConstructor(() => new StringListOptionParser(targetProperty, "strings"))); var setup = new StringListOptionSetup <DataTypesCommandOptions>(commandParser, optionParser); var defaultValue = new List <String>(); 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("Strings"); var optionParser = A.Fake <StringListOptionParser>(ob => ob.WithArgumentsForConstructor(() => new StringListOptionParser(targetProperty, "strings"))); var setup = new StringListOptionSetup <DataTypesCommandOptions>(commandParser, optionParser); A.CallTo(() => commandParser.CanOptionParserUseOptionName(optionParser, "newName")).Returns(false); setup.Invoking(a => a.Name("newName")) .Should() .Throw <ArgumentException>(); }