TEST_F(IddFixture,IddFactory_IddObjects)
{
    IddObject object;

    OptionalIddObject candidate = IddFactory::instance().getObject(IddObjectType::UserCustom);
    EXPECT_FALSE(candidate);

    candidate = IddFactory::instance().getObject(IddObjectType::Catchall);
    ASSERT_TRUE(candidate);
    object = *candidate;
    candidate = IddFactory::instance().getObject("catchall");
    ASSERT_TRUE(candidate);
    EXPECT_TRUE(object == *candidate);

    candidate = IddFactory::instance().getObject(IddObjectType::CommentOnly);
    ASSERT_TRUE(candidate);
    object = *candidate;
    candidate = IddFactory::instance().getObject("coMmentonLy");
    ASSERT_TRUE(candidate);
    EXPECT_TRUE(object == *candidate);

    candidate = IddFactory::instance().getObject(IddObjectType::Lights);
    ASSERT_TRUE(candidate);
    object = *candidate;
    candidate = IddFactory::instance().getObject("lights");
    ASSERT_TRUE(candidate);
    EXPECT_TRUE(object == *candidate);
    EXPECT_EQ("Lights", object.name());
    ASSERT_TRUE(object.nonextensibleFields().size() > static_cast<unsigned>(0));
    EXPECT_EQ("Return Air Fraction Function of Plenum Temperature Coefficient 2",
              object.nonextensibleFields().back().name());

    OptionalIddField field = object.getField(0);
    ASSERT_TRUE(field);
    EXPECT_EQ("Name",field->name());
    EXPECT_TRUE(field->properties().required);
    EXPECT_EQ(IddFieldType(IddFieldType::AlphaType),field->properties().type);
    ASSERT_TRUE(!field->properties().references.empty());
    EXPECT_EQ(static_cast<unsigned>(1), field->properties().references.size());
    EXPECT_EQ("LightsNames", *(field->properties().references.begin()));
    EXPECT_FALSE(field->properties().stringDefault); // OptionalString should be false--no default name
    EXPECT_EQ(IddFieldProperties::Unbounded,field->properties().minBoundType);

    ASSERT_TRUE(object.nonextensibleFields().size() > static_cast<unsigned>(3));
    field = object.getField(3);
    EXPECT_EQ("Design Level Calculation Method",field->name());
    EXPECT_FALSE(field->properties().required);
    EXPECT_TRUE(field->properties().stringDefault);
    EXPECT_EQ("LightingLevel",*(field->properties().stringDefault));
    EXPECT_EQ(IddFieldType(IddFieldType::ChoiceType),field->properties().type);
    EXPECT_EQ(static_cast<unsigned>(3),field->keys().size());
}
Ejemplo n.º 2
0
TEST_F(IddFixture,IddObject_InsertHandleField) {
  // Test on EnergyPlus IDD object since no handles there
  // Use object with mix of A's and N's
  IddObjectType type(IddObjectType::HeatBalanceAlgorithm);
  IddObject temp = IddFactory::instance().getObject(type).get();
  std::stringstream ss;
  temp.print(ss);
  IddObject object = IddObject::load("HeatBalanceAlgorithm","Simulation Control",ss.str()).get();
  object.insertHandleField();
  EXPECT_EQ("A1",object.getField(0).get().fieldId());
  EXPECT_EQ("A2",object.getField(1).get().fieldId());
  EXPECT_EQ("N1",object.getField(2).get().fieldId());
}
Ejemplo n.º 3
0
TEST_F(IddFixture,IddKey_Getters) {
  OptionalIddObject optObject = IddFactory::instance().getObject(IddObjectType::Controller_OutdoorAir);
  ASSERT_TRUE(optObject);
  IddObject obj = *optObject;
  OptionalIddField f = obj.getField(Controller_OutdoorAirFields::EconomizerControlType);
  ASSERT_TRUE(f);
  EXPECT_TRUE(f->properties().type == IddFieldType::ChoiceType);
  IddKeyVector keys = f->keys();
  EXPECT_EQ(static_cast<unsigned>(8),keys.size());
  LOG(Info,"Keys for field " << Controller_OutdoorAirFields::EconomizerControlType 
      << ", " << f->name() << ", of IddObject " << obj.name() << ":");
  unsigned i = 0;
  BOOST_FOREACH(IddKey& key,keys) {
    LOG(Info,"  Key " << i << ": " << key.name());
    ++i;
  }