public void Reset()
        {
            var setting = new LabelConfigSetting();

            setting.DefaultValue = "Text";

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

            setting.Reset();
            Assert.That(setting.Value, Is.EqualTo("Text"));
        }
        public void SetValidValue()
        {
            var setting = new LabelConfigSetting();

            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("TextValue");

            setting.Set(reporter.Object, token.Object);
            Assert.That(setting.Value, Is.EqualTo("TextValue"));
        }
        public void SetStringValue()
        {
            var setting = new LabelConfigSetting();

            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.FromPos).Returns(new CharPos(10, 11, 12));
            token.Setup(x => x.ToPos).Returns(new CharPos(13, 14, 15));
            token.Setup(x => x.Text).Returns("String Value");

            reporter.Setup(x => x.AddError(11, 12, 14, 15, "'String Value' is not a valid value.")).Verifiable();
            setting.Set(reporter.Object, token.Object);
            Assert.That(setting.Value, Is.EqualTo(null));
            reporter.Verify();
        }
예제 #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());
 }