public void ShouldHandleEmptyString()
            {
                var parser = new ConfigFileParser(new ScriptConsole());
                var result = parser.Parse("");

                result.ShouldBeNull();
            }
Ejemplo n.º 2
0
        private void Load()
        {
            if (string.IsNullOrEmpty(Path.GetFileName(_fileName)) || !File.Exists(_fileName))
                return;

            ConfigFileParser parser = new ConfigFileParser(this);
            parser.Parse();
        }
            public void ShouldHandleConfigMalformedConfig()
            {
                const string file = "{\"Install\": \"install ";

                var parser = new ConfigFileParser(new ScriptConsole());
                var result = parser.Parse(file);

                result.ShouldBeNull();
            }
Ejemplo n.º 4
0
        private void Load()
        {
            if (string.IsNullOrEmpty(Path.GetFileName(FileName)) || !File.Exists(FileName))
            {
                return;
            }

            ConfigFileParser parser = new ConfigFileParser(this);
            parser.Parse();
        }
            public void ShouldHandleConfigFile()
            {
                const string file = "{\"Install\": \"install test value\", \"script\": \"server.csx\" }";

                var parser = new ConfigFileParser(new ScriptConsole());
                var result = parser.Parse(file);

                result.ShouldNotBeNull();
                result.ScriptName.ShouldEqual("server.csx");
                result.Install.ShouldEqual("install test value");
            }
            public void ShouldHanldeArgumentTypeConversionBool()
            {
                const string file = "{\"Install\": \"install test value\", \"script\": \"server.csx\", \"cache\": \"true\" }";

                var parser = new ConfigFileParser(new ScriptConsole());
                var result = parser.Parse(file);

                result.ShouldNotBeNull();
                result.ScriptName.ShouldEqual("server.csx");
                result.Install.ShouldEqual("install test value");
                result.Cache.ShouldEqual(true);
            }
            public void ShouldHandleConfigArgumentsCaseInsensitive()
            {
                const string file = "{\"Install\": \"install test value\", \"script\": \"server.csx\", \"cache\": \"tRUe\", \"logLEVEL\": \"TRaCE\" }";

                var parser = new ConfigFileParser(new ScriptConsole());
                var result = parser.Parse(file);

                result.ShouldNotBeNull();
                result.ScriptName.ShouldEqual("server.csx");
                result.Install.ShouldEqual("install test value");
                result.Cache.ShouldEqual(true);
                result.LogLevel.ShouldEqual(LogLevel.Trace);
            }
            public void ShouldHanldeArgumentTypeConversionEnum()
            {
                const string file = "{\"Install\": \"install test value\", \"script\": \"server.csx\", \"inMemory\": \"true\", \"log\": \"error\" }";

                var parser = new ConfigFileParser(new ScriptConsole());
                var result = parser.Parse(file);

                result.ShouldNotBeNull();
                result.ScriptName.ShouldEqual("server.csx");
                result.Install.ShouldEqual("install test value");
                result.InMemory.ShouldEqual(true);
                result.LogLevel.ShouldEqual(LogLevel.Error);
            }
Ejemplo n.º 9
0
        [TestMethod] public void ParseConfigObject()
        {
            ConfigObject mdObject;
            string       filePath = @"C:\temp\original.txt";

            using (StreamReader stream = new StreamReader(filePath, Encoding.UTF8))
            {
                mdObject = FileParser.Parse(stream);
            }
            using (StreamWriter stream = new StreamWriter(@"C:\temp\original_parsed.txt", false, Encoding.UTF8))
            {
                WriteToFile(stream, mdObject, 0, string.Empty);
            }
            filePath = @"C:\temp\changed.txt";
            using (StreamReader stream = new StreamReader(filePath, Encoding.UTF8))
            {
                mdObject = FileParser.Parse(stream);
            }
            using (StreamWriter stream = new StreamWriter(@"C:\temp\changed_parsed.txt", false, Encoding.UTF8))
            {
                WriteToFile(stream, mdObject, 0, string.Empty);
            }
        }
Ejemplo n.º 10
0
        public void LoadFromString(string str)
        {
            ConfigFileParser parser = new ConfigFileParser(this);

            parser.Parse(str);
        }
Ejemplo n.º 11
0
 public void LoadFromString(string str)
 {
     ConfigFileParser parser = new ConfigFileParser(this);
     parser.Parse(str);
 }