summaryrefslogtreecommitdiff
path: root/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLRequestTypeSpec.m
blob: 7a314e1a624431fafc3c21f495e236faa16a1d38 (plain)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//
//  SDLRequestTypeSpec.m
//  SmartDeviceLink


#import <Foundation/Foundation.h>

#import <Quick/Quick.h>
#import <Nimble/Nimble.h>

#import "SDLRequestType.h"

QuickSpecBegin(SDLRequestTypeSpec)

describe(@"Individual Enum Value Tests", ^ {
    it(@"Should match internal values", ^ {
        expect([SDLRequestType HTTP].value).to(equal(@"HTTP"));
        expect([SDLRequestType FILE_RESUME].value).to(equal(@"FILE_RESUME"));
        expect([SDLRequestType AUTH_REQUEST].value).to(equal(@"AUTH_REQUEST"));
        expect([SDLRequestType AUTH_CHALLENGE].value).to(equal(@"AUTH_CHALLENGE"));
        expect([SDLRequestType AUTH_ACK].value).to(equal(@"AUTH_ACK"));
        expect([SDLRequestType PROPRIETARY].value).to(equal(@"PROPRIETARY"));
        expect([SDLRequestType QUERY_APPS].value).to(equal(@"QUERY_APPS"));
        expect([SDLRequestType LAUNCH_APP].value).to(equal(@"LAUNCH_APP"));
        expect([SDLRequestType LOCK_SCREEN_ICON_URL].value).to(equal(@"LOCK_SCREEN_ICON_URL"));
        expect([SDLRequestType TRAFFIC_MESSAGE_CHANNEL].value).to(equal(@"TRAFFIC_MESSAGE_CHANNEL"));
        expect([SDLRequestType DRIVER_PROFILE].value).to(equal(@"DRIVER_PROFILE"));
        expect([SDLRequestType VOICE_SEARCH].value).to(equal(@"VOICE_SEARCH"));
        expect([SDLRequestType NAVIGATION].value).to(equal(@"NAVIGATION"));
        expect([SDLRequestType PHONE].value).to(equal(@"PHONE"));
        expect([SDLRequestType CLIMATE].value).to(equal(@"CLIMATE"));
        expect([SDLRequestType SETTINGS].value).to(equal(@"SETTINGS"));
        expect([SDLRequestType VEHICLE_DIAGNOSTICS].value).to(equal(@"VEHICLE_DIAGNOSTICS"));
        expect([SDLRequestType EMERGENCY].value).to(equal(@"EMERGENCY"));
        expect([SDLRequestType MEDIA].value).to(equal(@"MEDIA"));
        expect([SDLRequestType FOTA].value).to(equal(@"FOTA"));
    });
});

describe(@"ValueOf Tests", ^ {
    it(@"Should return correct values when valid", ^ {
        expect([SDLRequestType valueOf:@"HTTP"]).to(equal([SDLRequestType HTTP]));
        expect([SDLRequestType valueOf:@"FILE_RESUME"]).to(equal([SDLRequestType FILE_RESUME]));
        expect([SDLRequestType valueOf:@"AUTH_REQUEST"]).to(equal([SDLRequestType AUTH_REQUEST]));
        expect([SDLRequestType valueOf:@"AUTH_CHALLENGE"]).to(equal([SDLRequestType AUTH_CHALLENGE]));
        expect([SDLRequestType valueOf:@"AUTH_ACK"]).to(equal([SDLRequestType AUTH_ACK]));
        expect([SDLRequestType valueOf:@"QUERY_APPS"]).to(equal([SDLRequestType QUERY_APPS]));
        expect([SDLRequestType valueOf:@"LAUNCH_APP"]).to(equal([SDLRequestType LAUNCH_APP]));
        expect([SDLRequestType valueOf:@"LOCK_SCREEN_ICON_URL"]).to(equal([SDLRequestType LOCK_SCREEN_ICON_URL]));
        expect([SDLRequestType valueOf:@"TRAFFIC_MESSAGE_CHANNEL"]).to(equal([SDLRequestType TRAFFIC_MESSAGE_CHANNEL]));
        expect([SDLRequestType valueOf:@"DRIVER_PROFILE"]).to(equal([SDLRequestType DRIVER_PROFILE]));
        expect([SDLRequestType valueOf:@"VOICE_SEARCH"]).to(equal([SDLRequestType VOICE_SEARCH]));
        expect([SDLRequestType valueOf:@"NAVIGATION"]).to(equal([SDLRequestType NAVIGATION]));
        expect([SDLRequestType valueOf:@"PHONE"]).to(equal([SDLRequestType PHONE]));
        expect([SDLRequestType valueOf:@"CLIMATE"]).to(equal([SDLRequestType CLIMATE]));
        expect([SDLRequestType valueOf:@"SETTINGS"]).to(equal([SDLRequestType SETTINGS]));
        expect([SDLRequestType valueOf:@"VEHICLE_DIAGNOSTICS"]).to(equal([SDLRequestType VEHICLE_DIAGNOSTICS]));
        expect([SDLRequestType valueOf:@"EMERGENCY"]).to(equal([SDLRequestType EMERGENCY]));
        expect([SDLRequestType valueOf:@"MEDIA"]).to(equal([SDLRequestType MEDIA]));
        expect([SDLRequestType valueOf:@"FOTA"]).to(equal([SDLRequestType FOTA]));
    });
    
    it(@"Should return nil when invalid", ^ {
        expect([SDLRequestType valueOf:nil]).to(beNil());
        expect([SDLRequestType valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil());
    });
});

describe(@"Value List Tests", ^ {
    NSArray* storedValues = [SDLRequestType values];
    __block NSArray* definedValues;
    beforeSuite(^ {
        definedValues = [@[[SDLRequestType HTTP],
                           [SDLRequestType FILE_RESUME],
                           [SDLRequestType AUTH_REQUEST],
                           [SDLRequestType AUTH_CHALLENGE],
                           [SDLRequestType AUTH_ACK],
                           [SDLRequestType PROPRIETARY],
                           [SDLRequestType QUERY_APPS],
                           [SDLRequestType LAUNCH_APP],
                           [SDLRequestType LOCK_SCREEN_ICON_URL],
                           [SDLRequestType TRAFFIC_MESSAGE_CHANNEL],
                           [SDLRequestType DRIVER_PROFILE],
                           [SDLRequestType VOICE_SEARCH],
                           [SDLRequestType NAVIGATION],
                           [SDLRequestType PHONE],
                           [SDLRequestType CLIMATE],
                           [SDLRequestType SETTINGS],
                           [SDLRequestType VEHICLE_DIAGNOSTICS],
                           [SDLRequestType EMERGENCY],
                           [SDLRequestType MEDIA],
                           [SDLRequestType FOTA]] copy];
    });
    
    it(@"Should contain all defined enum values", ^ {
        for (int i = 0; i < definedValues.count; i++) {
            expect(storedValues).to(contain(definedValues[i]));
        }
    });
    
    it(@"Should contain only defined enum values", ^ {
        for (int i = 0; i < storedValues.count; i++) {
            expect(definedValues).to(contain(storedValues[i]));
        }
    });
});

QuickSpecEnd