Beispiel #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 );
        }
Beispiel #2
0
        public void Category_TestAccessor()
        {
            mdnaSettings.Settings settings = new mdnaSettings.Settings();
            settings.Category = "foo";

            Assert.AreEqual( "foo", settings.Category );
        }
Beispiel #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 ) );
        }
Beispiel #4
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 );
        }
Beispiel #5
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 ) );
        }
Beispiel #6
0
 public void Get_NewObjectReturnsEmptySettings()
 {
     mdnaSettings.Settings settings = new mdnaSettings.Settings();
     Assert.AreEqual( "", settings.Get("foo") );
 }
Beispiel #7
0
 public void Count_NewObjectIsInitiallyEmpty()
 {
     // It would be nice to check for null here, but it is unnecessary.
     mdnaSettings.Settings settings = new mdnaSettings.Settings();
     Assert.AreEqual( 0, settings.Count );
 }
Beispiel #8
0
 public void Category_UsedInTheConstructor()
 {
     mdnaSettings.Settings settings = new mdnaSettings.Settings( "foo" );
     Assert.AreEqual( "foo", settings.Category );
 }