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