blob: e677840aaf89c61fe025fa5ab946fe64cde6b93e (
plain) (
blame)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
/*
* The Mana World Server
* Copyright 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
* The Mana World is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or any later version.
*
* The Mana World is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with The Mana World; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id$
*/
#ifndef _TMWSERV_TEST_DATA_PROVIDER_H_
#define _TMWSERV_TEST_DATA_PROVIDER_H_
#include <cppunit/extensions/HelperMacros.h>
#include "dalexcept.h"
/**
* Unit test for the DataProvider class.
*/
class DataProviderTest: public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(DataProviderTest);
// add tests to the test suite.
CPPUNIT_TEST(testConnection1);
CPPUNIT_TEST(testCreateTable1);
CPPUNIT_TEST_EXCEPTION(testCreateTable2,
tmwserv::dal::DbSqlQueryExecFailure);
CPPUNIT_TEST(testInsert1);
CPPUNIT_TEST_EXCEPTION(testInsert2, tmwserv::dal::DbSqlQueryExecFailure);
CPPUNIT_TEST(testFetch1);
CPPUNIT_TEST(testDisconnection1);
CPPUNIT_TEST(testDisconnection2);
CPPUNIT_TEST_SUITE_END();
public:
/**
* Set up fixtures.
*/
void
setUp(void);
/**
* Tear down fixtures.
*/
void
tearDown(void);
/**
* Connection to an existing database.
*/
void
testConnection1(void);
/**
* Create a new table in the database.
*/
void
testCreateTable1(void);
/**
* Create the same table one more time in the database.
*/
void
testCreateTable2(void);
/**
* Insert a new record into the table.
*/
void
testInsert1(void);
/**
* Insert the same record again.
*/
void
testInsert2(void);
/**
* Fetch data from the table.
*/
void
testFetch1(void);
/**
* Disconnection from an open database.
*/
void
testDisconnection1(void);
/**
* Disconnection from a closed database.
*/
void
testDisconnection2(void);
private:
tmwserv::dal::DataProvider* mDb; /**< the data provider */
std::string mDbName; /**< the database name */
std::string mDbPath; /**< the database path */
std::string mDbUser; /**< the database user */
std::string mDbPassword; /**< the database password */
std::string mSqlCreateTable; /**< SQL query to create table */
std::string mSqlInsertRow; /**< SQL query to delete table */
std::string mSqlFetchRow; /**< SQL query to fetch data */
};
#endif // _TMWSERV_TEST_DATA_PROVIDER_H_
|