-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:lpmaurice/Ember
- Loading branch information
Showing
12 changed files
with
197 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,7 @@ bin-release/* | |
# OS X | ||
Icon | ||
Thumbs.db | ||
.DS_Store | ||
.DS_Store | ||
|
||
#uncompiled libraries | ||
libs-src/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package | ||
{ | ||
import asunit.framework.TestSuite; | ||
|
||
import com.tomseysdavies.ember.base.EntityManagerTest; | ||
|
||
public class AllTests extends TestSuite | ||
{ | ||
public function AllTests() | ||
{ | ||
super(); | ||
addTest(new EntityManagerTest()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package { | ||
import asunit.textui.TestRunner; | ||
|
||
public class EmberTestRunner extends TestRunner { | ||
|
||
public function EmberTestRunner() { | ||
start(AllTests); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.tomseysdavies.ember.base | ||
{ | ||
public class ComponentA | ||
{ | ||
public var x:int; | ||
public var y:int; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.tomseysdavies.ember.base | ||
{ | ||
public class ComponentB | ||
{ | ||
public var health:int; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package com.tomseysdavies.ember.base | ||
{ | ||
import asunit.framework.TestCase; | ||
|
||
import com.tomseysdavies.ember.core.IEntity; | ||
import com.tomseysdavies.ember.core.IFamily; | ||
|
||
public class EntityManagerTest extends TestCase | ||
{ | ||
public function EntityManagerTest() | ||
{ | ||
super(); | ||
} | ||
|
||
override protected function setUp():void | ||
{ | ||
_entityManager = new EntityManager(); | ||
} | ||
|
||
override protected function tearDown():void | ||
{ | ||
_entityManager.dispose(); | ||
_entityManager = null; | ||
} | ||
|
||
public function testVerifyExistenceOf():void | ||
{ | ||
_entityManager.createEntity(SOME_ID); | ||
assertTrue("Entity was proven to exist.", _entityManager.verifyExistenceOf(SOME_ID)); | ||
} | ||
|
||
public function testVerifyExistenceOfFailure():void | ||
{ | ||
_entityManager.createEntity(SOME_ID); | ||
assertFalse("Entity was not proven to exist.", _entityManager.verifyExistenceOf("FAIL")); | ||
} | ||
|
||
public function testEntityWithoutIDCreated():void | ||
{ | ||
var entity:IEntity = _entityManager.createEntity(); | ||
assertNotNull("Entity was created WITHOUT an id specified.", entity); | ||
} | ||
|
||
public function testEntityWithIDCreated():void | ||
{ | ||
var entity:IEntity = _entityManager.createEntity("SOME_ID"); | ||
assertNotNull("Entity was created WITH an id specified.", entity); | ||
} | ||
|
||
public function testDuplicateIDDoesNotCreateEntity():void | ||
{ | ||
_entityManager.createEntity(SOME_ID); | ||
assertNull("Entity with duplicate ID won't be created.", _entityManager.createEntity(SOME_ID)); | ||
} | ||
|
||
public function testEntityIsDeleted():void | ||
{ | ||
_entityManager.createEntity(SOME_ID); | ||
_entityManager.removeEntity(SOME_ID); | ||
assertFalse("Entity was removed.", _entityManager.verifyExistenceOf(SOME_ID)); | ||
} | ||
|
||
public function testComponentAdded():void | ||
{ | ||
var result:Boolean; | ||
_entityManager.createEntity(SOME_ID); | ||
result = _entityManager.addComponent(SOME_ID, new ComponentA()); | ||
assertTrue("Component was added.", result); | ||
} | ||
|
||
public function testComponentNotAddedIfNoEntity():void | ||
{ | ||
var result:Boolean = _entityManager.addComponent("FAIL", new ComponentA()); | ||
assertFalse("Component was not added.", result); | ||
} | ||
|
||
public function testComponentFound():void | ||
{ | ||
var result:ComponentA; | ||
_entityManager.createEntity(SOME_ID); | ||
_entityManager.addComponent(SOME_ID, new ComponentA()); | ||
result = _entityManager.getComponent(SOME_ID, ComponentA); | ||
assertNotNull("Component was found.", result); | ||
} | ||
|
||
public function testComponentRemoved():void | ||
{ | ||
var result:ComponentA; | ||
_entityManager.createEntity(SOME_ID); | ||
_entityManager.addComponent(SOME_ID, new ComponentA()); | ||
_entityManager.removeComponent(SOME_ID, ComponentA); | ||
result = _entityManager.getComponent(SOME_ID, ComponentA); | ||
assertNull("Component was removed.", result); | ||
} | ||
|
||
public function testFamilyCreatedWithOneComponent():void | ||
{ | ||
var result:IFamily = _entityManager.getEntityFamily(ComponentA); | ||
assertTrue("Family was retrieved.", result is IFamily); | ||
} | ||
|
||
public function testFamilyCreatedWithManyComponents():void | ||
{ | ||
var result:IFamily = _entityManager.getEntityFamily(ComponentA, ComponentB); | ||
assertTrue("Family was retrieved.", result is IFamily); | ||
} | ||
|
||
//_________________PRIVATE | ||
private static const SOME_ID:String = "SOME_ID"; | ||
private var _entityManager:EntityManager; | ||
} | ||
} |