summaryrefslogtreecommitdiff
path: root/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLCarModeStatusSpec.m
blob: 78f04e83712c30bb043b3ecb33f5876f193d17a9 (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
//
//  SDLCarModeStatusSpec.m
//  SmartDeviceLink


#import <Foundation/Foundation.h>

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

#import "SDLCarModeStatus.h"

QuickSpecBegin(SDLCarModeStatusSpec)

describe(@"Individual Enum Value Tests", ^ {
    it(@"Should match internal values", ^ {
        expect([SDLCarModeStatus NORMAL].value).to(equal(@"NORMAL"));
        expect([SDLCarModeStatus FACTORY].value).to(equal(@"FACTORY"));
        expect([SDLCarModeStatus TRANSPORT].value).to(equal(@"TRANSPORT"));
        expect([SDLCarModeStatus CRASH].value).to(equal(@"CRASH"));
    });
});
describe(@"ValueOf Tests", ^ {
    it(@"Should return correct values when valid", ^ {
        expect([SDLCarModeStatus valueOf:@"NORMAL"]).to(equal([SDLCarModeStatus NORMAL]));
        expect([SDLCarModeStatus valueOf:@"FACTORY"]).to(equal([SDLCarModeStatus FACTORY]));
        expect([SDLCarModeStatus valueOf:@"TRANSPORT"]).to(equal([SDLCarModeStatus TRANSPORT]));
        expect([SDLCarModeStatus valueOf:@"CRASH"]).to(equal([SDLCarModeStatus CRASH]));
    });
    
    it(@"Should return nil when invalid", ^ {
        expect([SDLCarModeStatus valueOf:nil]).to(beNil());
        expect([SDLCarModeStatus valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil());
    });
});
describe(@"Value List Tests", ^ {
    NSArray* storedValues = [SDLCarModeStatus values];
    __block NSArray* definedValues;
    beforeSuite(^ {
        definedValues = [@[[SDLCarModeStatus NORMAL],
                        [SDLCarModeStatus FACTORY],
                        [SDLCarModeStatus TRANSPORT],
                        [SDLCarModeStatus CRASH]] 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