public void Option_TimeSpanTargetProperty_ShouldReturnANewTimeSpanOptionSetup() { var targetProperty = typeof(DataTypesCommandOptions).GetProperty("TimeSpan"); var parser = A.Fake <Parser>(); var commandParser = A.Fake <CommandParser <DataTypesCommandOptions> >(ob => ob.WithArgumentsForConstructor(() => new CommandParser <DataTypesCommandOptions>(parser))); var optionParser = A.Fake <TimeSpanOptionParser>(ob => ob.WithArgumentsForConstructor(() => new TimeSpanOptionParser(targetProperty, "timeSpan"))); var optionSetup = A.Fake <TimeSpanOptionSetup <DataTypesCommandOptions> >(ob => ob.WithArgumentsForConstructor(() => new TimeSpanOptionSetup <DataTypesCommandOptions>(commandParser, optionParser))); var setup = new NamedCommandSetup <DataTypesCommandOptions>(parser, commandParser); A.CallTo(() => commandParser.GetOrCreateOptionParser <TimeSpanOptionParser>(targetProperty)).Returns(optionParser); A.CallTo(() => this.DependencyResolver.Resolve <TimeSpanOptionSetup <DataTypesCommandOptions> >(commandParser, optionParser)).Returns(optionSetup); Expression <Func <DataTypesCommandOptions, TimeSpan> > propertyExpression = a => a.TimeSpan; setup.Option(propertyExpression).Should().Be(optionSetup); A.CallTo(() => commandParser.GetOrCreateOptionParser <TimeSpanOptionParser>(targetProperty)).MustHaveHappened(); A.CallTo(() => this.DependencyResolver.Resolve <TimeSpanOptionSetup <DataTypesCommandOptions> >(commandParser, optionParser)).MustHaveHappened(); }
public void Option_NullableEnumTargetProperty_ShouldReturnANewEnumOptionSetup() { var targetProperty = typeof(DataTypesCommandOptions).GetProperty("NullableEnum"); var parser = A.Fake <Parser>(); var commandParser = A.Fake <CommandParser <DataTypesCommandOptions> >(ob => ob.WithArgumentsForConstructor(() => new CommandParser <DataTypesCommandOptions>(parser))); var optionParser = A.Fake <EnumOptionParser <LogLevel> >(ob => ob.WithArgumentsForConstructor(() => new EnumOptionParser <LogLevel>(targetProperty, "nullableEnum"))); var optionSetup = A.Fake <EnumOptionSetup <DataTypesCommandOptions, LogLevel> >(ob => ob.WithArgumentsForConstructor(() => new EnumOptionSetup <DataTypesCommandOptions, LogLevel>(commandParser, optionParser))); var setup = new NamedCommandSetup <DataTypesCommandOptions>(parser, commandParser); A.CallTo(() => commandParser.GetOrCreateOptionParser <EnumOptionParser <LogLevel> >(targetProperty)).Returns(optionParser); A.CallTo(() => this.DependencyResolver.Resolve <EnumOptionSetup <DataTypesCommandOptions, LogLevel> >(commandParser, optionParser)).Returns(optionSetup); Expression <Func <DataTypesCommandOptions, Nullable <LogLevel> > > propertyExpression = a => a.NullableEnum; setup.Option(propertyExpression).Should().Be(optionSetup); A.CallTo(() => commandParser.GetOrCreateOptionParser <EnumOptionParser <LogLevel> >(targetProperty)).MustHaveHappened(); A.CallTo(() => this.DependencyResolver.Resolve <EnumOptionSetup <DataTypesCommandOptions, LogLevel> >(commandParser, optionParser)).MustHaveHappened(); }