changeset 737:1dee6e9bdbf4

abstraction of databasewrapper tests
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 14 Mar 2014 11:23:57 +0100
parents 7019922daf3d
children c60743fadd4e
files UnitTestsSources/ServerIndexTests.cpp
diffstat 1 files changed, 37 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/UnitTestsSources/ServerIndexTests.cpp	Fri Feb 28 17:08:59 2014 +0100
+++ b/UnitTestsSources/ServerIndexTests.cpp	Fri Mar 14 11:23:57 2014 +0100
@@ -14,6 +14,12 @@
 
 namespace
 {
+  enum DatabaseWrapperClass
+  {
+    DatabaseWrapperClass_SQLite
+  };
+
+
   class ServerIndexListener : public IServerIndexListener
   {
   public:
@@ -41,14 +47,36 @@
       LOG(INFO) << "A file must be removed: " << fileUuid;
     }                                
   };
+
+
+  class DatabaseWrapperTest : public ::testing::TestWithParam<DatabaseWrapperClass>
+  {
+  protected:
+    ServerIndexListener listener;
+    DatabaseWrapper index;
+
+    DatabaseWrapperTest() : index(listener)
+    {
+    }
+
+    virtual void SetUp() 
+    {
+    }
+
+    virtual void TearDown()
+    {
+    }
+  };
 }
 
 
-TEST(DatabaseWrapper, Simple)
+INSTANTIATE_TEST_CASE_P(DatabaseWrapperName,
+                        DatabaseWrapperTest,
+                        ::testing::Values(DatabaseWrapperClass_SQLite));
+
+
+TEST_P(DatabaseWrapperTest, Simple)
 {
-  ServerIndexListener listener;
-  DatabaseWrapper index(listener);
-
   int64_t a[] = {
     index.CreateResource("a", ResourceType_Patient),   // 0
     index.CreateResource("b", ResourceType_Study),     // 1
@@ -235,11 +263,8 @@
 
 
 
-TEST(DatabaseWrapper, Upward)
+TEST_P(DatabaseWrapperTest, Upward)
 {
-  ServerIndexListener listener;
-  DatabaseWrapper index(listener);
-
   int64_t a[] = {
     index.CreateResource("a", ResourceType_Patient),   // 0
     index.CreateResource("b", ResourceType_Study),     // 1
@@ -304,11 +329,8 @@
 }
 
 
-TEST(DatabaseWrapper, PatientRecycling)
+TEST_P(DatabaseWrapperTest, PatientRecycling)
 {
-  ServerIndexListener listener;
-  DatabaseWrapper index(listener);
-
   std::vector<int64_t> patients;
   for (int i = 0; i < 10; i++)
   {
@@ -357,11 +379,8 @@
 }
 
 
-TEST(DatabaseWrapper, PatientProtection)
+TEST_P(DatabaseWrapperTest, PatientProtection)
 {
-  ServerIndexListener listener;
-  DatabaseWrapper index(listener);
-
   std::vector<int64_t> patients;
   for (int i = 0; i < 5; i++)
   {
@@ -439,11 +458,8 @@
 
 
 
-TEST(DatabaseWrapper, Sequence)
+TEST_P(DatabaseWrapperTest, Sequence)
 {
-  ServerIndexListener listener;
-  DatabaseWrapper index(listener);
-
   ASSERT_EQ(1u, index.IncrementGlobalSequence(GlobalProperty_AnonymizationSequence));
   ASSERT_EQ(2u, index.IncrementGlobalSequence(GlobalProperty_AnonymizationSequence));
   ASSERT_EQ(3u, index.IncrementGlobalSequence(GlobalProperty_AnonymizationSequence));
@@ -452,11 +468,8 @@
 
 
 
-TEST(DatabaseWrapper, LookupTagValue)
+TEST_P(DatabaseWrapperTest, LookupTagValue)
 {
-  ServerIndexListener listener;
-  DatabaseWrapper index(listener);
-
   int64_t a[] = {
     index.CreateResource("a", ResourceType_Study),   // 0
     index.CreateResource("b", ResourceType_Study),   // 1