Exemple #1
0
        public mdnaSettings.Settings Load( string category )
        {
            mdnaSettings.Settings result = new mdnaSettings.Settings();

            XPathDocument doc = new XPathDocument( m_fileName );
            XPathNavigator nav = doc.CreateNavigator();

            // Get the expression compiled.
            // We want all of the nodes in the category regardless of position or their attributes.
            XPathExpression expr;
            expr = nav.Compile( "//"+category );
            XPathNodeIterator iter = nav.Select(expr);

            result.Category = category;

            try
            {
                while( iter.MoveNext() )
                {
                    result.Add( iter.Current.GetAttribute( "name", "" ), iter.Current.GetAttribute( "value", "" ) );
                }
            }
            catch( Exception ex )
            {
                MessageBox.Show( "Exception Caught: " + ex.Message );
            }

            return( result );
        }
Exemple #2
0
        public void Clear_AddManyKeysThenClear()
        {
            mdnaSettings.Settings settings = new mdnaSettings.Settings();

            Assert.AreEqual( 0, settings.Count );

            settings.Add( "foo", "bar" );
            settings.Add( "peanut butter", "jelly" );
            settings.Add( "laverne", "shirley" );

            Assert.AreEqual( 3, settings.Count );

            settings.Clear();

            Assert.AreEqual( 0, settings.Count );
        }
Exemple #3
0
        public void Add_InsertNewSetting()
        {
            mdnaSettings.Settings settings = new mdnaSettings.Settings();

            settings.Clear();
            Assert.AreEqual( 0, settings.Count );

            settings.Add( m_settingName, m_settingNameValue );

            Assert.AreEqual( settings.Count, 1 );
            Assert.AreEqual( m_settingNameValue, settings.Get( m_settingName ) );
        }
Exemple #4
0
        public void Remove_ClearSettingsAddAnObjectThenRemoveIt( )
        {
            mdnaSettings.Settings settings = new mdnaSettings.Settings();

            settings.Clear();
            Assert.AreEqual( 0, settings.Count );

            settings.Add( m_settingName, m_settingNameValue );
            Assert.AreEqual( 1, settings.Count );

            settings.Remove( m_settingName );
            Assert.AreEqual( 0, settings.Count );

            Assert.AreEqual( "", settings.Get( m_settingName ) );
        }