示例#1
0
        public void ParseFileContentsWithString()
        {
            string namelistContent = File.ReadAllText("TestFiles/wrfnamelist.input");

            Namelist nameList = NamelistParser.ParseFromString(namelistContent);
            string   value    = nameList["geogrid"]["map_proj"].Values[0].ToString();

            Assert.AreEqual("lambert", value);

            nameList["geogrid"]["map_proj"].Values.Clear();
            nameList["geogrid"]["map_proj"].Values.Add("test");

            string asString = NamelistParser.ParseToString(nameList);

            Assert.IsTrue(asString.Contains("map_proj = 'test'"));
        }
示例#2
0
        public void ParseFileContents()
        {
            string namelistContent = File.ReadAllText("TestFiles/namelist.input");

            Namelist nameList = NamelistParser.ParseFromString(namelistContent);

            Assert.AreEqual(8, nameList.Sections.Count);
            Assert.AreEqual("time_control", nameList["time_control"].Name);
            Assert.AreEqual("run_days", nameList["time_control"]["run_days"].Name);
            Assert.AreEqual(1, nameList["time_control"].Items[0].Values.Count);
            Assert.AreEqual(125.0, nameList["time_control"]["run_hours"].Values[0]);
            Assert.AreEqual(1, nameList["time_control"]["start_year"].Values.Count);

            string namelistBackToString = NamelistParser.ParseToString(nameList);

            nameList = NamelistParser.ParseFromString(namelistBackToString);

            Assert.AreEqual(8, nameList.Sections.Count);
            Assert.AreEqual("time_control", nameList["time_control"].Name);
            Assert.AreEqual("run_days", nameList["time_control"]["run_days"].Name);
            Assert.AreEqual(1, nameList["time_control"].Items[0].Values.Count);
            Assert.AreEqual(125.0, nameList["time_control"]["run_hours"].Values[0]);
            Assert.AreEqual(1, nameList["time_control"]["start_year"].Values.Count);
        }