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 ); }
public void Category_TestAccessor() { mdnaSettings.Settings settings = new mdnaSettings.Settings(); settings.Category = "foo"; Assert.AreEqual( "foo", settings.Category ); }
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 ) ); }
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 ); }
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 ) ); }
public void Get_NewObjectReturnsEmptySettings() { mdnaSettings.Settings settings = new mdnaSettings.Settings(); Assert.AreEqual( "", settings.Get("foo") ); }
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 ); }
public void Category_UsedInTheConstructor() { mdnaSettings.Settings settings = new mdnaSettings.Settings( "foo" ); Assert.AreEqual( "foo", settings.Category ); }