Mercurial > hg > audiodb
view bindings/as3/src/tests/TestQuerier.as @ 732:3a0b9700b3d2
* Initial AS3 commit
author | mas01mj |
---|---|
date | Tue, 14 Sep 2010 16:47:10 +0000 |
parents | |
children | 35bfc91b67d3 |
line wrap: on
line source
package tests { import asunit.framework.TestCase; import org.omras2.audiodb.LookupEvent; import org.omras2.audiodb.Querier; import flash.events.ErrorEvent; /** * @author mikej */ public class TestQuerier extends TestCase { private var _querier : Querier; public function TestQuerier(testMethod : String) { super(testMethod); } override protected function setUp() : void { super.setUp(); this._querier = new Querier("http://127.0.0.1:8080"); } public function testLookupSuccess() : void { var handler : Function = addAsync(handleLookupSuccessComplete, 2000); _querier.addEventListener(LookupEvent.COMPLETE, handler); _querier.lookup("AWAL1000"); } public function testLookupFail() : void { var handler : Function = addAsync(handleLookupFailComplete, 2000); _querier.addEventListener(ErrorEvent.ERROR, handler); _querier.lookup("AWAL10000"); } private function handleLookupFailComplete(event : ErrorEvent) : void { assertEquals(event.text, 'Invalid key'); } protected function handleLookupSuccessComplete(event : LookupEvent) : void { assertEquals(event.track.uid, 'AWAL1000'); assertEquals(event.track.artist, 'Moscow Drive'); assertEquals(event.track.seconds, '221000'); } } }