Example #1
0
        public void IgnoreCommentLine()
        {
            // Arrange
            var contents = @"#";
            var stream = new MemoryStream(Encoding.UTF8.GetBytes(contents));
            stream.Seek(0, SeekOrigin.Begin);

            var parser = new ConfigParser();

            // Act
            var config = parser.Parse(stream);

            // Assert
            Assert.AreEqual(0, config.Count);
        }
Example #2
0
        public void ParserParsesSimpleKeyValue()
        {
            // Arrange
            var contents = "Key Value";
            var stream = new MemoryStream(Encoding.UTF8.GetBytes(contents));
            stream.Seek(0, SeekOrigin.Begin);

            var parser = new ConfigParser();

            // Act
            var config = parser.Parse(stream);

            // Assert
            Assert.True(config.ContainsKey("Key"));
            Assert.AreEqual(config["Key"], "Value");
        }
Example #3
0
        public void LoadPluginAddsPluginNameToPluginsList()
        {
            // Arrange
            var contents = "LoadPlugin cpu";
            var stream = new MemoryStream(Encoding.UTF8.GetBytes(contents));
            stream.Seek(0, SeekOrigin.Begin);

            var parser = new ConfigParser();

            // Act
            var config = parser.Parse(stream);

            // Assert
            Assert.AreEqual(1, config.Plugins.Count);
            Assert.True(config.Plugins.Contains("cpu"));
        }
Example #4
0
 private ConfigurationFile LoadConfig()
 {
     var parser = new ConfigParser();
     var config = parser.Parse("collectn.conf");
     return config;
 }