summaryrefslogtreecommitdiff
path: root/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLStartTimeSpec.m
blob: 209b8d75da880a5f6191c4526ce57cb4367201f9 (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
//
//  SDLStartTimeSpec.m
//  SmartDeviceLink


#import <Foundation/Foundation.h>

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

#import "SDLStartTime.h"
#import "SDLNames.h"

QuickSpecBegin(SDLStartTimeSpec)

describe(@"StartTime Spec", ^ {
    describe(@"when initialized", ^{
        __block UInt8 testHours = 22;
        __block UInt8 testMinutes = 39;
        __block UInt8 testSeconds = 11;

        __block NSTimeInterval testTimeInterval = 81551;

        it(@"should properly initialize with init", ^{
            SDLStartTime *testStruct = [[SDLStartTime alloc] init];

            expect(testStruct.hours).to(beNil());
            expect(testStruct.minutes).to(beNil());
            expect(testStruct.seconds).to(beNil());
        });

        it(@"should properly initialize with initWithDictionary:", ^{
            NSDictionary<NSString *, id> *dict = @{SDLNameHours:@(testHours),
                                                   SDLNameMinutes:@(testMinutes),
                                                   SDLNameSeconds:@(testSeconds)};
            SDLStartTime *testStruct = [[SDLStartTime alloc] initWithDictionary:dict];

            expect(testStruct.hours).to(equal(@(testHours)));
            expect(testStruct.minutes).to(equal(@(testMinutes)));
            expect(testStruct.seconds).to(equal(@(testSeconds)));
        });

        it(@"should properly initialize with initWithTimeInterval:", ^{
            SDLStartTime *testStruct = [[SDLStartTime alloc] initWithTimeInterval:testTimeInterval];

            expect(testStruct.hours).to(equal(@(testHours)));
            expect(testStruct.minutes).to(equal(@(testMinutes)));
            expect(testStruct.seconds).to(equal(@(testSeconds)));
        });

        it(@"should properly initialize with initWithHours:minutes:seconds:", ^{
            SDLStartTime *testStruct = [[SDLStartTime alloc] initWithHours:testHours minutes:testMinutes seconds:testSeconds];

            expect(testStruct.hours).to(equal(@(testHours)));
            expect(testStruct.minutes).to(equal(@(testMinutes)));
            expect(testStruct.seconds).to(equal(@(testSeconds)));
        });
    });

    it(@"Should set and get correctly", ^ {
        SDLStartTime* testStruct = [[SDLStartTime alloc] init];
        
        testStruct.hours = @22;
        testStruct.minutes = @39;
        testStruct.seconds = @11;
        
        expect(testStruct.hours).to(equal(@22));
        expect(testStruct.minutes).to(equal(@39));
        expect(testStruct.seconds).to(equal(@11));
    });
});

QuickSpecEnd