Last change
on this file since 3949 was
3949,
checked in by hmayr, 14 years ago
|
following changes (#1046):
- changed AbstractHeuristicLabTest.cs
|
File size:
1.5 KB
|
Line | |
---|
1 | using Persistence;
|
---|
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
---|
3 | using System;
|
---|
4 |
|
---|
5 | namespace UnitTests {
|
---|
6 | /// <summary>
|
---|
7 | ///This is a abstract test class for all HeuristicLab unit tests
|
---|
8 | ///</summary>
|
---|
9 | public abstract class AbstractHeuristicLabTest {
|
---|
10 |
|
---|
11 | /// <summary>
|
---|
12 | /// shared database for all test methods
|
---|
13 | /// </summary>
|
---|
14 | protected Persistence.DataClassesDataContext db;
|
---|
15 |
|
---|
16 | /// <summary>
|
---|
17 | /// constructor creates database connection for all other test methods
|
---|
18 | /// </summary>
|
---|
19 | public AbstractHeuristicLabTest() {
|
---|
20 | db = Persistence.DatabaseUtil.createDataClassesDataContext();
|
---|
21 | }
|
---|
22 |
|
---|
23 | /// <summary>
|
---|
24 | /// creates and opens a local database out of the DataClasses and checks connection state
|
---|
25 | /// </summary>
|
---|
26 | [TestInitialize()]
|
---|
27 | public virtual void updateDBConnection() {
|
---|
28 | Assert.IsNotNull(db);
|
---|
29 | DatabaseUtil.createDatabase(db);
|
---|
30 | if (db.Connection.State != System.Data.ConnectionState.Open) {
|
---|
31 | db.Connection.Open();
|
---|
32 | }
|
---|
33 | Assert.AreEqual<System.Data.ConnectionState>(System.Data.ConnectionState.Open, db.Connection.State);
|
---|
34 | }
|
---|
35 |
|
---|
36 | /// <summary>
|
---|
37 | /// closes db connection
|
---|
38 | /// </summary>
|
---|
39 | [TestCleanup()]
|
---|
40 | public virtual void closeDBConnection() {
|
---|
41 | if (db.Connection.State == System.Data.ConnectionState.Open) {
|
---|
42 | db.Connection.Close();
|
---|
43 | }
|
---|
44 | Assert.AreEqual<System.Data.ConnectionState>(System.Data.ConnectionState.Closed, db.Connection.State);
|
---|
45 | }
|
---|
46 | }
|
---|
47 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.