@@ -60,21 +60,6 @@ class TestObserver : public IOfflineStorageObserver
60
60
}
61
61
};
62
62
63
- // / <summary>
64
- // / No-op NULL object pattern log manager
65
- // / </summary>
66
- NullLogManager testLogManager;
67
-
68
- // / <summary>
69
- // / Default test configuration
70
- // / </summary>
71
- RuntimeConfig_Default testConfig (testLogManager.GetLogConfiguration());
72
-
73
- // / <summary>
74
- // / Storage observer
75
- // / </summary>
76
- TestObserver testObserver;
77
-
78
63
// Run the list of all supported latencies
79
64
std::set<EventLatency> latencies =
80
65
{
@@ -108,15 +93,40 @@ size_t addEvents(MemoryStorage& storage)
108
93
return total_db_size;
109
94
}
110
95
96
+ class MemoryStorageTests : public ::testing::Test
97
+ {
98
+ public:
99
+ // / <summary>
100
+ // / No-op NULL object pattern log manager
101
+ // / </summary>
102
+ NullLogManager testLogManager;
103
+
104
+ // / <summary>
105
+ // / Default test configuration
106
+ // / </summary>
107
+ std::unique_ptr<RuntimeConfig_Default> testConfig;
108
+
109
+ // / <summary>
110
+ // / Storage observer
111
+ // / </summary>
112
+ TestObserver testObserver;
113
+
114
+ virtual void SetUp () override
115
+ {
116
+ testConfig = std::make_unique<RuntimeConfig_Default>(testLogManager.GetLogConfiguration ());
117
+ }
118
+
119
+ };
120
+
111
121
// / <summary>
112
122
// / Initialize, generate some records, save and retrieve these records back.
113
123
// / </summary>
114
124
// / <param name="">The .</param>
115
125
// / <param name="">The .</param>
116
126
// / <returns></returns>
117
- TEST (MemoryStorageTests, StoreAndGetRecords)
127
+ TEST_F (MemoryStorageTests, StoreAndGetRecords)
118
128
{
119
- MemoryStorage storage (testLogManager, testConfig);
129
+ MemoryStorage storage (testLogManager, * testConfig);
120
130
121
131
// Observer callbacks are not currently implemented for this storage type
122
132
storage.Initialize (testObserver);
@@ -164,9 +174,9 @@ TEST(MemoryStorageTests, StoreAndGetRecords)
164
174
EXPECT_THAT (storage.GetSize (), 0 );
165
175
}
166
176
167
- TEST (MemoryStorageTests, GetRecordsDeletesRecords)
177
+ TEST_F (MemoryStorageTests, GetRecordsDeletesRecords)
168
178
{
169
- MemoryStorage storage (testLogManager, testConfig);
179
+ MemoryStorage storage (testLogManager, * testConfig);
170
180
171
181
std::vector<StorageRecordId> ids;
172
182
@@ -184,9 +194,9 @@ TEST(MemoryStorageTests, GetRecordsDeletesRecords)
184
194
EXPECT_THAT (records.size (), num_iterations * 4 ); // 4 latencies
185
195
}
186
196
187
- TEST (MemoryStorageTests, DeleteAllRecords)
197
+ TEST_F (MemoryStorageTests, DeleteAllRecords)
188
198
{
189
- MemoryStorage storage (testLogManager, testConfig);
199
+ MemoryStorage storage (testLogManager, * testConfig);
190
200
191
201
std::vector<StorageRecordId> ids;
192
202
@@ -204,9 +214,9 @@ TEST(MemoryStorageTests, DeleteAllRecords)
204
214
}
205
215
206
216
207
- TEST (MemoryStorageTests, ReleaseRecords)
217
+ TEST_F (MemoryStorageTests, ReleaseRecords)
208
218
{
209
- MemoryStorage storage (testLogManager, testConfig);
219
+ MemoryStorage storage (testLogManager, * testConfig);
210
220
211
221
std::vector<StorageRecordId> ids;
212
222
HttpHeaders headers;
@@ -246,9 +256,9 @@ TEST(MemoryStorageTests, ReleaseRecords)
246
256
EXPECT_THAT (storage.GetReservedCount (), 0 );
247
257
}
248
258
249
- TEST (MemoryStorageTests, GetAndReserveSome)
259
+ TEST_F (MemoryStorageTests, GetAndReserveSome)
250
260
{
251
- MemoryStorage storage (testLogManager, testConfig);
261
+ MemoryStorage storage (testLogManager, * testConfig);
252
262
storage.Initialize (testObserver);
253
263
addEvents (storage);
254
264
auto totalCount = storage.GetRecordCount ();
@@ -285,33 +295,33 @@ TEST(MemoryStorageTests, GetAndReserveSome)
285
295
}
286
296
287
297
// This method is not implemented for RAM storage
288
- TEST (MemoryStorageTests, StoreSetting)
298
+ TEST_F (MemoryStorageTests, StoreSetting)
289
299
{
290
- MemoryStorage storage (testLogManager, testConfig);
300
+ MemoryStorage storage (testLogManager, * testConfig);
291
301
bool result = storage.StoreSetting (" not_implemented" , " not_implemented" );
292
302
EXPECT_THAT (result, false );
293
303
}
294
304
295
305
// This method is not implemented for RAM storage
296
- TEST (MemoryStorageTests, GetSetting)
306
+ TEST_F (MemoryStorageTests, GetSetting)
297
307
{
298
- MemoryStorage storage (testLogManager, testConfig);
308
+ MemoryStorage storage (testLogManager, * testConfig);
299
309
auto result = storage.GetSetting (" not_implemented" );
300
310
EXPECT_THAT (result.empty (), true );
301
311
}
302
312
303
313
// This method is not implemented for RAM storage
304
- TEST (MemoryStorageTests, ResizeDb)
314
+ TEST_F (MemoryStorageTests, ResizeDb)
305
315
{
306
- MemoryStorage storage (testLogManager, testConfig);
316
+ MemoryStorage storage (testLogManager, * testConfig);
307
317
EXPECT_THAT (storage.ResizeDb (), true );
308
318
}
309
319
310
320
constexpr size_t MAX_STRESS_THREADS = 20 ;
311
321
312
- TEST (MemoryStorageTests, MultiThreadPerfTest)
322
+ TEST_F (MemoryStorageTests, MultiThreadPerfTest)
313
323
{
314
- MemoryStorage storage (testLogManager, testConfig);
324
+ MemoryStorage storage (testLogManager, * testConfig);
315
325
316
326
std::vector<std::thread> workers;
317
327
std::atomic<size_t > threadCount (0 );
0 commit comments