~people-project/people-core/deep-refactoring

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
using People;


namespace People.Backend.Sqlite.Test {

	public class ContactNew : People.Backend.Test.Contact {
		private string db_path = "/tmp/people-test-sqlite-ab-new.db";
		private global::Sqlite.Database db;

		protected override void initialize () {
			backend_name = "Sqlite";
			contact_id = null;
			contact_flags = Backend.ContactFlags.EDITABLE | Backend.ContactFlags.DELETABLE;

			base.initialize ();
		}

		protected override void set_up () {
			global::Sqlite.Database.open(db_path, out db);
			db.exec (
				"CREATE TABLE IF NOT EXISTS people(" +
					"id integer PRIMARY KEY AUTOINCREMENT," +
					"first_name string," +
					"middle_name string," +
					"last_name string," +
					"home_phone string," +
					"work_phone string," +
					"mobile_phone string," +
					"home_email string," +
					"work_email string" +
				");");

			contact = new Backend.Sqlite.Contact (null, db);

			definable_fields.add ("identity.name.first");
			definable_fields.add ("identity.name.middle");
			definable_fields.add ("identity.name.last");
			definable_fields.add ("communication.phone.home");
			definable_fields.add ("communication.phone.work");
			definable_fields.add ("communication.phone.mobile");
			definable_fields.add ("communication.email.home");
			definable_fields.add ("communication.email.work");
			base.set_up ();
		}

		protected override void tear_down () {
			db = null;
			FileUtils.unlink (db_path);

			base.tear_down ();
		}

		static int main(string[] args) {
			var suite = new ContactNew ();
			return suite.run ();
		}

	}
}