CYCAMORE
src/manager_inst_tests.cc
Go to the documentation of this file.
1 #include "manager_inst_tests.h"
2 
3 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4 TestProducer::TestProducer(cyclus::Context* ctx) : cyclus::Facility(ctx) {}
5 
6 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
8 
9 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
11  ctx_ = new cyclus::Context(&ti_, &rec_);
12  src_inst = new cycamore::ManagerInst(ctx_);
13  producer = new TestProducer(ctx_);
14  commodity = cyclus::toolkit::Commodity("commod");
15  capacity = 5;
16  producer->cyclus::toolkit::CommodityProducer::Add(commodity);
17  producer->SetCapacity(commodity, capacity);
18 }
19 
20 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
22  delete producer;
23  delete src_inst;
24  delete ctx_;
25 }
26 
27 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
28 cyclus::Agent* ManagerInstitutionConstructor(cyclus::Context* ctx) {
29  return new cycamore::ManagerInst(ctx);
30 }
31 
32 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
33 TEST_F(ManagerInstTests, producerexists) {
34  using std::set;
35  ctx_->AddPrototype("foop", producer);
36  set<cyclus::toolkit::CommodityProducer*>::iterator it;
37  for (it = src_inst->cyclus::toolkit::CommodityProducerManager:: producers().begin();
38  it != src_inst->cyclus::toolkit::CommodityProducerManager:: producers().end();
39  it++) {
40  EXPECT_EQ(dynamic_cast<TestProducer*>(*it)->prototype(),
41  producer->prototype());
42  }
43 }
44 
45 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
46 TEST_F(ManagerInstTests, productioncapacity) {
47  EXPECT_EQ(src_inst->TotalCapacity(commodity), 0);
48  src_inst->BuildNotify(producer);
49  EXPECT_EQ(src_inst->TotalCapacity(commodity), capacity);
50  src_inst->DecomNotify(producer);
51  EXPECT_EQ(src_inst->TotalCapacity(commodity), 0);
52 }
53 
54 // required to get functionality in cyclus agent unit tests library
55 #ifndef CYCLUS_AGENT_TESTS_CONNECTED
56 int ConnectAgentTests();
58 #define CYCLUS_AGENT_TESTS_CONNECTED cyclus_agent_tests_connected
59 #endif // CYCLUS_AGENT_TESTS_CONNECTED
60 
61 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
62 INSTANTIATE_TEST_CASE_P(ManagerInst, InstitutionTests,
64 INSTANTIATE_TEST_CASE_P(ManagerInst, AgentTests,
66 
cyclus::Agent * ManagerInstitutionConstructor(cyclus::Context *ctx)
TestProducer(cyclus::Context *ctx)
INSTANTIATE_TEST_CASE_P(ManagerInst, InstitutionTests, Values(&ManagerInstitutionConstructor))
static int cyclus_agent_tests_connected
TEST_F(ManagerInstTests, producerexists)
int ConnectAgentTests()