Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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();
        }
Esempio n. 5
0
        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();
        }
Esempio n. 6
0
        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>();
        }