| 45 | using namespace openstudio::model; |
| 46 | |
| 47 | TEST(AlfalfaJSON, basic_export) { |
| 48 | AlfalfaJSON alfalfa; |
| 49 | AlfalfaPoint constant = alfalfa.exposeConstant(17, "hello").get(); |
| 50 | |
| 51 | // Check that point has output of type "Constant" |
| 52 | ASSERT_TRUE(constant.output().is_initialized()); |
| 53 | EXPECT_EQ(constant.output().get().typeName(), "Constant"); |
| 54 | // Check that point does not have an input |
| 55 | EXPECT_FALSE(constant.input().is_initialized()); |
| 56 | |
| 57 | const AlfalfaPoint meter = alfalfa.exposeMeter("Electricity:Facility").get(); |
| 58 | std::cout << "here" << std::endl; |
| 59 | |
| 60 | // Check that point has output of type "Meter" |
| 61 | ASSERT_TRUE(meter.output().is_initialized()); |
| 62 | EXPECT_EQ(meter.output().get().typeName(), "Meter"); |
| 63 | // Check that point does not have an input |
| 64 | EXPECT_FALSE(meter.input().is_initialized()); |
| 65 | |
| 66 | const AlfalfaPoint actuator = alfalfa.exposeActuator("thing1", "thing2", "thing3").get(); |
| 67 | |
| 68 | // Check that point has output of type "Actuator" |
| 69 | ASSERT_TRUE(actuator.output().is_initialized()); |
| 70 | EXPECT_EQ(actuator.output().get().typeName(), "Actuator"); |
| 71 | // Check that point has input of type "Actuator" |
| 72 | ASSERT_TRUE(actuator.input().is_initialized()); |
| 73 | EXPECT_EQ(actuator.input().get().typeName(), "Actuator"); |
| 74 | |
| 75 | const AlfalfaPoint output_variable = alfalfa.exposeOutputVariable("key", "name").get(); |
| 76 | |
| 77 | // Check that point has output of type "OutputVariable" |
| 78 | ASSERT_TRUE(output_variable.output().is_initialized()); |
| 79 | EXPECT_EQ(output_variable.output().get().typeName(), "OutputVariable"); |
| 80 | // Check that point does not have an input |
| 81 | EXPECT_FALSE(output_variable.input().is_initialized()); |
| 82 | |
| 83 | const AlfalfaPoint global_variable = alfalfa.exposeGlobalVariable("name").get(); |
| 84 | |
| 85 | // Check that point has output of type "GlobalVariable" |
| 86 | ASSERT_TRUE(global_variable.output().is_initialized()); |
| 87 | EXPECT_EQ(global_variable.output().get().typeName(), "GlobalVariable"); |
| 88 | // Check that point has input of type "GlobalVariable" |
| 89 | ASSERT_TRUE(global_variable.input().is_initialized()); |
| 90 | EXPECT_EQ(global_variable.input().get().typeName(), "GlobalVariable"); |
| 91 | |
| 92 | std::vector<AlfalfaPoint> points = alfalfa.points(); |
| 93 | |
| 94 | ASSERT_EQ(points.size(), 5); |
| 95 | |
| 96 | constant.setUnits("mW"); |
| 97 | |
| 98 | EXPECT_EQ("mW", points.at(0).units().get()); |
| 99 | |
| 100 | EXPECT_EQ(constant, points.at(0)); |
| 101 | EXPECT_EQ(meter, points.at(1)); |
| 102 | EXPECT_EQ(actuator, points.at(2)); |
| 103 | EXPECT_EQ(output_variable, points.at(3)); |
| 104 | EXPECT_EQ(global_variable, points.at(4)); |
nothing calls this directly
no test coverage detected