|
From: <luk...@us...> - 2006-09-20 18:24:39
|
Revision: 105
http://svn.sourceforge.net/asunit/?rev=105&view=rev
Author: lukebayes
Date: 2006-09-20 11:24:28 -0700 (Wed, 20 Sep 2006)
Log Message:
-----------
moving test classes into their own directory
Added Paths:
-----------
trunk/framework-test/
trunk/framework-test/as3/
trunk/framework-test/as3/asunit/
trunk/framework-test/as3/asunit/framework/
trunk/framework-test/as3/asunit/framework/AssertTest.as
trunk/framework-test/as3/asunit/framework/MockData.xml
trunk/framework-test/as3/asunit/framework/TestCaseMock.as
trunk/framework-test/as3/asunit/framework/TestCaseTest.as
trunk/framework-test/as3/asunit/framework/TestFailureTest.as
trunk/framework-test/as3/asunit/framework/VisualTestCaseTest.as
trunk/framework-test/as3/asunit/runner/
trunk/framework-test/as3/asunit/runner/BaseTestRunnerMock.as
trunk/framework-test/as3/asunit/textui/
trunk/framework-test/as3/asunit/textui/TestRunnerTest.as
trunk/framework-test/as3/asunit/textui/TestRunnerTestCaseMock.as
trunk/framework-test/as3/asunit/util/
trunk/framework-test/as3/asunit/util/ArrayIteratorTest.as
Added: trunk/framework-test/as3/asunit/framework/AssertTest.as
===================================================================
--- trunk/framework-test/as3/asunit/framework/AssertTest.as (rev 0)
+++ trunk/framework-test/as3/asunit/framework/AssertTest.as 2006-09-20 18:24:28 UTC (rev 105)
@@ -0,0 +1,187 @@
+package asunit.framework {
+
+ import flash.errors.IllegalOperationError;
+ import flash.display.Sprite;
+
+ public class AssertTest extends TestCase {
+
+ public function AssertTest(testMethod:String = null) {
+ super(testMethod);
+ }
+
+ public function testAssertTrue():void {
+ assertTrue(true);
+ }
+
+ public function testAssertFalse():void {
+ assertFalse(false);
+ }
+
+ public function testAssertFalseWithMessage():void {
+ assertFalse("message", false);
+ }
+
+ public function testAssertTrueWithMessage():void {
+ assertTrue("message", true);
+ }
+
+ public function testAssertTrueFailure():void {
+ try {
+ assertTrue(false);
+ }
+ catch(e:Error) {
+ return;
+ }
+ assertTrue("assertTrue(false) should have failed but didn't", false);
+ }
+
+ public function testAssertTrueMessage():void {
+ assertTrue("asertTrue with message", true);
+ }
+
+ public function testAssertTrueMessageFailure():void {
+ try {
+ assertTrue("trueMessage", false);
+ }
+ catch(e:Error) {
+ return;
+ }
+ assertTrue("assertTrue('message', false) should have failed but didn't", false);
+ }
+
+ public function testFail():void {
+ try {
+ Assert.fail("this shouldn't be caught");
+ }
+ catch(e:Error) {
+ assertTrue("passed", true);
+ return;
+ }
+ fail("failure should be thrown");
+ }
+
+ public function testAssertEqualsSimple():void {
+ var obj1:Object = new Object();
+ assertEquals(obj1, obj1);
+ }
+
+ public function testEqualsMethod():void {
+ var obj1:Object = new Object();
+ obj1.equals = function():Boolean {
+ return true;
+ }
+
+ var obj2:Object = new Object();
+ obj2.equals = function():Boolean {
+ return true;
+ }
+ assertEquals(obj1, obj2);
+ }
+
+ public function testEqualsSimpleMessage():void {
+ var obj1:Object = new Object();
+ assertEquals("message", obj1, obj1);
+ }
+
+ public function testEqualsFailure():void {
+ var obj1:Object = new Object();
+ var obj2:Object = new Object();
+ try {
+ assertEquals(obj1, obj2);
+ }
+ catch(e:Error) {
+ return;
+ }
+ fail("obj1 does not equal obj2");
+ }
+
+ public function testEqualsSimpleMessageFailure():void {
+ try {
+ var obj1:Object = new Object();
+ var obj2:Object = new Object();
+ assertEquals("message", obj1, obj2);
+ }
+ catch(e:Error) {
+ return;
+ }
+ fail("obj1 does not equal obj2 with message");
+ }
+
+ public function testNull():void {
+ assertNull(null);
+ }
+
+ public function testNullMessage():void {
+ assertNull("message", null);
+ }
+
+ public function testNullFailure():void {
+ var obj:Object = new Object();
+ try {
+ assertNull("message", obj);
+ }
+ catch(e:Error) {
+ return;
+ }
+ fail("null failure");
+ }
+
+ public function testNotNull():void {
+ var obj:Object = new Object();
+ assertNotNull(obj);
+ }
+
+ public function testNotNullFailure():void {
+ try {
+ assertNotNull(null);
+ }
+ catch(e:Error) {
+ return;
+ }
+ fail("not null failed");
+ }
+
+ public function testNotNullMessage():void {
+ var obj:Object = new Object();
+ assertNotNull("not null", obj);
+ }
+
+ public function testSame():void {
+ var obj:Object = new Object();
+ assertSame(obj, obj);
+ }
+
+ public function testSameFailure():void {
+ try {
+ assertSame(new Object(), new Object());
+ }
+ catch(e:Error) {
+ return;
+ }
+ fail("same failure");
+ }
+
+ public function testNotSame():void {
+ var obj1:Object = new Object();
+ var obj2:Object = new Object();
+ assertNotSame(obj1, obj2);
+ }
+
+ public function testNotSameFailure():void {
+ var obj1:Object = new Object();
+ try {
+ assertNotSame(obj1, obj1);
+ }
+ catch(e:Error) {
+ return;
+ }
+ fail("not same failure");
+ }
+
+ public function testNotSameMessage():void {
+ var obj1:Object = new Object();
+ var obj2:Object = new Object();
+ assertNotSame("not same message", obj1, obj2);
+ }
+ }
+}
\ No newline at end of file
Added: trunk/framework-test/as3/asunit/framework/MockData.xml
===================================================================
--- trunk/framework-test/as3/asunit/framework/MockData.xml (rev 0)
+++ trunk/framework-test/as3/asunit/framework/MockData.xml 2006-09-20 18:24:28 UTC (rev 105)
@@ -0,0 +1,8 @@
+<books>
+ <book publisher="Addison-Wesley" name="Design Patterns" />
+ <book publisher="Addison-Wesley" name="The Pragmatic Programmer" />
+ <book publisher="Addison-Wesley" name="Test Driven Development" />
+ <book publisher="Addison-Wesley" name="Refactoring to Patterns" />
+ <book publisher="O'Reilly Media" name="The Cathedral & the Bazaar" />
+ <book publisher="O'Reilly Media" name="Unit Test Frameworks" />
+</books>
\ No newline at end of file
Added: trunk/framework-test/as3/asunit/framework/TestCaseMock.as
===================================================================
--- trunk/framework-test/as3/asunit/framework/TestCaseMock.as (rev 0)
+++ trunk/framework-test/as3/asunit/framework/TestCaseMock.as 2006-09-20 18:24:28 UTC (rev 105)
@@ -0,0 +1,24 @@
+package asunit.framework {
+
+ public class TestCaseMock extends TestCase {
+ public var testMethod1Run:Boolean;
+ public var testMethod2Run:Boolean;
+ public var testMethod3Run:Boolean;
+
+ public function TestCaseMock(methodName:String = null) {
+ super(methodName);
+ }
+
+ public function testMethod1():void {
+ testMethod1Run = true;
+ }
+
+ public function testMethod2():void {
+ testMethod2Run = true;
+ }
+
+ public function testMethod3():void {
+ testMethod3Run = true;
+ }
+ }
+}
\ No newline at end of file
Added: trunk/framework-test/as3/asunit/framework/TestCaseTest.as
===================================================================
--- trunk/framework-test/as3/asunit/framework/TestCaseTest.as (rev 0)
+++ trunk/framework-test/as3/asunit/framework/TestCaseTest.as 2006-09-20 18:24:28 UTC (rev 105)
@@ -0,0 +1,45 @@
+package asunit.framework {
+
+ public class TestCaseTest extends TestCase {
+
+ public function TestCaseTest(testMethod:String = null) {
+ super(testMethod);
+ }
+
+ public function testInstantiated():void {
+ assertTrue(this is TestCase);
+ }
+
+ public function testCustomConstructor():void {
+ var mock:TestCaseMock = new TestCaseMock("testMethod1");
+ mock.run();
+ assertTrue("testMethod1Run", mock.testMethod1Run);
+ assertFalse("testMethod2Run", mock.testMethod2Run);
+ assertFalse("testMethod3Run", mock.testMethod3Run);
+ }
+
+ public function testCustomConstructor2():void {
+ var mock:TestCaseMock = new TestCaseMock("testMethod1, testMethod3");
+ mock.run();
+ assertTrue("testMethod1Run", mock.testMethod1Run);
+ assertFalse("testMethod2Run", mock.testMethod2Run);
+ assertTrue("testMethod3Run", mock.testMethod3Run);
+ }
+
+ public function testCustomConstructor3():void {
+ var mock:TestCaseMock = new TestCaseMock("testMethod1,testMethod3");
+ mock.run();
+ assertTrue("testMethod1Run", mock.testMethod1Run);
+ assertFalse("testMethod2Run", mock.testMethod2Run);
+ assertTrue("testMethod3Run", mock.testMethod3Run);
+ }
+
+ public function testCustomConstructor4():void {
+ var mock:TestCaseMock = new TestCaseMock("testMethod1, testMethod2,testMethod3");
+ mock.run();
+ assertTrue("testMethod1Run", mock.testMethod1Run);
+ assertTrue("testMethod2Run", mock.testMethod2Run);
+ assertTrue("testMethod3Run", mock.testMethod3Run);
+ }
+ }
+}
\ No newline at end of file
Added: trunk/framework-test/as3/asunit/framework/TestFailureTest.as
===================================================================
--- trunk/framework-test/as3/asunit/framework/TestFailureTest.as (rev 0)
+++ trunk/framework-test/as3/asunit/framework/TestFailureTest.as 2006-09-20 18:24:28 UTC (rev 105)
@@ -0,0 +1,14 @@
+package asunit.framework {
+
+ public class TestFailureTest extends TestCase {
+
+ public function TestFailureTest(testMethod:String = null) {
+ super(testMethod);
+ }
+
+ public function testInstantiated():void {
+ var failure:TestFailure = new TestFailure(this, new Error());
+ assertTrue(failure is TestFailure);
+ }
+ }
+}
\ No newline at end of file
Added: trunk/framework-test/as3/asunit/framework/VisualTestCaseTest.as
===================================================================
--- trunk/framework-test/as3/asunit/framework/VisualTestCaseTest.as (rev 0)
+++ trunk/framework-test/as3/asunit/framework/VisualTestCaseTest.as 2006-09-20 18:24:28 UTC (rev 105)
@@ -0,0 +1,43 @@
+package asunit.framework {
+ import flash.display.Sprite;
+
+ public class VisualTestCaseTest extends TestCase {
+ private var instance:Sprite;
+
+ public function VisualTestCaseTest(testMethod:String = null) {
+ super(testMethod);
+ }
+
+ protected override function setUp():void {
+ instance = new Sprite();
+ addChild(instance);
+ }
+
+ protected override function tearDown():void {
+ removeChild(instance);
+ }
+
+ public function testInstance():void {
+ assertTrue(instance is Sprite);
+ }
+
+ public function testSize():void {
+ assertTrue(instance.width == 0);
+ assertTrue(instance.height == 0);
+ }
+
+ public function testDrawnSize():void {
+ instance.graphics.beginFill(0xFF0000);
+ instance.graphics.drawRect(0, 0, 10, 20);
+
+ assertTrue(instance.width == 10);
+ assertTrue(instance.height == 20);
+ }
+
+ public function testSecondSize():void {
+ assertTrue(instance.width == 0);
+ assertTrue(instance.height == 0);
+ }
+
+ }
+}
\ No newline at end of file
Added: trunk/framework-test/as3/asunit/runner/BaseTestRunnerMock.as
===================================================================
--- trunk/framework-test/as3/asunit/runner/BaseTestRunnerMock.as (rev 0)
+++ trunk/framework-test/as3/asunit/runner/BaseTestRunnerMock.as 2006-09-20 18:24:28 UTC (rev 105)
@@ -0,0 +1,6 @@
+package asunit.runner {
+
+ public class BaseTestRunnerMock extends BaseTestRunner {
+
+ }
+}
\ No newline at end of file
Added: trunk/framework-test/as3/asunit/textui/TestRunnerTest.as
===================================================================
--- trunk/framework-test/as3/asunit/textui/TestRunnerTest.as (rev 0)
+++ trunk/framework-test/as3/asunit/textui/TestRunnerTest.as 2006-09-20 18:24:28 UTC (rev 105)
@@ -0,0 +1,55 @@
+package asunit.textui {
+ import asunit.framework.TestCase;
+ import flash.utils.setTimeout;
+ import flash.events.Event;
+ import flash.errors.IllegalOperationError;
+
+ public class TestRunnerTest extends TestCase {
+ private var instance:TestRunner;
+
+ public function TestRunnerTest(testMethod:String = null) {
+ super(testMethod);
+ }
+
+ protected override function setUp():void {
+ instance = new TestRunner();
+ addChild(instance);
+ }
+
+ protected override function tearDown():void {
+ removeChild(instance);
+ instance = null;
+ }
+
+ public function testInstantiated():void {
+ assertTrue("TestRunner instantiated with: " + instance, instance is TestRunner);
+ }
+
+ public function testAsync():void {
+ var handler:Function = addAsync(asyncCompleteHandler);
+ setTimeout(handler, 400, new Event(Event.ACTIVATE));
+ }
+
+ public function asyncCompleteHandler(event:Event):void {
+// throw new IllegalOperationError("what the heck?");
+ }
+
+ public function testAsync2():void {
+ var handler:Function = addAsync(async2CompleteHandler);
+ setTimeout(handler, 40);
+ }
+
+ public function async2CompleteHandler():void {
+// fail("test async complete failed");
+ }
+
+ public function testSomethingComplete():void {
+ }
+
+ public function testSomethingElse():void {
+ }
+
+ public function testAnotherThing():void {
+ }
+ }
+}
Added: trunk/framework-test/as3/asunit/textui/TestRunnerTestCaseMock.as
===================================================================
--- trunk/framework-test/as3/asunit/textui/TestRunnerTestCaseMock.as (rev 0)
+++ trunk/framework-test/as3/asunit/textui/TestRunnerTestCaseMock.as 2006-09-20 18:24:28 UTC (rev 105)
@@ -0,0 +1,30 @@
+package asunit.textui {
+
+ import asunit.framework.TestCase;
+
+ public class TestRunnerTestCaseMock extends TestCase {
+ public var testMethod1Run:Boolean;
+ public var testMethod2Run:Boolean;
+ public var testMethod3Run:Boolean;
+
+ public function TestRunnerTestCaseMock(methodName:String = null) {
+ super(methodName);
+ }
+
+ public function testMethod1():void {
+ testMethod1Run = true;
+ }
+
+ public function testMethod1Completed():void {
+ trace("testMethod1Handler called");
+ }
+
+ public function testMethod2():void {
+ testMethod2Run = true;
+ }
+
+ public function testMethod3():void {
+ testMethod3Run = true;
+ }
+ }
+}
\ No newline at end of file
Added: trunk/framework-test/as3/asunit/util/ArrayIteratorTest.as
===================================================================
--- trunk/framework-test/as3/asunit/util/ArrayIteratorTest.as (rev 0)
+++ trunk/framework-test/as3/asunit/util/ArrayIteratorTest.as 2006-09-20 18:24:28 UTC (rev 105)
@@ -0,0 +1,65 @@
+package asunit.util {
+ import asunit.framework.TestCase;
+
+ public class ArrayIteratorTest extends TestCase {
+ private var itr:ArrayIterator;
+
+ public function ArrayIteratorTest(testMethod:String = null) {
+ super(testMethod);
+ }
+
+ protected override function setUp():void {
+ itr = new ArrayIterator(getSimpleArray(5));
+ }
+
+ private function getSimpleArray(count:Number):Array {
+ var arr:Array = new Array();
+ for(var i:Number = 0; i < count; i++) {
+ arr.push("item-" + i);
+ }
+ return arr;
+ }
+
+ protected override function tearDown():void {
+ itr = null;
+ }
+
+ public function testInstantiated():void {
+ assertTrue("ArrayIterator instantiated", itr is ArrayIterator);
+ }
+
+ public function testHasNext():void {
+ assertTrue(itr.hasNext());
+ }
+
+ public function testNext():void {
+ assertEquals("item-0", itr.next());
+ }
+
+ public function testNextTwice():void {
+ assertEquals("item-0", itr.next());
+ assertEquals("item-1", itr.next());
+ }
+
+ public function testLast():void {
+ assertTrue(itr.hasNext());
+ assertEquals("item-0", itr.next());
+ assertTrue(itr.hasNext());
+ assertEquals("item-1", itr.next());
+ assertTrue(itr.hasNext());
+ assertEquals("item-2", itr.next());
+ assertTrue(itr.hasNext());
+ assertEquals("item-3", itr.next());
+ assertTrue(itr.hasNext());
+ assertEquals("item-4", itr.next());
+ assertFalse(itr.hasNext());
+ }
+
+ public function testReset():void {
+ testLast();
+ itr.reset();
+ assertTrue(itr.hasNext());
+ assertEquals("item-0", itr.next());
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|