@@ -39,6 +39,7 @@ void StorageTest::SetUpStorage(){
3939  src_facility_->out_commods  = out_c1;
4040  src_facility_->residence_time  = residence_time;
4141  src_facility_->max_inv_size  = max_inv_size;
42+   src_facility_->inventory_tracker .set_capacity (max_inv_size);
4243  src_facility_->throughput  = throughput;
4344  src_facility_->discrete_handling  = discrete_handling;
4445}
@@ -457,6 +458,7 @@ TEST_F(StorageTest, MultipleCommods){
457458  EXPECT_EQ (1 , n_trans2) << " expected 1 transactions, got "   << n_trans;
458459}
459460
461+ 
460462//  Should get one transaction in a 2 step simulation when agent is active for
461463//  one step and dormant for one step
462464TEST_F (StorageTest, ActiveDormant){
@@ -624,7 +626,7 @@ TEST_F(StorageTest, NormalActiveDormantBuyingSize){
624626    "    <buying_size_mean>0.5</buying_size_mean>" 
625627    "    <buying_size_stddev>0.1</buying_size_stddev>"  ;
626628
627-      int  simdur = 15 ;
629+   int  simdur = 15 ;
628630
629631  cyclus::MockSim sim (cyclus::AgentSpec  (" :cycamore:Storage"  ), config, simdur);
630632
@@ -702,7 +704,6 @@ TEST_F(StorageTest, IncorrectBuyPolSetupMinMax) {
702704  cyclus::MockSim sim (cyclus::AgentSpec  (" :cycamore:Storage"  ), 
703705                                         config_uniform_min_bigger_max, simdur);
704706  EXPECT_THROW (sim.Run (), cyclus::ValueError);
705- 
706707}
707708
708709TEST_F (StorageTest, PositionInitialize){
@@ -753,6 +754,86 @@ TEST_F(StorageTest, Longitude){
753754  EXPECT_EQ (qr.GetVal <double >(" Longitude"  ), 35.0 );
754755}
755756
757+ TEST_F (StorageTest, RQ_Inventory_Invalid) {
758+   std::string config =
759+     "    <in_commods> <val>spent_fuel</val> </in_commods> " 
760+     "    <out_commods> <val>dry_spent</val> </out_commods> " 
761+     "    <max_inv_size>5</max_inv_size>" 
762+     "    <reorder_point>2</reorder_point>" 
763+     "    <reorder_quantity>10</reorder_quantity>"  ;
764+ 
765+   int  simdur = 2 ;
766+  
767+   cyclus::MockSim sim (cyclus::AgentSpec (" :cycamore:Storage"  ), config, simdur);
768+ 
769+   EXPECT_THROW (int  id = sim.Run (), cyclus::ValueError);
770+ }
771+ 
772+ TEST_F (StorageTest, RQ_Inventory) {
773+   std::string config =
774+     "    <in_commods> <val>spent_fuel</val> </in_commods> " 
775+     "    <out_commods> <val>dry_spent</val> </out_commods> " 
776+     "    <max_inv_size>5</max_inv_size>" 
777+     "    <reorder_point>2</reorder_point>" 
778+     "    <reorder_quantity>3</reorder_quantity>"  ;
779+ 
780+   int  simdur = 5 ;
781+ 
782+   cyclus::MockSim sim (cyclus::AgentSpec  (" :cycamore:Storage"  ), config, simdur);
783+ 
784+   sim.AddSource (" spent_fuel"  ).capacity (5 ).Finalize ();
785+   sim.AddSink (" dry_spent"  ).Finalize ();
786+ 
787+   int  id = sim.Run ();
788+ 
789+   std::vector<cyclus::Cond> conds;
790+   conds.push_back (cyclus::Cond (" Commodity"  , " =="  , std::string (" spent_fuel"  )));
791+   cyclus::QueryResult qr = sim.db ().Query (" Transactions"  , &conds);
792+   int  n_trans = qr.rows .size ();
793+ 
794+   EXPECT_EQ (3 , n_trans) << " expected 3 transactions, got "   << n_trans;
795+   //  check that the transactions occur at the expected time (0, 2, 4)
796+   EXPECT_EQ (0 , qr.GetVal <int >(" Time"  , 0 ));
797+   EXPECT_EQ (2 , qr.GetVal <int >(" Time"  , 1 ));
798+   EXPECT_EQ (4 , qr.GetVal <int >(" Time"  , 2 ));
799+ 
800+   //  check that all transactions are of size 3
801+   qr = sim.db ().Query (" Resources"  , NULL );
802+   EXPECT_EQ (3 , qr.GetVal <double >(" Quantity"  , 0 ));
803+ }
804+ 
805+ TEST_F (StorageTest, sS_Inventory ) {
806+   std::string config =
807+     "    <in_commods> <val>spent_fuel</val> </in_commods> " 
808+     "    <out_commods> <val>dry_spent</val> </out_commods> " 
809+     "    <max_inv_size>5</max_inv_size>" 
810+     "    <reorder_point>2</reorder_point>"  ;
811+ 
812+   int  simdur = 5 ;
813+ 
814+   cyclus::MockSim sim (cyclus::AgentSpec  (" :cycamore:Storage"  ), config, simdur);
815+ 
816+   sim.AddSource (" spent_fuel"  ).capacity (5 ).Finalize ();
817+   sim.AddSink (" dry_spent"  ).Finalize ();
818+ 
819+   int  id = sim.Run ();
820+ 
821+   std::vector<cyclus::Cond> conds;
822+   conds.push_back (cyclus::Cond (" Commodity"  , " =="  , std::string (" spent_fuel"  )));
823+   cyclus::QueryResult qr = sim.db ().Query (" Transactions"  , &conds);
824+   int  n_trans = qr.rows .size ();
825+   EXPECT_EQ (3 , n_trans) << " expected 3 transactions, got "   << n_trans;
826+   //  check that the transactions occur at the expected time (0, 2, 4)
827+   EXPECT_EQ (0 , qr.GetVal <int >(" Time"  , 0 ));
828+   EXPECT_EQ (2 , qr.GetVal <int >(" Time"  , 1 ));
829+   EXPECT_EQ (4 , qr.GetVal <int >(" Time"  , 2 ));
830+ 
831+   //  check that all transactions are of size 5
832+   qr = sim.db ().Query (" Resources"  , NULL );
833+   EXPECT_EQ (5 , qr.GetVal <double >(" Quantity"  , 0 ));
834+ }
835+ 
836+ 
756837} //  namespace cycamore
757838
758839//  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
0 commit comments