add test for calling changeState with same name twice
This commit is contained in:
parent
7bd1b3cc82
commit
4995b16c43
|
|
@ -270,8 +270,6 @@ class EntityStateTests: XCTestCase {
|
|||
XCTAssertTrue(state.has(MockComponent.self))
|
||||
}
|
||||
|
||||
// TODO: continue here
|
||||
|
||||
class MockComponent: ComponentInitializable {
|
||||
let value: Int
|
||||
|
||||
|
|
@ -401,6 +399,21 @@ class EntityStateMachineTests: XCTestCase {
|
|||
XCTAssertNil(entity.get(component: MockComponent.self))
|
||||
}
|
||||
|
||||
func testCallChangeStateWithSameNameLeavesEntityComponentsIntact() {
|
||||
let state = fsm.createState(name: "test")
|
||||
let component1 = MockComponent()
|
||||
let component2 = MockComponent2()
|
||||
state.add(MockComponent.self).withInstance(component1)
|
||||
state.add(MockComponent2.self).withInstance(component2)
|
||||
let name = "test"
|
||||
fsm.changeState(name: name)
|
||||
XCTAssertTrue(entity.get(component: MockComponent.self) === component1)
|
||||
XCTAssertTrue(entity.get(component: MockComponent2.self) === component2)
|
||||
fsm.changeState(name: name)
|
||||
XCTAssertTrue(entity.get(component: MockComponent.self) === component1)
|
||||
XCTAssertTrue(entity.get(component: MockComponent2.self) === component2)
|
||||
}
|
||||
|
||||
class MockComponent: ComponentInitializable {
|
||||
let value: Int
|
||||
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ extension EntityStateMachineTests {
|
|||
// `swift test --generate-linuxmain`
|
||||
// to regenerate.
|
||||
static let __allTests__EntityStateMachineTests = [
|
||||
("testCallChangeStateWithSameNameLeavesEntityComponentsIntact", testCallChangeStateWithSameNameLeavesEntityComponentsIntact),
|
||||
("testCreateStateAddsState", testCreateStateAddsState),
|
||||
("testCreateStateDoesNotChangeState", testCreateStateDoesNotChangeState),
|
||||
("testEnterSecondStateAddsSecondStatesComponents", testEnterSecondStateAddsSecondStatesComponents),
|
||||
|
|
|
|||
Loading…
Reference in New Issue