TEST_F(IddFixture,IddFactory_IddFile)
{
    IddFile file = IddFactory::instance().getIddFile(IddFileType::OpenStudio);
    EXPECT_TRUE(file.getObject("OS:Building"));
    EXPECT_TRUE(file.getObject(IddObjectType::CommentOnly));
    EXPECT_TRUE(file.getObject(IddObjectType::OS_ClimateZones));
    // print out for visual inspection
    path outPath = resourcesPath()/toPath("utilities/RoundTrip_OpenStudio.idd");
    file.save(outPath,true);
    // check against getIddObjects
    IddObjectVector objects = IddFactory::instance().getObjects(IddFileType::OpenStudio);
    EXPECT_TRUE(file.objects().size() == objects.size());
    // required objects
    EXPECT_TRUE(file.requiredObjects().size() > 0);
    EXPECT_TRUE(file.requiredObjects().size() ==
                IddFactory::instance().getRequiredObjects(IddFileType::OpenStudio).size());
    EXPECT_TRUE(file.requiredObjects().size() <= IddFactory::instance().requiredObjects().size());
    // unique objects
    EXPECT_TRUE(file.uniqueObjects().size() > 0);
    EXPECT_TRUE(file.uniqueObjects().size() ==
                IddFactory::instance().getUniqueObjects(IddFileType::OpenStudio).size());
    EXPECT_TRUE(file.uniqueObjects().size() <= IddFactory::instance().uniqueObjects().size());

    file = IddFactory::instance().getIddFile(IddFileType::EnergyPlus);
    EXPECT_TRUE(file.getObject("Building"));
    EXPECT_TRUE(file.getObject(IddObjectType::CommentOnly));
    EXPECT_FALSE(file.getObject(IddObjectType::OS_ClimateZones));
    // print out for visual inspection
    outPath = resourcesPath()/toPath("energyplus/RoundTrip_ProposedEnergy+.idd");
    file.save(outPath,true);
    // check against getIddObjects
    objects = IddFactory::instance().getObjects(IddFileType::EnergyPlus);
    EXPECT_TRUE(file.objects().size() == objects.size());
}
Пример #2
0
void OSVersionFixture::SetUpTestCase() {
  // set up logging
  logFile = FileLogSink(toPath("./OSVersionFixture.log"));
  logFile->setLogLevel(Debug);
  Logger::instance().standardOutLogger().disable();

  // create and popluate resource folder
  openstudio::path thisVersionPath = versionResourcesPath(openstudio::VersionString(openStudioVersion()));
  if (!boost::filesystem::exists(thisVersionPath)) {
    boost::filesystem::create_directory(thisVersionPath);
  }

  // ETH@20120514 Eventually this cpp file should be configured by CMake so OpenStudio.idd can be 
  // directly copied over, and so all these items can be copied back into source.
  model::Model model = openstudio::model::exampleModel();
  model.save(thisVersionPath / toPath("example.osm"),true);
  model::Component component = model.getConcreteModelObjects<model::Construction>()[0].createComponent();
  component.save(thisVersionPath / toPath("example.osc"),true);
  IddFile iddFile = IddFactory::instance().getIddFile(IddFileType::OpenStudio);
  iddFile.save(thisVersionPath / toPath("OpenStudio.idd"),true);
}