| 12 | using namespace openstudio; |
| 13 | |
| 14 | TEST_F(BCLFixture, BCLFileReference) { |
| 15 | |
| 16 | openstudio::path testDir = openstudio::filesystem::system_complete(getApplicationBuildDirectory() / toPath("Testing")); |
| 17 | openstudio::path relativePath = toPath("BCLFileReference.txt"); |
| 18 | openstudio::path absolutePath = testDir / relativePath; |
| 19 | if (exists(absolutePath)) { |
| 20 | remove(absolutePath); |
| 21 | } |
| 22 | ASSERT_FALSE(exists(absolutePath)); |
| 23 | |
| 24 | BCLFileReference ref(testDir, relativePath, true); |
| 25 | EXPECT_FALSE(ref.checkForUpdate()); |
| 26 | |
| 27 | EXPECT_EQ("BCLFileReference.txt", ref.fileName()); |
| 28 | EXPECT_EQ("txt", ref.fileType()); |
| 29 | |
| 30 | openstudio::filesystem::ofstream file(absolutePath); |
| 31 | ASSERT_TRUE(file.is_open()); |
| 32 | file << "Hi"; |
| 33 | file.close(); |
| 34 | |
| 35 | EXPECT_TRUE(ref.checkForUpdate()); |
| 36 | |
| 37 | EXPECT_FALSE(ref.checkForUpdate()); |
| 38 | |
| 39 | file.open(absolutePath); |
| 40 | ASSERT_TRUE(file.is_open()); |
| 41 | file << "Bye"; |
| 42 | file.close(); |
| 43 | |
| 44 | EXPECT_TRUE(ref.checkForUpdate()); |
| 45 | |
| 46 | EXPECT_FALSE(ref.checkForUpdate()); |
| 47 | |
| 48 | ASSERT_TRUE(exists(absolutePath)); |
| 49 | remove(absolutePath); |
| 50 | ASSERT_FALSE(exists(absolutePath)); |
| 51 | |
| 52 | EXPECT_TRUE(ref.checkForUpdate()); |
| 53 | |
| 54 | EXPECT_FALSE(ref.checkForUpdate()); |
| 55 | } |