bloritsch    2003/06/25 07:15:05

  Modified:    csframework/src/test/Configuration
                        AbstractConfigurationTestCase.cs
  Log:
  add some more tests
  
  Revision  Changes    Path
  1.2       +37 -92    
avalon-sandbox/csframework/src/test/Configuration/AbstractConfigurationTestCase.cs
  
  Index: AbstractConfigurationTestCase.cs
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/csframework/src/test/Configuration/AbstractConfigurationTestCase.cs,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractConfigurationTestCase.cs  25 Jun 2003 12:15:23 -0000      1.1
  +++ AbstractConfigurationTestCase.cs  25 Jun 2003 14:15:05 -0000      1.2
  @@ -98,6 +98,17 @@
                        config.Value = "Value";
   
                        Assertion.AssertEquals( "Value", config.Value );
  +
  +                     config.Value = "true";
  +
  +                     Assertion.AssertEquals( true, (bool)config.GetValue(typeof( 
bool ) ) );
  +
  +                     int intValue = (int) config.GetValue(typeof(int), -1);
  +                     Assertion.AssertEquals( -1, intValue );
  +                     
  +                     config.Value = "3";
  +                     intValue = (int) config.GetValue( typeof( int ), -1 );
  +                     Assertion.AssertEquals( 3, intValue );
                }
   
                [Test]
  @@ -143,35 +154,39 @@
                        int x = 0;
                        foreach ( AbstractConfiguration child in config.Children )
                        {
  -                             Assertion.Equals( "Child" + x, child.Name );
  +                             Assertion.AssertEquals( "Child" + x, child.Name );
                                x++;
                        }
                }
   
  -             /// <summary>
  -             /// Gets node attributes.
  -             /// </summary>
  -             /// <value>
  -             /// All attributes of the node.
  -             /// </value>
  -/*           public  IDictionary Attributes
  +             [Test]
  +             public void Attributes()
                {
  -                     get
  -                     {
  -                             if (attributes == null)
  -                             {
  -                                     attributes = new Hashtable();
  -                             }
  +                     AbstractConfiguration config = GetConfiguration();
   
  -                             return attributes;
  -                     }
  +                     Assertion.AssertEquals( 0, config.Attributes.Count );
   
  -                     set
  -                     {
  -                             CheckReadOnly();
  +                     config.Attributes.Add( "Attr1", "Val1" );
   
  -                             attributes = new Hashtable(value);
  -                     }
  +                     Assertion.AssertEquals( 1, config.Attributes.Count );
  +
  +                     Assertion.AssertEquals( "Val1", config.Attributes[ "Attr1" ] );
  +
  +                     config.Attributes.Add( "ValTest", "true" );
  +                     Assertion.AssertEquals( 2, config.Attributes.Count );
  +
  +                     bool valTest = (bool) config.GetAttribute( "ValTest", typeof ( 
bool ) );
  +                     Assertion.AssertEquals( true, valTest );
  +
  +                     config.Attributes["ValTest"] = "3";
  +                     Assertion.AssertEquals( 2, config.Attributes.Count );
  +
  +                     int intValTest = (int) config.GetAttribute( "ValTest", typeof( 
int ), -1 );
  +                     Assertion.AssertEquals( 3, intValTest );
  +
  +                     intValTest = (int) config.GetAttribute( "Attr1", typeof( int 
), -1 );
  +                     Assertion.AssertEquals( -1, intValTest );
  +                     
                }
   
                /// <summary>
  @@ -183,7 +198,7 @@
                ///     The <see 
cref="Apache.Avalon.Framework.Configuration.AbstractConfiguration"/> instance 
encapsulating the specified
                ///     child node.
                /// </returns>
  -             public AbstractConfiguration GetChild(string child)
  +/*           public AbstractConfiguration GetChild(string child)
                {
                        return GetChild(child, false);
                }
  @@ -205,76 +220,6 @@
                /// </returns>
                public abstract AbstractConfiguration GetChild(string child, bool 
createNew);
   
  -             /// <summary>
  -             /// Return an <see cref="ConfigurationCollection"/> of <see 
cref="AbstractConfiguration"/>
  -             /// elements containing all node children with the specified name.
  -             /// </summary>
  -             /// <param name="name">The Name of the children to get.</param>
  -             /// <returns>
  -             /// All node children with the specified name
  -             /// </returns>
  -             public abstract ConfigurationCollection GetChildren(string name);
  -
  -             /// <summary>
  -             /// Gets the value of the node and converts it
  -             /// into specified <see cref="System.Type"/>.
  -             /// </summary>
  -             /// <param name="type">The <see cref="System.Type"/></param>
  -             /// <returns>The Value converted into the specified type.</returns>
  -             /// <exception cref="InvalidCastException">
  -             /// If the convertion fails, an exception will be thrown.
  -             /// </exception>
  -             public object GetValue(Type type)
  -             {
  -                     return GetValue(type, null);
  -             }
  -
  -             /// <summary>
  -             /// Gets the value of the node and converts it
  -             /// into specified <see cref="System.Type"/>.
  -             /// </summary>
  -             /// <param name="type">The <see cref="System.Type"/></param>
  -             /// <param name="defaultValue">
  -             /// The Default value returned if the convertion fails.
  -             /// </param>
  -             /// <returns>The Value converted into the specified type.</returns>
  -             public object GetValue(Type type, object defaultValue)
  -             {
  -
  -                     return Converter.ChangeType(Value, type, defaultValue);
  -             }
  -
  -             /// <summary>
  -             /// Gets the value of specified attribute and
  -             /// converts it into specified <see cref="System.Type"/>.
  -             /// </summary>
  -             /// <param name="name">The Name of the attribute you ask the value 
of.</param>
  -             /// <param name="type">The <see cref="System.Type"/></param>
  -             /// <returns>The Value converted into the specified type.</returns>
  -             /// <exception cref="InvalidCastException">
  -             /// If the convertion fails, an exception will be thrown.
  -             /// </exception>
  -             public object GetAttribute(string name, Type type)
  -             {
  -
  -                     return GetAttribute(name, type, null);
  -             }
  -
  -             /// <summary>
  -             /// Gets the value of specified attribute and
  -             /// converts it into specified <see cref="System.Type"/>.
  -             /// </summary>
  -             /// <param name="name">The Name of the attribute you ask the value 
of.</param>
  -             /// <param name="type">The <see cref="System.Type"/></param>
  -             /// <param name="defaultValue">
  -             /// The Default value returned if the convertion fails.
  -             /// </param>
  -             /// <returns>The Value converted into the specified type.</returns>
  -             public object GetAttribute(string name, Type type, object defaultValue)
  -             {
  -
  -                     return Converter.ChangeType(Attributes[name], type, 
defaultValue);
  -             }
   */
        }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to