1 #include <gtest/gtest.h> 5 #include "institution_tests.h" 6 #include "agent_tests.h" 13 using cyclus::QueryResult;
15 TEST(DeployInstTests, ProtoNames) {
17 "<prototypes> <val>foobar</val> </prototypes>" 18 "<build_times> <val>1</val> </build_times>" 19 "<n_build> <val>3</val> </n_build>" 20 "<lifetimes> <val>2</val> </lifetimes>" 24 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:DeployInst"), config, simdur);
25 sim.DummyProto(
"foobar");
28 cyclus::SqlStatement::Ptr stmt = sim.db().db().Prepare(
29 "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar';" 32 EXPECT_EQ(3, stmt->GetInt(0));
35 TEST(DeployInstTests, BuildTimes) {
37 "<prototypes> <val>foobar</val> <val>foobar</val> </prototypes>" 38 "<build_times> <val>1</val> <val>3</val> </build_times>" 39 "<n_build> <val>1</val> <val>7</val> </n_build>" 43 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:DeployInst"), config, simdur);
44 sim.DummyProto(
"foobar");
47 cyclus::SqlStatement::Ptr stmt = sim.db().db().Prepare(
48 "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar' AND EnterTime = 1;" 51 EXPECT_EQ(1, stmt->GetInt(0));
53 stmt = sim.db().db().Prepare(
54 "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar' AND EnterTime = 3;" 57 EXPECT_EQ(7, stmt->GetInt(0));
62 TEST(DeployInstTests, FiniteLifetimes) {
64 "<prototypes> <val>foobar</val> <val>foobar</val> <val>foobar</val> </prototypes>" 65 "<build_times> <val>1</val> <val>1</val> <val>2</val> </build_times>" 66 "<n_build> <val>1</val> <val>7</val> <val>3</val> </n_build>" 67 "<lifetimes> <val>1</val> <val>2</val> <val>-1</val> </lifetimes>" 71 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:DeployInst"), config, simdur);
72 sim.DummyProto(
"foobar");
76 cyclus::SqlStatement::Ptr stmt = sim.db().db().Prepare(
77 "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar' AND EnterTime = 1 AND Lifetime = 1;" 80 EXPECT_EQ(1, stmt->GetInt(0));
82 stmt = sim.db().db().Prepare(
83 "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar' AND EnterTime = 1 AND Lifetime = 2;" 86 EXPECT_EQ(7, stmt->GetInt(0));
88 stmt = sim.db().db().Prepare(
89 "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar' AND EnterTime = 2 AND Lifetime = -1;" 92 EXPECT_EQ(3, stmt->GetInt(0));
95 stmt = sim.db().db().Prepare(
96 "SELECT COUNT(*) FROM AgentEntry As e JOIN AgentExit AS x ON x.AgentId = e.AgentId WHERE e.Prototype = 'foobar' AND x.ExitTime = 1;" 99 EXPECT_EQ(1, stmt->GetInt(0));
101 stmt = sim.db().db().Prepare(
102 "SELECT COUNT(*) FROM AgentEntry As e JOIN AgentExit AS x ON x.AgentId = e.AgentId WHERE e.Prototype = 'foobar' AND x.ExitTime = 2;" 105 EXPECT_EQ(7, stmt->GetInt(0));
108 stmt = sim.db().db().Prepare(
109 "SELECT COUNT(*) FROM AgentExit;" 112 EXPECT_EQ(8, stmt->GetInt(0));
115 TEST(DeployInstTests, NoDupProtos) {
117 "<prototypes> <val>foobar</val> <val>foobar</val> <val>foobar</val> </prototypes>" 118 "<build_times> <val>1</val> <val>1</val> <val>2</val> </build_times>" 119 "<n_build> <val>1</val> <val>7</val> <val>3</val> </n_build>" 120 "<lifetimes> <val>1</val> <val>1</val> <val>-1</val> </lifetimes>" 124 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:DeployInst"), config, simdur);
125 sim.DummyProto(
"foobar");
129 cyclus::SqlStatement::Ptr stmt = sim.db().db().Prepare(
130 "SELECT COUNT(*) FROM Prototypes WHERE Prototype = 'foobar_life_1';" 133 EXPECT_EQ(1, stmt->GetInt(0));
137 stmt = sim.db().db().Prepare(
138 "SELECT COUNT(*) FROM Prototypes WHERE Prototype = 'foobar';" 141 EXPECT_EQ(1, stmt->GetInt(0));
144 TEST(DeployInstTests, PositionInitialize) {
146 "<prototypes> <val>foobar</val> </prototypes>" 147 "<build_times> <val>1</val> </build_times>" 148 "<n_build> <val>3</val> </n_build>" 149 "<lifetimes> <val>2</val> </lifetimes>";
152 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:DeployInst"), config, simdur);
153 sim.DummyProto(
"foobar");
156 QueryResult qr = sim.db().Query(
"AgentPosition", NULL);
157 EXPECT_EQ(qr.GetVal<
double>(
"Latitude"), 0.0);
158 EXPECT_EQ(qr.GetVal<
double>(
"Longitude"), 0.0);
161 TEST(DeployInstTests, PositionInitialize2) {
163 "<prototypes> <val>foobar</val> </prototypes>" 164 "<longitude> -20.0 </longitude>" 165 "<latitude> 2.0 </latitude>" 166 "<build_times> <val>1</val> </build_times>" 167 "<n_build> <val>3</val> </n_build>" 168 "<lifetimes> <val>2</val> </lifetimes>";
171 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:DeployInst"), config, simdur);
172 sim.DummyProto(
"foobar");
175 QueryResult qr = sim.db().Query(
"AgentPosition", NULL);
176 EXPECT_EQ(qr.GetVal<
double>(
"Latitude"), 2.0);
177 EXPECT_EQ(qr.GetVal<
double>(
"Longitude"), -20.0);
185 #ifndef CYCLUS_AGENT_TESTS_CONNECTED 188 #define CYCLUS_AGENT_TESTS_CONNECTED cyclus_agent_tests_connected 189 #endif // CYCLUS_AGENT_TESTS_CONNECTED
cyclus::Agent * DeployInstitutionConstructor(cyclus::Context *ctx)
static int cyclus_agent_tests_connected
cycamore::GrowthRegion string
INSTANTIATE_TEST_CASE_P(DeployInst, InstitutionTests, Values(&DeployInstitutionConstructor))
TEST(DeployInstTests, ProtoNames)