コード例 #1
0
        private void TestDefault(NumberConvertOptions opts)
        {
            // Returns a value
            Assert.NotNull(opts);

            // Always the same instance
            Assert.Same(opts, NumberConvertOptions.Default);

            // Expected configuration
            Assert.Equal(ParseNumericStringFlags.None, opts.ParseFlags);
        }
コード例 #2
0
        public void Flags()
        {
            var opts = new NumberConvertOptions(ParseNumericStringFlags.AllowDigitSeparator | ParseNumericStringFlags.OctalString);

            Assert.Equal(ParseNumericStringFlags.AllowDigitSeparator | ParseNumericStringFlags.OctalString, opts.ParseFlags);

            // Validate memoized flags
            Assert.False(opts.ParseHex);
            Assert.True(opts.ParseOctal);
            Assert.False(opts.ParseBinary);
            Assert.True(opts.AllowDigitSeparator);

            opts = new NumberConvertOptions(ParseNumericStringFlags.HexString | ParseNumericStringFlags.BinaryString);
            Assert.Equal(ParseNumericStringFlags.HexString | ParseNumericStringFlags.BinaryString, opts.ParseFlags);

            Assert.True(opts.ParseHex);
            Assert.False(opts.ParseOctal);
            Assert.True(opts.ParseBinary);
            Assert.False(opts.AllowDigitSeparator);
        }
コード例 #3
0
        public void FromConvertOptions()
        {
            var stringOpts  = new StringConvertOptions(StringAsNullOption.NullReference, TrimStringFlags.None);
            var valOpts     = new ValueTypeConvertOptions(ValueTypeConvertFlags.None);
            var complexOpts = new ComplexNumberConvertOptions(ComplexNumberElement.Real);
            var boolOpts    = new BooleanConvertOptions(new[] { bool.TrueString }, new[] { bool.FalseString });
            var enumOpts    = new EnumConvertOptions(UndefinedValueOption.Throw, UndefinedValueOption.Throw);
            var numberOpts  = new NumberConvertOptions(ParseNumericStringFlags.None);

            var opts = new ConvertOptions(new OptionSet[] { stringOpts, valOpts, complexOpts, boolOpts, enumOpts, numberOpts });

            var builder = ConvertOptionsBuilder.FromConvertOptions(opts);

            Assert.Equal(6, builder.Count());
            Assert.Contains(stringOpts, builder);
            Assert.Contains(valOpts, builder);
            Assert.Contains(complexOpts, builder);
            Assert.Contains(boolOpts, builder);
            Assert.Contains(enumOpts, builder);
            Assert.Contains(numberOpts, builder);
        }
コード例 #4
0
        public void Ctor()
        {
            var opts = new NumberConvertOptions(ParseNumericStringFlags.AllowDigitSeparator);

            Assert.NotNull(opts);
        }
コード例 #5
0
 public ConvertOptions(BooleanConvertOptions booleanOptions, EnumConvertOptions enumOptions, NumberConvertOptions numberOptions, StringConvertOptions stringOptions, ValueTypeConvertOptions valueTypeOptions, params OptionSet[] otherOptions);