Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

testTableDataStore.h

Go to the documentation of this file.
00001 /*
00002  * testTableDataStore.h
00003  *
00004  *  Created on: 6-aug-2009
00005  *      Author: dodijk
00006  */
00007 
00008 #ifndef TESTTABLEDATASTORE_H
00009 #define TESTTABLEDATASTORE_H
00010 
00011 #define BOOST_TEST_MODULE MediaTableTestSuite
00012 #include "boost/test/unit_test.hpp"
00013 
00014 #include "testTableDataSource.h"
00015 //#include "testTableDataView.h"
00016 
00017 #include "../TableDataSource.h"
00018 #include "../TableDataStore.h"
00019 //#include "TableDataView.h"
00020 
00021 #include "Basis/Quid.h"
00022 
00023 typedef Impala::Application::MediaTable::TableDataSource                                TableDataSource;
00024 typedef Impala::Application::MediaTable::TableDataStore                                 TableDataStore;
00025 typedef Impala::Application::MediaTable::TableDataView                                  TableDataView;
00026 typedef TableDataSourceTests::TableDataSourceFixture                                    TableDataSourceFixture;
00027 
00028 BOOST_AUTO_TEST_SUITE(TableDataStoreTests)
00029 
00030 struct TableDataStoreFixture : public TableDataSourceFixture {
00031         TableDataStoreFixture() {
00032                 store = TableDataStore::GetInstance();
00033         }
00034         ~TableDataStoreFixture() {
00035                 TableDataStore::GetInstance()->Clear();
00036         }
00037 
00038         TableDataStore* store;
00039 };
00040 
00041 BOOST_FIXTURE_TEST_CASE(testTableDataStoreRemove, TableDataStoreFixture) {
00042     /*store->RemoveTableDataSource("default");
00043     assert(store->GetTableDataSourceCount() == 0);
00044     store->AddTableDataSource("default", src);
00045 
00046     store->RemoveTableDataSource(src);
00047     assert(store->GetTableDataSourceCount() == 0);
00048     store->AddTableDataSource("default", src);*/
00049 }
00050 
00051 BOOST_FIXTURE_TEST_CASE(TableDataStoreTest, TableDataStoreFixture) {
00052     BOOST_REQUIRE(src);
00053 
00054     BOOST_REQUIRE(store);
00055 
00056     int mTableDataSourceCount = store->GetTableDataSourceCount();
00057     BOOST_WARN_GT(mTableDataSourceCount, 0);
00058     store->AddTableDataSource("test", src);
00059     BOOST_CHECK_GT(store->GetTableDataSourceCount(), mTableDataSourceCount);
00060 
00061     TableDataView* view = store->GetTableDataView("test", "test");
00062     BOOST_REQUIRE(view);
00063 
00064     TableDataViewTests::IsValidTableDataViewTest(view);
00065     int nrOfRows = view->GetNumberOfRows();
00066 
00067     view->SetNumberOfRows(nrOfRows-1);
00068     BOOST_CHECK_LT(view->GetNumberOfRows(), nrOfRows);
00069 
00070     TableDataView* view2 = store->GetTableDataView("test", "test2");
00071     BOOST_REQUIRE(view2);
00072     BOOST_CHECK_EQUAL(view2->GetNumberOfRows(), nrOfRows);
00073 }
00074 
00075 
00076 BOOST_FIXTURE_TEST_CASE(TableDataStoreQuidTest, TableDataStoreFixture) {
00077     BOOST_REQUIRE(src);
00078 
00079     BOOST_REQUIRE(store);
00080 
00081     BOOST_CHECK_EQUAL(Impala::QuidClass(src->GetQuid("id", 1)), 0);
00082     BOOST_CHECK_EQUAL(Impala::QuidSet(src->GetQuid("id", 1)), TableDataSource::TYPE_INT);
00083     BOOST_CHECK_EQUAL(Impala::QuidObject(src->GetQuid("id", 1)), 1);
00084     BOOST_CHECK_EQUAL(Impala::QuidId(src->GetQuid("id", 1)), 1);
00085     BOOST_CHECK_EQUAL(Impala::QuidId(src->GetQuid("id", 2)), 2);
00086 
00087     BOOST_CHECK_EQUAL(src->GetQuid("id", 1), Impala::MakeQuid(0, TableDataSource::TYPE_INT, 1, 1));
00088     BOOST_CHECK_EQUAL(src->GetQuid("red", 2), Impala::MakeQuid(0, TableDataSource::TYPE_NORMALIZEDVALUE, 2, 2));
00089     BOOST_CHECK_EQUAL(src->GetQuid("green", 3), Impala::MakeQuid(0, TableDataSource::TYPE_NORMALIZEDVALUE, 3, 3));
00090     BOOST_CHECK_EQUAL(src->GetQuid("blue", 4), Impala::MakeQuid(0, TableDataSource::TYPE_NORMALIZEDVALUE, 4, 4));
00091 
00092     store->AddTableDataSource("test", src);
00093 
00094     BOOST_CHECK_EQUAL(Impala::QuidClass(src->GetQuid("id", 1)), 1);
00095     BOOST_CHECK_EQUAL(src->GetQuid("id", 1), Impala::MakeQuid(1, TableDataSource::TYPE_INT, 1, 1));
00096     BOOST_CHECK_EQUAL(src->GetQuid("red", 2), Impala::MakeQuid(1, TableDataSource::TYPE_NORMALIZEDVALUE, 2, 2));
00097     BOOST_CHECK_EQUAL(src->GetQuid("green", 3), Impala::MakeQuid(1, TableDataSource::TYPE_NORMALIZEDVALUE, 3, 3));
00098     BOOST_CHECK_EQUAL(src->GetQuid("blue", 4), Impala::MakeQuid(1, TableDataSource::TYPE_NORMALIZEDVALUE, 4, 4));
00099 
00100     TableDataView* view = store->GetTableDataView("test", "test");
00101 
00102     BOOST_CHECK_EQUAL(Impala::QuidClass(view->GetSortedQuid("id", 1)), 1);
00103     BOOST_CHECK_EQUAL(Impala::QuidSet(view->GetSortedQuid("id", 1)), TableDataSource::TYPE_INT);
00104     BOOST_CHECK_EQUAL(Impala::QuidObject(view->GetSortedQuid("id", 1)), 1);
00105     BOOST_CHECK_EQUAL(Impala::QuidId(view->GetSortedQuid("id", 1)), 1);
00106     BOOST_CHECK_EQUAL(view->GetSortedQuid("id", 1), Impala::MakeQuid(1, TableDataSource::TYPE_INT, 1, 1));
00107 }
00108 
00109 BOOST_AUTO_TEST_SUITE_END()
00110 
00111 #endif /* TESTTABLEDATASTORE_H */

Generated on Fri Mar 19 09:30:37 2010 for ImpalaSrc by  doxygen 1.5.1