~ubuntu-branches/ubuntu/trusty/zipper.app/trusty

« back to all changes in this revision

Viewing changes to Tests/PreferencesTestCase.m

  • Committer: Bazaar Package Importer
  • Author(s): Gürkan Sengün
  • Date: 2004-11-10 23:40:33 UTC
  • Revision ID: james.westby@ubuntu.com-20041110234033-v32mldso2yf8i7v4
Tags: upstream-0.9
Import upstream version 0.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#import <Foundation/Foundation.h>
 
2
#import "PreferencesTestCase.h"
 
3
#import "Preferences.h"
 
4
 
 
5
@implementation PreferencesTestCase : TestCase
 
6
 
 
7
- (void)setUp
 
8
{
 
9
        NSUserDefaults *defaults;
 
10
 
 
11
        // zap all prefs
 
12
        defaults = [NSUserDefaults standardUserDefaults];
 
13
        [defaults removePersistentDomainForName:@"Zipper"];
 
14
        [defaults synchronize];
 
15
        // also remove all replacement preferences that might have been set from previous test cases
 
16
        [Preferences usePreferences:nil];
 
17
}
 
18
 
 
19
- (void)testUnsetPref
 
20
{
 
21
        // setUp zaps all existing prefs
 
22
        [self assertNil:[[NSUserDefaults standardUserDefaults] objectForKey:PREF_KEY_TAR]];
 
23
}
 
24
 
 
25
- (void)testFindInPath
 
26
{
 
27
        NSString *tar;
 
28
        
 
29
        // currently, all tests run in the same instance. This is unlike JUnit, however. In order
 
30
        // to get this desired behaviour we call setUp here for now.
 
31
        [self setUp];
 
32
        
 
33
        tar = [Preferences tarExecutable];
 
34
        [self assert:tar equals:@"/bin/tar"];
 
35
}
 
36
 
 
37
- (void)testReplacementPrefs
 
38
{
 
39
        NSDictionary *dict;
 
40
        NSString *dummyTar;
 
41
 
 
42
        // currently, all tests run in the same instance. This is unlike JUnit, however. In order
 
43
        // to get this desired behaviour we call setUp here for now.
 
44
        [self setUp];
 
45
                
 
46
        dummyTar = @"/foo/bar/baz/tar";
 
47
        dict = [NSDictionary dictionaryWithObject:dummyTar forKey:PREF_KEY_TAR];
 
48
        [Preferences usePreferences:dict];
 
49
        
 
50
        [self assert:[Preferences tarExecutable] equals:dummyTar];
 
51
}
 
52
 
 
53
- (void)testPrefsFromPlist
 
54
{
 
55
        // currently, all tests run in the same instance. This is unlike JUnit, however. In order
 
56
        // to get this desired behaviour we call setUp here for now.
 
57
        [self setUp];
 
58
 
 
59
        [self assert:[Preferences zipExecutable] equals:@"/plist/zip"];
 
60
}
 
61
 
 
62
@end