hi.

i have a question on using asunit to test a class that loads XML. 

i have a class that accepts a string in its constructor and i want to test if 
it'll accept not just an http://myFileLocation.xml but also a file location 
such as "/data/config.xml". 

my question is how can i write my test with a handler for when the xml is 
finished loading? 

this is what i have right now: 

class com.testsource.util.ConfigParserTest extends 
com.asunit.framework.TestCase {
 private var className:String = "com.testsource.util.ConfigParserTest";
 private var configParser:ConfigParser;

 public function setUp():Void {
trace("setUp: " + setUp());  
configParser = new ConfigParser("data/config.xml");
  configParser.addEventListener("loadSuccess", 
Delegate.create(this,testLoadFileLocation));
 }

 public function tearDown():Void {
trace("tearDown()");  
delete configParser;
  }
 
 public function testLoadFileLocation():Void{
  var size:Number = configParser.getLayerSetSize(); // this should return the 
number 2.
  trace("size: " + size);
  assertEquals("example test", size, 2);
 }
}

the problem here is that my test is run and testLoadFileLocation() is run 
before my XML successfully loads. and by the time it does load, the 
'configParser" object has been deleted by the tearDown() method. 

so my traces come out looking like this:
setUp()
size: 0
tearDown()
size: undefined

any tips are greatly appreciated. 

thanks. -- matt.
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to