-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Timothy Hahn
committed
Feb 20, 2014
1 parent
7828f61
commit d83ce80
Showing
5 changed files
with
83 additions
and
4 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
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,58 @@ | ||
package crane | ||
|
||
import org.scalatest.FlatSpec | ||
import org.scalamock.scalatest.MockFactory | ||
|
||
class EntitySpec extends FlatSpec with MockFactory { | ||
"an entity" should "have a tag" in { | ||
var entity = Entity() | ||
assert(entity.tag == "") | ||
entity = new Entity("tag") | ||
assert(entity.tag == "tag") | ||
} | ||
|
||
it should "have components" in { | ||
val entity = Entity() | ||
val component = mock[Component] | ||
entity.components += component | ||
assert(entity.components.length == 1) | ||
|
||
assert(entity.getComponent(component.getClass) match { | ||
case Some(s) => true | ||
case _ => false | ||
}) | ||
|
||
assert(entity.getComponent(classOf[Component]) match { | ||
case Some(s) => false | ||
case _ => true | ||
}) | ||
} | ||
|
||
it should "die when killed" in { | ||
val entity = Entity() | ||
val component = mock[Component] | ||
entity.components += component | ||
assert(entity.alive == true) | ||
assert(entity.components.length == 1) | ||
|
||
entity.kill() | ||
assert(entity.alive == false) | ||
assert(entity.components.length == 0) | ||
} | ||
|
||
it should "throw a DeadEntityException when it is dead" in { | ||
import crane.exceptions.DeadEntityException | ||
val entity = Entity() | ||
|
||
entity.kill() | ||
|
||
intercept[DeadEntityException] { | ||
entity.kill() | ||
} | ||
|
||
intercept[DeadEntityException] { | ||
entity.removeComponent(classOf[Component]) | ||
} | ||
} | ||
} | ||
|
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 crane | ||
|
||
import org.scalatest.FlatSpec | ||
|
||
class SystemSpec extends FlatSpec { | ||
"a world" should "hi" in { | ||
assert(0 == 0) | ||
} | ||
} | ||
|
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 crane | ||
|
||
import org.scalatest.FlatSpec | ||
|
||
class WorldSpec extends FlatSpec { | ||
"a world" should "hi" in { | ||
assert(0 == 0) | ||
} | ||
} | ||
|
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