/*! @header ECParameterStringTEST @abstract Module of Encore @availability OS X, GNUstep @copyright 2004, 2005, 2006 Oliver Langer This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  -------------------------------------------------------------------------
  Modification history

  18.01.06 ola     initial version
  23.08.06 ola     license changed
  -------------------------------------------------------------------------
  
*/ #include @implementation ECParameterStringTEST - testParameterString { ECParameterString *paramStr; NSMutableDictionary *params; ECDefaultParameterEvaluaterImpl *paramEvaluater; NSString *result; EC_AUTORELEASEPOOL_BEGIN paramEvaluater = [[[ECDefaultParameterEvaluaterImpl alloc] init] autorelease]; paramStr = [[[ECParameterString alloc] initWithFormat: @"Param1: ${param1}, Param2: ${param2}, Param3: ${param3}" parameterEvaluater: paramEvaluater] autorelease]; params = [[[NSMutableDictionary alloc] init] autorelease]; [params setObject: @"Value1" forKey: @"param1"]; [params setObject: @"Value2" forKey: @"param2"]; [params setObject: @"Value3" forKey: @"param3"]; [paramEvaluater setParameterValues: params]; result = [paramStr substituteVariables]; NSLog( @"ECParameterStringTEST::testParameterString: Result=%@", result ); ECAssertTrue( [result isEqual: @"Param1: Value1, Param2: Value2, "\ "Param3: Value3"], @"ECParameterStringTEST:: First test failed!" ); /* now change some values within the dictionary which should have no effect*/ [params setObject: @"NEWValue1" forKey: @"param1"]; [params setObject: @"NEWValue2" forKey: @"param2"]; result = [paramStr substituteVariables]; NSLog( @"ECParameterStringTEST::testParameterString: Result=%@", result ); ECAssertTrue( [result isEqual: @"Param1: Value1, Param2: Value2, "\ "Param3: Value3"], @"ECParameterStringTEST:: Second test failed!" ); /* now change some parameters within the evaluator which should have an * effect: */ [paramEvaluater setValue: @"NEWValue1" forVariable: @"param1"]; [paramEvaluater setValue: @"NEWValue2" forVariable: @"param2"]; result = [paramStr substituteVariables]; NSLog( @"ECParameterStringTEST::testParameterString: Result=%@", result ); ECAssertTrue( [result isEqual: @"Param1: NEWValue1, Param2: NEWValue2, "\ "Param3: Value3"], @"ECParameterStringTEST:: Third test failed!" ); /* now some must haves...: */ paramEvaluater = [[[ECDefaultParameterEvaluaterImpl alloc] init] autorelease]; paramStr = [[[ECParameterString alloc] initWithFormat: @"No parameters at all!" parameterEvaluater: paramEvaluater] autorelease]; result = [paramStr substituteVariables]; NSLog( @"ECParameterStringTEST::testParameterString: Result=%@", result ); ECAssertTrue( [result isEqual: @"No parameters at all!"], @"ECParameterStringTEST:: Fourth test failed!" ); paramStr = [[[ECParameterString alloc] initWithFormat: @"Missing parameter: ${missing}!" parameterEvaluater: paramEvaluater] autorelease]; result = [paramStr substituteVariables]; NSLog( @"ECParameterStringTEST::testParameterString: Result=%@", result ); EC_AUTORELEASEPOOL_END return self; } @end