Differential D4388 Diff 19317 ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Researcher.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Researcher.js
Show All 34 Lines | |||||
AddMock(entityID, IID_Ownership, { | AddMock(entityID, IID_Ownership, { | ||||
"GetOwner": () => playerID | "GetOwner": () => playerID | ||||
}); | }); | ||||
AddMock(entityID, IID_Identity, { | AddMock(entityID, IID_Identity, { | ||||
"GetCiv": () => "iber" | "GetCiv": () => "iber" | ||||
}); | }); | ||||
const cmpResearcher = ConstructComponent(entityID, "Researcher", { | let cmpResearcher = ConstructComponent(entityID, "Researcher", { | ||||
"Technologies": { "_string": "gather_fishing_net " + | "Technologies": { "_string": "gather_fishing_net " + | ||||
"phase_town_{civ} " + | "phase_town_{civ} " + | ||||
"phase_city_{civ}" } | "phase_city_{civ}" } | ||||
}); | }); | ||||
TS_ASSERT_UNEVAL_EQUALS( | TS_ASSERT_UNEVAL_EQUALS( | ||||
cmpResearcher.GetTechnologiesList(), | cmpResearcher.GetTechnologiesList(), | ||||
["gather_fishing_net", "phase_town_generic", "phase_city_generic"] | ["gather_fishing_net", "phase_town_generic", "phase_city_generic"] | ||||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | |||||
// Test finishing a queued tech. | // Test finishing a queued tech. | ||||
id = cmpResearcher.QueueTechnology(queuedTech); | id = cmpResearcher.QueueTechnology(queuedTech); | ||||
TS_ASSERT_EQUALS(cmpResearcher.GetResearchingTechnology(id).progress, 0); | TS_ASSERT_EQUALS(cmpResearcher.GetResearchingTechnology(id).progress, 0); | ||||
TS_ASSERT_EQUALS(cmpResearcher.Progress(id, 500), 500); | TS_ASSERT_EQUALS(cmpResearcher.Progress(id, 500), 500); | ||||
TS_ASSERT_EQUALS(cmpResearcher.GetResearchingTechnology(id).progress, 0.5); | TS_ASSERT_EQUALS(cmpResearcher.GetResearchingTechnology(id).progress, 0.5); | ||||
cmpResearcher = SerializationCycle(cmpResearcher); | |||||
spyTechManager = new Spy(techManager, "ResearchTechnology"); | spyTechManager = new Spy(techManager, "ResearchTechnology"); | ||||
TS_ASSERT_EQUALS(cmpResearcher.Progress(id, 1000), 500); | TS_ASSERT_EQUALS(cmpResearcher.Progress(id, 1000), 500); | ||||
TS_ASSERT_EQUALS(spyTechManager._called, 1); | TS_ASSERT_EQUALS(spyTechManager._called, 1); | ||||
TS_ASSERT_EQUALS(cmpResearcher.queue.size, 0); | TS_ASSERT_EQUALS(cmpResearcher.queue.size, 0); | ||||
// Test that we can affect an empty researcher. | // Test that we can affect an empty researcher. | ||||
Engine.RegisterGlobal("ApplyValueModificationsToEntity", (_, value) => value + "some_test"); | Engine.RegisterGlobal("ApplyValueModificationsToEntity", (_, value) => value + "some_test"); | ||||
TS_ASSERT_UNEVAL_EQUALS( | TS_ASSERT_UNEVAL_EQUALS( | ||||
ConstructComponent(entityID, "Researcher", null).GetTechnologiesList(), | ConstructComponent(entityID, "Researcher", null).GetTechnologiesList(), | ||||
["some_test"] | ["some_test"] | ||||
); | ); |
Wildfire Games · Phabricator