blob: e9b0c29dbcf4e3b585969a1b6f21047e562d6cda (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#include <gtest/gtest.h>
#include <crepe/ValueBroker.h>
#include <crepe/facade/DB.h>
#include <crepe/manager/SaveManager.h>
using namespace std;
using namespace crepe;
using namespace testing;
class SaveManagerTest : public Test {
Mediator m;
class TestSaveManager : public SaveManager {
using SaveManager::SaveManager;
// in-memory database for testing
DB db{};
virtual DB & get_db() override { return this->db; }
};
public:
TestSaveManager mgr{m};
};
TEST_F(SaveManagerTest, ReadWrite) {
ASSERT_FALSE(mgr.has("foo"));
mgr.set<string>("foo", "bar");
ASSERT_TRUE(mgr.has("foo"));
ValueBroker value = mgr.get<string>("foo");
EXPECT_EQ(value.get(), "bar");
}
TEST_F(SaveManagerTest, DefaultValue) {
ValueBroker value = mgr.get<int>("foo", 3);
ASSERT_EQ(value.get(), 3);
value.set(5);
ASSERT_EQ(value.get(), 5);
}
|