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
|
#import <Foundation/Foundation.h>
#import "PreferencesTestCase.h"
#import "Preferences.h"
@implementation PreferencesTestCase : TestCase
- (void)setUp
{
NSUserDefaults *defaults;
// zap all prefs
defaults = [NSUserDefaults standardUserDefaults];
[defaults removePersistentDomainForName:@"Zipper"];
[defaults synchronize];
// also remove all replacement preferences that might have been set from previous test cases
[Preferences usePreferences:nil];
}
- (void)testUnsetPref
{
// setUp zaps all existing prefs
[self assertNil:[[NSUserDefaults standardUserDefaults] objectForKey:PREF_KEY_TAR]];
}
- (void)testFindInPath
{
NSString *tar;
// currently, all tests run in the same instance. This is unlike JUnit, however. In order
// to get this desired behaviour we call setUp here for now.
[self setUp];
tar = [Preferences tarExecutable];
[self assert:tar equals:@"/bin/tar"];
}
- (void)testReplacementPrefs
{
NSDictionary *dict;
NSString *dummyTar;
// currently, all tests run in the same instance. This is unlike JUnit, however. In order
// to get this desired behaviour we call setUp here for now.
[self setUp];
dummyTar = @"/foo/bar/baz/tar";
dict = [NSDictionary dictionaryWithObject:dummyTar forKey:PREF_KEY_TAR];
[Preferences usePreferences:dict];
[self assert:[Preferences tarExecutable] equals:dummyTar];
}
- (void)testPrefsFromPlist
{
// currently, all tests run in the same instance. This is unlike JUnit, however. In order
// to get this desired behaviour we call setUp here for now.
[self setUp];
[self assert:[Preferences zipExecutable] equals:@"/plist/zip"];
}
@end
|