コード例 #1
0
        public void BuildAndSaveTest()
        {
            INIWriter builder = new INIWriter();

            builder.AppendKVP("Int32Key", -12);
            builder.AppendKVP("FloatKey", 1.1F);
            builder.AppendKVP("DoubleKey", 1.2);
            builder.AppendKVP("BooleanKey", true);
            builder.AppendKVP("StringKey", "TestString");
            builder.AppendKVP("NullStringKey", null);
            builder.AppendKVP("EmptyStringKey", "");
            builder.AppendKVP("SpaceStringKey", " ");
            builder.AppendKVP("UnsupportedCharsStringTypeKey", "a" + Environment.NewLine + "b");

            bool saveResult = builder.Save(_testsDataPath);

            Assert.IsTrue(saveResult);

            string expected =
                @"Int32Key = -12
FloatKey = 1.1
DoubleKey = 1.2
BooleanKey = True
StringKey = TestString
NullStringKey = NULL
EmptyStringKey = 
SpaceStringKey =  
UnsupportedCharsStringTypeKey = a|13||10|b";
            string actual = File.ReadAllText(_testsDataPath);

            Assert.AreEqual(expected, actual);
        }
コード例 #2
0
        public void BuildTest_NullValue()
        {
            INIWriter builder = new INIWriter();

            builder.AppendKVP("NullKeyTest", null);

            bool saveResult = builder.Save(_testsDataPath);

            Assert.IsTrue(saveResult);

            string expected = "NullKeyTest = NULL";
            string actual   = File.ReadAllText(_testsDataPath);

            Assert.AreEqual(expected, actual);
        }
コード例 #3
0
        public void CreateTestFile()
        {
            INIWriter builder = new INIWriter();

            builder.AppendKVP("Int32TypeValue", 123);
            builder.AppendKVP("FloatTypeValue", -123.6F);
            builder.AppendKVP("DoubleTypeValue", 123.4);
            builder.AppendKVP("BooleanTypeValue", false);

            builder.AppendKVP("StringTypeValue", "123");
            builder.AppendKVP("NullStringTypeValue", null);
            builder.AppendKVP("EmptyStringTypeValue", "");
            builder.AppendKVP("SpaceStringTypeValue", " ");
            builder.AppendKVP("KVPPatternStringTypeValue", "(some text 1) = (some text 2)");
            builder.AppendKVP("UnsupportedCharsStringTypeValue", "a" + Environment.NewLine + "b");
            builder.AppendKVP("UnsupportedCharsStringTypeValue2", "|");

            //builder.AppendKVP("Key with spaces", 999); // Исключение как и положено

            builder.Save(_testINIFilePath);

            _parser = new INIReader(_testINIFilePath);
        }