add tests for EntityStateMachine.createState
This commit is contained in:
parent
3e30812c99
commit
7bd1b3cc82
|
|
@ -386,6 +386,21 @@ class EntityStateMachineTests: XCTestCase {
|
|||
XCTAssertTrue(entity.get(component: MockComponent.self) === component3)
|
||||
}
|
||||
|
||||
func testCreateStateAddsState() {
|
||||
let state = fsm.createState(name: "test")
|
||||
let component = MockComponent()
|
||||
state.add(MockComponent.self).withInstance(component)
|
||||
fsm.changeState(name: "test")
|
||||
XCTAssertTrue(entity.get(component: MockComponent.self) === component)
|
||||
}
|
||||
|
||||
func testCreateStateDoesNotChangeState() {
|
||||
let state = fsm.createState(name: "test")
|
||||
let component = MockComponent()
|
||||
state.add(MockComponent.self).withInstance(component)
|
||||
XCTAssertNil(entity.get(component: MockComponent.self))
|
||||
}
|
||||
|
||||
class MockComponent: ComponentInitializable {
|
||||
let value: Int
|
||||
|
||||
|
|
@ -411,6 +426,8 @@ class EntityStateMachineTests: XCTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
|
||||
class StateComponentMappingTests: XCTestCase {
|
||||
func testAddReturnsSameMappingForSameComponentType() {
|
||||
let state = EntityState()
|
||||
|
|
|
|||
|
|
@ -96,6 +96,8 @@ extension EntityStateMachineTests {
|
|||
// `swift test --generate-linuxmain`
|
||||
// to regenerate.
|
||||
static let __allTests__EntityStateMachineTests = [
|
||||
("testCreateStateAddsState", testCreateStateAddsState),
|
||||
("testCreateStateDoesNotChangeState", testCreateStateDoesNotChangeState),
|
||||
("testEnterSecondStateAddsSecondStatesComponents", testEnterSecondStateAddsSecondStatesComponents),
|
||||
("testEnterSecondStateDoesNotRemoveOverlappingComponents", testEnterSecondStateDoesNotRemoveOverlappingComponents),
|
||||
("testEnterSecondStateRemovesDifferentComponentsOfSameType", testEnterSecondStateRemovesDifferentComponentsOfSameType),
|
||||
|
|
|
|||
Loading…
Reference in New Issue