43 cyclus::Context* ctx = tc.get();
45 (src_facility->Clone());
47 EXPECT_EQ(outcommod(src_facility), outcommod(cloned_fac));
48 EXPECT_EQ(throughput(src_facility), throughput(cloned_fac));
49 EXPECT_EQ(outrecipe(src_facility), outrecipe(cloned_fac));
60 using cyclus::BidPortfolio;
61 using cyclus::CapacityConstraint;
62 using cyclus::ExchangeContext;
63 using cyclus::Material;
67 boost::shared_ptr< ExchangeContext<Material> >
68 ec = GetContext(nreqs, commod);
70 src_facility->EnterNotify();
72 std::set<BidPortfolio<Material>::Ptr> ports =
73 src_facility->GetMatlBids(ec.get()->commod_requests);
75 ASSERT_TRUE(ports.size() > 0);
76 EXPECT_EQ(ports.size(), 1);
78 BidPortfolio<Material>::Ptr port = *ports.begin();
79 EXPECT_EQ(port->bidder(), src_facility);
80 EXPECT_EQ(port->bids().size(), nreqs);
82 const std::set< CapacityConstraint<Material> >& constrs = port->constraints();
83 ASSERT_TRUE(constrs.size() > 0);
84 EXPECT_EQ(constrs.size(), 1);
85 EXPECT_EQ(*constrs.begin(), CapacityConstraint<Material>(capacity));
90 using cyclus::Material;
91 using cyclus::Request;
93 using test_helpers::get_mat;
95 std::vector< Trade<Material> > trades;
96 std::vector<std::pair<Trade<Material>,
97 Material::Ptr> > responses;
100 EXPECT_NO_THROW(src_facility->GetMatlTrades(trades, responses));
101 EXPECT_EQ(responses.size(), 0);
103 double qty = capacity / 3;
104 Request<Material>* request =
105 Request<Material>::Create(get_mat(), trader, commod);
107 Bid<Material>::Create(request, get_mat(), src_facility);
109 Trade<Material> trade(request, bid, qty);
110 trades.push_back(trade);
113 src_facility->GetMatlTrades(trades, responses);
114 EXPECT_EQ(responses.size(), 1);
115 EXPECT_EQ(responses[0].second->quantity(), qty);
116 EXPECT_EQ(responses[0].second->comp(), recipe);
119 trades.push_back(trade);
121 EXPECT_NO_THROW(src_facility->GetMatlTrades(trades, responses));
122 EXPECT_EQ(responses.size(), 2);
125 src_facility->Tick();
162 using cyclus::QueryResult;
166 "<outcommod>commod</outcommod>"
167 "<outrecipe>recipe</outrecipe>"
168 "<package>testpackage</package>"
169 "<throughput>5</throughput>";
172 cyclus::MockSim sim(cyclus::AgentSpec (
":cycamore:Source"), config, simdur);
174 sim.context()->AddRecipe(recipe_name, recipe);
175 sim.context()->AddPackage(package_name, 3, 4,
"first");
176 package = sim.context()->GetPackage(package_name);
178 sim.AddSink(
"commod").Finalize();
180 EXPECT_NO_THROW(sim.Run());
182 QueryResult qr_tr = sim.db().Query(
"Transactions", NULL);
183 EXPECT_EQ(qr_tr.rows.size(), 3);
185 std::vector<Cond> conds;
186 conds.push_back(Cond(
"PackageName",
"==", package->name()));
187 QueryResult qr_res = sim.db().Query(
"Resources", &conds);
189 EXPECT_EQ(qr_res.rows.size(), 3);
193 using cyclus::QueryResult;
197 "<outcommod>commod</outcommod>"
198 "<outrecipe>recipe</outrecipe>"
199 "<package>testpackage</package>"
200 "<transport_unit>testtu</transport_unit>"
201 "<throughput>10</throughput>";
204 cyclus::MockSim sim(cyclus::AgentSpec (
":cycamore:Source"), config, simdur);
206 sim.context()->AddRecipe(recipe_name, recipe);
207 sim.context()->AddPackage(package_name, 3, 4,
"equal");
208 package = sim.context()->GetPackage(package_name);
209 sim.context()->AddTransportUnit(tu_name, 2, 2);
210 tu = sim.context()->GetTransportUnit(tu_name);
212 sim.AddSink(
"commod").Finalize();
214 EXPECT_NO_THROW(sim.Run());
216 QueryResult qr_tr = sim.db().Query(
"Transactions", NULL);
217 EXPECT_EQ(qr_tr.rows.size(), 4);
219 std::vector<Cond> conds;
220 conds.push_back(Cond(
"PackageName",
"==", package->name()));
221 QueryResult qr_res = sim.db().Query(
"Resources", &conds);
223 EXPECT_EQ(qr_res.rows.size(), 4);
225 QueryResult qr_allres = sim.db().Query(
"Resources", NULL);