summaryrefslogtreecommitdiff
path: root/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLSpatialStructSpec.m
blob: 614f2a0fc0ec320262a15485803374b8078773f5 (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
//
//  SDLSpatialStructSpec.m
//  SmartDeviceLink-iOS
//
//  Created by Nicole on 8/3/17.
//  Copyright © 2017 smartdevicelink. All rights reserved.
//

#import <Foundation/Foundation.h>

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

#import "SDLNames.h"
#import "SDLSpatialStruct.h"

QuickSpecBegin(SDLSpatialStructSpec)

describe(@"Getter/Setter Tests", ^{
    it(@"Should set and get correctly", ^{
        SDLSpatialStruct *testStruct = [[SDLSpatialStruct alloc] init];

        testStruct.id = @1;
        testStruct.x = @10;
        testStruct.y = @100;
        testStruct.width = @1000;
        testStruct.height = @2000;

        expect(testStruct.id).to(equal(@1));
        expect(testStruct.x).to(equal(@10));
        expect(testStruct.y).to(equal(@100));
        expect(testStruct.width).to(equal(@1000));
        expect(testStruct.height).to(equal(@2000));
    });

    it(@"Should get correctly when initialized with parameters", ^{
        SDLSpatialStruct *testStruct = [[SDLSpatialStruct alloc] initWithId:5 x:@50.0 y:@60.0 width:@500.0 height:@600.0];

        expect(testStruct.id).to(equal(@5));
        expect(testStruct.x).to(equal(@50.0));
        expect(testStruct.y).to(equal(@60.0));
        expect(testStruct.width).to(equal(@500.0));
        expect(testStruct.height).to(equal(@600.0));
    });

    it(@"Should get correctly when initialized with a dict", ^{
        NSMutableDictionary *dict = [@{SDLNameId:@2,
                                       SDLNameX:@20,
                                       SDLNameY:@200,
                                       SDLNameWidth:@2000,
                                       SDLNameHeight:@3000} mutableCopy];
        SDLSpatialStruct *testStruct = [[SDLSpatialStruct alloc] initWithDictionary:dict];

        expect(testStruct.id).to(equal(@2));
        expect(testStruct.x).to(equal(@20));
        expect(testStruct.y).to(equal(@200));
        expect(testStruct.width).to(equal(@2000));
        expect(testStruct.height).to(equal(@3000));
    });

    it(@"Should return nil if not set", ^{
        SDLSpatialStruct *testStruct = [[SDLSpatialStruct alloc] init];

        expect(testStruct.id).to(beNil());
        expect(testStruct.x).to(beNil());
        expect(testStruct.y).to(beNil());
        expect(testStruct.width).to(beNil());
        expect(testStruct.height).to(beNil());
    });
});

QuickSpecEnd