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
|
/* test-contact-source-factory.vala
*
* Copyright (C) 2008 Ali Sabil <ali.sabil@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
using People;
using Core.Async;
namespace People.Backend.Test {
public abstract class ContactSourceFactory : Core.Trial.Suite {
protected string backend_name = "Null";
protected uint parameters_count = 0;
protected string[] parameters_names;
protected Type[] parameters_types;
protected Backend.ContactSourceFactory contact_source_factory;
protected override void initialize () {
name = "People::Backend::%s::ContactSourceFactory".printf (backend_name);
add_test_case ("Parameters count", test_parameters_count);
add_test_case ("Parameters names", test_parameters_names);
add_test_case ("Parameters types", test_parameters_types);
add_test_case ("request_contact_source with null",
test_request_contact_source_null_param);
}
protected override void set_up () {
}
protected override void tear_down () {
contact_source_factory = null;
}
private void test_parameters_count () {
var parameters = contact_source_factory.get_parameters ();
assert_true (parameters.length == parameters_count);
}
private void test_parameters_names () {
var parameters = contact_source_factory.get_parameters ();
uint i = 0;
foreach (Backend.ContactSourceParamSpec parameter in parameters) {
assert_true (parameter.name == parameters_names[i++]);
}
}
private void test_parameters_types () {
var parameters = contact_source_factory.get_parameters ();
uint i = 0;
foreach (Backend.ContactSourceParamSpec parameter in parameters) {
assert_true (parameter.gtype == parameters_types[i++]);
}
}
private void test_request_contact_source_null_param () {
var async_result = contact_source_factory.request_contact_source (null);
async_result.add_callback (async_callback);
async_wait ();
try {
var cs = async_result.get ();
assert_true (cs != null);
} catch (Backend.Error e) {
success ();
return;
}
failure ();
}
private void async_callback (AsyncResult async_result) {
async_break ();
}
}
}
|