示例#1
0
        private OpenSauceIDE.Settings.PropertyTree BuildPropertyTree()
        {
            OpenSauceIDE.Settings.PropertyTree propertyTree = new OpenSauceIDE.Settings.PropertyTree('.');

            propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestBool", mBool);
            propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestByte", mByte);
            propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestSByte", mSByte);
            propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestUShort", mUShort);
            propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestShort", mShort);
            propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestUInt", mUInt);
            propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestInt", mInt);
            propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestFloat", mFloat);
            propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestDouble", mDouble);
            propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestChar", mChar);
            propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestString", mString);
            propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestEnum1", mEnum1);
            propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestEnum2", mEnum2);
            propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestEnum3", mEnum3);

            foreach (var boolValue in mBoolList)
            {
                propertyTree.PutValue("OpenSauceTest.SubList1.TestBoolList", boolValue);
            }

            return(propertyTree);
        }
		private OpenSauceIDE.Settings.PropertyTree BuildPropertyTree()
		{
			OpenSauceIDE.Settings.PropertyTree propertyTree = new OpenSauceIDE.Settings.PropertyTree('.');

			propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestBool", mBool);
			propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestByte", mByte);
			propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestSByte", mSByte);
			propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestUShort", mUShort);
			propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestShort", mShort);
			propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestUInt", mUInt);
			propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestInt", mInt);
			propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestFloat", mFloat);
			propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestDouble", mDouble);
			propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestChar", mChar);
			propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestString", mString);
			propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestEnum1", mEnum1);
			propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestEnum2", mEnum2);
			propertyTree.PutValue("OpenSauceTest.SubList1.SubList2.TestEnum3", mEnum3);

			foreach (var boolValue in mBoolList)
			{
				propertyTree.PutValue("OpenSauceTest.SubList1.TestBoolList", boolValue);
			}

			return propertyTree;
		}
示例#3
0
        public void PropertyTreeGetEnumeratorExceptions()
        {
            OpenSauceIDE.Settings.PropertyTree propertyTree = BuildPropertyTree();

            try
            {
                propertyTree.GetValueEnumerator <bool>("");
                Assert.Fail("Did not exception when passing an empty path.");
            }
            catch { };

            try
            {
                propertyTree.GetValueEnumerator <bool>("OpenSauceTest");
                Assert.Fail("Did not exception when attempting to enumerate root nodes.");
            }
            catch { };

            try
            {
                propertyTree.GetValueEnumerator <bool>("IncorrectRoot.SubList1.TestBoolList");
                Assert.Fail("Did not exception when the root node name was incorrect");
            }
            catch { };

            try
            {
                propertyTree.GetValueEnumerator <bool>("OpenSauceTest.SubList1.SubList2.TestBoolList");
                Assert.Fail("Did not exception when an requested path node was missing.");
            }
            catch { };
        }
示例#4
0
        public void PropertyTreeGetCreateExceptions()
        {
            OpenSauceIDE.Settings.PropertyTree propertyTree = BuildPropertyTree();

            try
            {
                propertyTree.GetValue <int>("", 0xBEEF);
                Assert.Fail("Did not exception when passing an empty path.");
            }
            catch { };

            try
            {
                propertyTree.GetValue <int>("IncorrectRoot.SubList1.SubList2.SubList3.TestBool", 0xBEEF);
                Assert.Fail("Did not exception when the root node name was incorrect.");
            }
            catch { };

            // This one should not exception if a missing node is used
            try
            {
                int value = propertyTree.GetValue <int>("OpenSauceTest.SubList1.SubList2.SubList3.TestBool", 0xBEEF);
                Assert.AreEqual(0xBEEF, value, "Did not return the default value when a requested node was missing.");
            }
            catch
            {
                Assert.Fail("Exceptioned when requesting the value of a missing node that should have been created automatically.");
            };
        }
示例#5
0
        public void PropertyTreeSaveReadXML()
        {
            OpenSauceIDE.Settings.PropertyTree propertyTree = BuildPropertyTree();
            propertyTree.SaveXml(Path.Combine(Directory.GetCurrentDirectory(), "PropertyTreeSaveReadXML.xml"));

            propertyTree = new OpenSauceIDE.Settings.PropertyTree('.');
            propertyTree.ReadXml(Path.Combine(Directory.GetCurrentDirectory(), "PropertyTreeSaveReadXML.xml"));

            TestPropertyTree(propertyTree);
        }
示例#6
0
        public void PropertyTreePutExceptions()
        {
            OpenSauceIDE.Settings.PropertyTree propertyTree = BuildPropertyTree();

            try
            {
                propertyTree.PutValue <bool>("", false);
                Assert.Fail("Did not exception when passing an empty path.");
            }
            catch { };

            try
            {
                propertyTree.PutValue <bool>("IncorrectRoot.SubList1.SubList2.SubList3.TestBool", false);
                Assert.Fail("Did not exception when the root node name was incorrect.");
            }
            catch { };
        }
示例#7
0
        private bool TestPropertyTree(OpenSauceIDE.Settings.PropertyTree propertyTree)
        {
            bool   getBool   = propertyTree.GetValue <bool>("OpenSauceTest.SubList1.SubList2.TestBool");
            byte   getByte   = propertyTree.GetValue <byte>("OpenSauceTest.SubList1.SubList2.TestByte");
            sbyte  getSByte  = propertyTree.GetValue <sbyte>("OpenSauceTest.SubList1.SubList2.TestSByte");
            ushort getUShort = propertyTree.GetValue <ushort>("OpenSauceTest.SubList1.SubList2.TestUShort");
            short  getShort  = propertyTree.GetValue <short>("OpenSauceTest.SubList1.SubList2.TestShort");
            uint   getUInt   = propertyTree.GetValue <uint>("OpenSauceTest.SubList1.SubList2.TestUInt");
            int    getInt    = propertyTree.GetValue <int>("OpenSauceTest.SubList1.SubList2.TestInt");
            float  getFloat  = propertyTree.GetValue <float>("OpenSauceTest.SubList1.SubList2.TestFloat");
            double getDouble = propertyTree.GetValue <double>("OpenSauceTest.SubList1.SubList2.TestDouble");
            char   getChar   = propertyTree.GetValue <char>("OpenSauceTest.SubList1.SubList2.TestChar");
            string getString = propertyTree.GetValue <string>("OpenSauceTest.SubList1.SubList2.TestString");
            PropertyTreeTestEnum getEnum1 = propertyTree.GetValue <PropertyTreeTestEnum>("OpenSauceTest.SubList1.SubList2.TestEnum1");
            PropertyTreeTestEnum getEnum2 = propertyTree.GetValue <PropertyTreeTestEnum>("OpenSauceTest.SubList1.SubList2.TestEnum2");
            PropertyTreeTestEnum getEnum3 = propertyTree.GetValue <PropertyTreeTestEnum>("OpenSauceTest.SubList1.SubList2.TestEnum3");

            Assert.AreEqual(mBool, getBool);
            Assert.AreEqual(mByte, getByte);
            Assert.AreEqual(mSByte, getSByte);
            Assert.AreEqual(mUShort, getUShort);
            Assert.AreEqual(mShort, getShort);
            Assert.AreEqual(mUInt, getUInt);
            Assert.AreEqual(mInt, getInt);
            Assert.AreEqual(mFloat, getFloat);
            Assert.AreEqual(mDouble, getDouble);
            Assert.AreEqual(mChar, getChar);
            Assert.AreEqual(mString, getString);
            Assert.AreEqual(mEnum1, getEnum1);
            Assert.AreEqual(mEnum2, getEnum2);
            Assert.AreEqual(mEnum3, getEnum3);

            var boolEnumerator = propertyTree.GetValueEnumerator <bool>("OpenSauceTest.SubList1.TestBoolList");

            foreach (var boolValue in mBoolList)
            {
                Assert.IsTrue(boolEnumerator.MoveNext());
                Assert.AreEqual(boolValue, boolEnumerator.Current);
            }

            return(true);
        }
		public void PropertyTreeSaveReadXML()
		{
			OpenSauceIDE.Settings.PropertyTree propertyTree = BuildPropertyTree();
			propertyTree.SaveXml(Path.Combine(Directory.GetCurrentDirectory(), "PropertyTreeSaveReadXML.xml"));

			propertyTree = new OpenSauceIDE.Settings.PropertyTree('.');
			propertyTree.ReadXml(Path.Combine(Directory.GetCurrentDirectory(), "PropertyTreeSaveReadXML.xml"));

			TestPropertyTree(propertyTree);
		}
示例#9
0
 public void PropertyTreePutGet()
 {
     OpenSauceIDE.Settings.PropertyTree propertyTree = BuildPropertyTree();
     TestPropertyTree(propertyTree);
 }