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());
}
TEST_F(IddFixture,IddFileAndFactoryWrapper_DirectlySetUserCustom) {
  IddFileAndFactoryWrapper wrapper(IddFileType::UserCustom);
  IddFile file = wrapper.iddFile();
  EXPECT_TRUE(file.objects().empty());
  BOOST_FOREACH(int typeIndex,IddObjectType::getValues()) {
    EXPECT_FALSE(wrapper.getObject(IddObjectType(typeIndex)));
  }
// ETH@20100521 Using this test to locate objects with characteristics I am looking for. Would
// rather use Ruby, but not quite sure about getting/using the installer.
TEST_F(IddFixture,IddFactory_ObjectFinder) {
    IddFileType fileType = IddFileType::WholeFactory;
    struct DesiredCharacteristics {
        bool operator()(const IddObject& object) {
            // fields that are \autocalculatable with no default, or a default other than 'autocalculate',
            // or fields that are \autosizable with no default or a default other than 'autosize'.
            for (const IddField& iddField : object.nonextensibleFields()) {
                if (iddField.properties().autocalculatable && (!iddField.properties().stringDefault ||
                        !istringEqual("autocalculate",iddField.properties().stringDefault.get())))
                {
                    return true;
                }
                if (iddField.properties().autosizable && (!iddField.properties().stringDefault ||
                        !istringEqual("autosize",iddField.properties().stringDefault.get())))
                {
                    return true;
                }
            }
            return false;
        }
    };

    IddFile iddFile = IddFactory::instance().getIddFile(fileType);
    IddObjectVector objects = iddFile.objects();
    LOG(Info,"IddObjects that satisfy DesiredCharacteristics:");
    DesiredCharacteristics tester;
    for (const IddObject& object : objects) {
        if (tester(object)) {
            LOG(Info,"  " << object.name());
        }
    }
}