bloritsch    2003/06/26 09:00:30

  Modified:    csframework AvalonFramework.build
               csframework/src/cs/Configuration DefaultConfiguration.cs
               csframework/src/test/Configuration
                        AbstractConfigurationTestCase.cs
                        DefaultConfigurationTestCase.cs
  Log:
  add test case and catch error
  
  Revision  Changes    Path
  1.10      +1 -0      avalon-sandbox/csframework/AvalonFramework.build
  
  Index: AvalonFramework.build
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/csframework/AvalonFramework.build,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- AvalonFramework.build     26 Jun 2003 14:20:13 -0000      1.9
  +++ AvalonFramework.build     26 Jun 2003 16:00:30 -0000      1.10
  @@ -29,6 +29,7 @@
            <includes name="${nant.location}/nunit.framework.dll"/>
          </references>
          <sources basedir="src/test">
  +         <includes name="*.cs"/>
            <includes name="Configuration/*.cs"/>
          </sources>
        </csc>
  
  
  
  1.8       +3 -1      
avalon-sandbox/csframework/src/cs/Configuration/DefaultConfiguration.cs
  
  Index: DefaultConfiguration.cs
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/csframework/src/cs/Configuration/DefaultConfiguration.cs,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DefaultConfiguration.cs   24 Jun 2003 12:18:24 -0000      1.7
  +++ DefaultConfiguration.cs   26 Jun 2003 16:00:30 -0000      1.8
  @@ -161,11 +161,13 @@
                                        }
                                }
                        }
  -                     else
  +                     
  +                     if ( result == null )
                        {
                                if( createNew )
                                {
                                        result = new DefaultConfiguration( name, 
string.Empty );
  +                                     Children.Add( result );
                                }
                        }
   
  
  
  
  1.3       +9 -32     
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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractConfigurationTestCase.cs  25 Jun 2003 14:15:05 -0000      1.2
  +++ AbstractConfigurationTestCase.cs  26 Jun 2003 16:00:30 -0000      1.3
  @@ -136,6 +136,11 @@
                {
                        AbstractConfiguration config = GetConfiguration();
   
  +                     IConfiguration fooBar = config.GetChild("FooBar", false );
  +                     Assertion.AssertNull( fooBar );
  +                     fooBar = config.GetChild("FooBar", true);
  +                     Assertion.AssertNotNull( fooBar );
  +
                        Assertion.AssertNotNull( config.Children );
   
                        ConfigurationCollection collection = config.Children;
  @@ -149,6 +154,10 @@
   
                        config.Children = collection;
   
  +                     Assertion.AssertEquals( 11, config.Children.Count );
  +
  +                     config.Children.Remove( fooBar );
  +                     
                        Assertion.AssertEquals( 10, config.Children.Count );
   
                        int x = 0;
  @@ -189,37 +198,5 @@
                        
                }
   
  -             /// <summary>
  -             ///     Gets a <see 
cref="Apache.Avalon.Framework.Configuration.AbstractConfiguration"/> instance 
encapsulating the specified
  -             /// child node.
  -             /// </summary>
  -             /// <param name="child">The Name of the child node.</param>
  -             /// <returns>
  -             ///     The <see 
cref="Apache.Avalon.Framework.Configuration.AbstractConfiguration"/> instance 
encapsulating the specified
  -             ///     child node.
  -             /// </returns>
  -/*           public AbstractConfiguration GetChild(string child)
  -             {
  -                     return GetChild(child, false);
  -             }
  -
  -             /// <summary>
  -             ///     Gets a <see 
cref="Apache.Avalon.Framework.Configuration.AbstractConfiguration"/> instance 
encapsulating the specified
  -             /// child node.
  -             /// </summary>
  -             /// <param name="child">The Name of the child node.</param>
  -             /// <param name="createNew">
  -             ///     If <see langword="true"/>, a new <see 
cref="Apache.Avalon.Framework.Configuration.AbstractConfiguration"/>
  -             /// will be created and returned if the specified child does not exist.
  -             /// If <see langword="false"/>, <see langword="null"/> will be 
returned when the specified
  -             /// child doesn't exist.
  -             /// </param>
  -             /// <returns>
  -             ///     The <see 
cref="Apache.Avalon.Framework.Configuration.AbstractConfiguration"/> instance 
encapsulating the specified
  -             ///     child node.
  -             /// </returns>
  -             public abstract AbstractConfiguration GetChild(string child, bool 
createNew);
  -
  -*/
        }
   }
  
  
  
  1.2       +18 -64    
avalon-sandbox/csframework/src/test/Configuration/DefaultConfigurationTestCase.cs
  
  Index: DefaultConfigurationTestCase.cs
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/csframework/src/test/Configuration/DefaultConfigurationTestCase.cs,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultConfigurationTestCase.cs   25 Jun 2003 12:15:23 -0000      1.1
  +++ DefaultConfigurationTestCase.cs   26 Jun 2003 16:00:30 -0000      1.2
  @@ -63,80 +63,34 @@
                        return new DefaultConfiguration("Name", "Location", 
"Namespace", "Prefix");
                }
   
  -
  -             /*
  -             public override IConfiguration GetChild(string name, bool createNew )
  +             [Test]
  +             public void DefaultChildren()
                {
  -                     IConfiguration result = null;
  +                     IConfiguration config = GetConfiguration();
   
  -                     if (Children.Count != 0)
  -                     {
  +                     IConfiguration child = config.GetChild("Child", false);
  +                     Assertion.AssertNull( child );
   
  -                             foreach (IConfiguration configuration in Children)
  -                             {
  -                                     if (string.Compare(configuration.Name, name) 
== 0)
  -                                     {
  -                                             result = configuration;
  -                                             break;
  -                                     }
  -                             }
  -                     }
  -                     else
  +                     child = config.GetChild("Child", true);
  +                     Assertion.AssertNotNull( child );
  +
  +                     for( int i = 0; i < 10; i++ )
                        {
  -                             if( createNew )
  -                             {
  -                                     result = new DefaultConfiguration( name, 
string.Empty );
  -                             }
  +                             DefaultConfiguration testChild = new 
DefaultConfiguration( "test", "Apache.Avalon.Framework.DefaultConfigurationTest" );
  +                             testChild.Value = "value";
  +                             config.Children.Add( testChild );
                        }
   
  -                     return result;
  -             }
  +                     Assertion.AssertEquals( 11, config.Children.Count );
   
  -             /// <summary>
  -             /// Return a collection of <see cref="IConfiguration"/>
  -             /// elements containing all node children with the specified name.
  -             /// </summary>
  -             /// <param name="name">The Name of the children to get.</param>
  -             /// <returns>
  -             /// The collection of <see cref="IConfiguration"/> children of
  -             /// this associated with the given name.
  -             /// </returns>
  -             public override ConfigurationCollection GetChildren(string name)
  -             {
  -                     ConfigurationCollection result = new ConfigurationCollection();
  +                     ConfigurationCollection coll = config.GetChildren( "test" );
  +                     Assertion.AssertEquals( 10, coll.Count );
   
  -                     foreach (IConfiguration configuration in Children)
  +                     foreach( IConfiguration testConfig in coll )
                        {
  -                             if (string.Compare(configuration.Name, name) == 0)
  -                             {
  -                                     result.Add(configuration);
  -                             }
  +                             Assertion.AssertEquals( "test", testConfig.Name );
  +                             Assertion.AssertEquals( "value", testConfig.Value );
                        }
  -
  -                     return result;
                }
  -
  -             /// <summary>
  -             /// Populates a <see cref="SerializationInfo"/> with the data needed
  -             /// to serialize the target object.
  -             /// </summary>
  -             /// <param name="info">The <see cref="SerializationInfo"/> to populate 
with data.</param>
  -             /// <param name="context">The destination for this 
serialization.</param>
  -             public void GetObjectData(SerializationInfo info, StreamingContext 
context)
  -             {
  -                     info.AddValue(SERIAL_NAME_NAME, Name);
  -                     info.AddValue(SERIAL_NAME_LOCATION, Location);
  -                     info.AddValue(SERIAL_NAME_NAMESPACE, Namespace);
  -                     info.AddValue(SERIAL_NAME_PREFIX, Prefix);
  -
  -                     info.AddValue(SERIAL_NAME_VALUE, Value);
  -
  -                     info.AddValue(SERIAL_NAME_READ_ONLY, IsReadOnly);
  -
  -                     RuntimeSerializer.SerializeIDictionary(info, Attributes,
  -                             SERIAL_NAME_ATTRIBUTE_KEYS, 
SERIAL_NAME_ATTRIBUTE_VALUES);
  -
  -                     RuntimeSerializer.SerializeICollection(info, Children, 
SERIAL_NAME_CHILDREN);
  -             }*/
        }
   }
  
  
  

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

Reply via email to