Ejemplo n.º 1
0
 public ConfigManager()
 {
     AddSetting("Name", _className = new StringConfigSetting()
     {
         DefaultValue = "Scanner"
     });
     AddSetting("Namespace", _classNamespace = new StringConfigSetting()
     {
         DefaultValue = "Unspecified"
     });
     AddSetting("Visibility", _visibility = new EnumConfigSetting <ClassVisibility>("visibility")
     {
         DefaultValue = ClassVisibility.Default
     });
     AddSetting("ElementSize", _elementSize = new EnumConfigSetting <TableElementSize>("element size")
     {
         DefaultValue = TableElementSize.Default
     });
     AddSetting("TableCompression", _tableCompression = new EnumConfigSetting <Compression>("mode")
     {
         DefaultValue = Compression.Auto
     });
     AddSetting("CacheTables", _cacheTables = new BoolConfigSetting());
     AddSetting("SuppressTableEmbedding", _suppressTableEmbedding = new BoolConfigSetting());
     AddSetting("RenderScanGraph", _renderScanGraph = new EnumConfigSetting <GraphStyle>("style")
     {
         DefaultValue = GraphStyle.Default
     });
 }
Ejemplo n.º 2
0
        public void Reset()
        {
            var setting = new BoolConfigSetting();

            setting.DefaultValue = true;

            Assert.That(setting.Value, Is.EqualTo(false));

            setting.Reset();
            Assert.That(setting.Value, Is.EqualTo(true));
        }
Ejemplo n.º 3
0
        public void SetInvalidType()
        {
            var setting = new BoolConfigSetting();

            var reporter = new Mock <IErrorReporter>(MockBehavior.Strict);
            var token    = new Mock <IToken>(MockBehavior.Strict);

            token.Setup(x => x.Type).Returns(SettingTokenType.String);
            token.Setup(x => x.Text).Returns("true");
            token.Setup(x => x.FromPos).Returns(new CharPos(10, 11, 12));
            token.Setup(x => x.ToPos).Returns(new CharPos(13, 14, 15));
            reporter.Setup(x => x.AddError(11, 12, 14, 15, "\"true\" is not a valid value.")).Verifiable();
            setting.Set(reporter.Object, token.Object);

            Assert.That(setting.Value, Is.EqualTo(false));
            reporter.Verify();
        }
Ejemplo n.º 4
0
 public ConfigManager()
 {
     AddSetting("Name", _parserName = new StringConfigSetting()
     {
         DefaultValue = "Parser"
     });
     AddSetting("TypeName", _typeName        = new StringConfigSetting());
     AddSetting("Namespace", _classNamespace = new StringConfigSetting()
     {
         DefaultValue = "Unspecified"
     });
     AddSetting("Visibility", _visibility = new EnumConfigSetting <ClassVisibility>("visibility")
     {
         DefaultValue = ClassVisibility.Default
     });
     AddSetting("TypeVisibility", _typeVisibility = new EnumConfigSetting <ClassVisibility>("visibility")
     {
         DefaultValue = ClassVisibility.Default
     });
     AddSetting("ElementSize", _elementSize = new EnumConfigSetting <TableElementSize>("element size")
     {
         DefaultValue = TableElementSize.Default
     });
     AddSetting("TableCompression", _tableCompression = new EnumConfigSetting <Compression>("mode")
     {
         DefaultValue = Compression.Auto
     });
     AddSetting("TypeHandling", _typeHandling = new EnumConfigSetting <TypeHandling>("mode")
     {
         DefaultValue = TypeHandling.Default
     });
     AddSetting("RenderParseTable", _renderParseTable = new BoolConfigSetting());
     AddSetting("RenderParseGraph", _renderParseGraph = new EnumConfigSetting <GraphStyle>("style")
     {
         DefaultValue = GraphStyle.Default
     });
     AddSetting("Trace", _trace             = new BoolConfigSetting());
     AddSetting("CacheTables", _cacheTables = new BoolConfigSetting());
     AddSetting("SuppressTableEmbedding", _suppressTableEmbedding = new BoolConfigSetting());
     AddSetting("TrimParseGraph", _trimParseGraph = new BoolConfigSetting()
     {
         DefaultValue = true
     });
     AddSetting("TokenType", _tokenType = new LabelConfigSetting());
 }
Ejemplo n.º 5
0
        public void SetValidValue()
        {
            var setting = new BoolConfigSetting();

            var reporter = new Mock <IErrorReporter>(MockBehavior.Strict);
            var token    = new Mock <IToken>(MockBehavior.Strict);

            token.Setup(x => x.Type).Returns(SettingTokenType.Label);
            token.Setup(x => x.Text).Returns("true");

            setting.Set(reporter.Object, token.Object);

            Assert.That(setting.Value, Is.EqualTo(true), "set to true");

            token.Setup(x => x.Type).Returns(SettingTokenType.Label);
            token.Setup(x => x.Text).Returns("false");

            setting.Set(reporter.Object, token.Object);

            Assert.That(setting.Value, Is.EqualTo(false), "set to false");
        }