Пример #1
0
  ClimateZone ClimateZones_Impl::setClimateZone(const std::string& institution,
                                                unsigned year, 
                                                const std::string& value) 
  {
    std::shared_ptr<ClimateZones_Impl> p;
    ClimateZone result(p,numFields());

    ClimateZone candidate = getClimateZone(institution,year);
    if (candidate.empty()) {
      return appendClimateZone(institution,
                               ClimateZones::getDefaultDocumentName(institution),
                               year,
                               value);
    }
    bool ok = candidate.setValue(value);
    if (ok) { result = candidate; }
    return result;
  }
Пример #2
0
TEST_F(ModelFixture, ClimateZones)
{
  // construct directly
  Model model;
  EXPECT_FALSE(model.getOptionalUniqueModelObject<ClimateZones>());
  ClimateZones czs = model.getUniqueModelObject<ClimateZones>();

  // default
  ASSERT_EQ(1u,czs.numClimateZones());
  ASSERT_EQ(1u,czs.climateZones().size());
  ClimateZone acz = czs.climateZones()[0];
  ASSERT_FALSE(acz.empty());
  EXPECT_EQ(ClimateZones::ashraeInstitutionName(),acz.institution());
  EXPECT_EQ(ClimateZones::ashraeDocumentName(),acz.documentName());
  EXPECT_EQ(ClimateZones::ashraeDefaultYear(),acz.year());
  EXPECT_EQ("",acz.value());

  // after clear
  czs.clear();
  EXPECT_EQ(0u,czs.numClimateZones());
  EXPECT_EQ(0,czs.climateZones().size());
  EXPECT_TRUE(acz.empty());

  // append a climate zone
  ClimateZone cz = czs.appendClimateZone(ClimateZones::cecInstitutionName(),
                                         ClimateZones::validClimateZoneValues(
                                             ClimateZones::cecInstitutionName(),
                                             ClimateZones::cecDefaultYear())[0]);
  ASSERT_FALSE(cz.empty());
  EXPECT_EQ(ClimateZones::cecInstitutionName(),cz.institution());
  EXPECT_EQ(ClimateZones::cecDocumentName(),cz.documentName());
  EXPECT_EQ(ClimateZones::cecDefaultYear(),cz.year());
  EXPECT_EQ("1",cz.value());
}