summaryrefslogtreecommitdiff
path: root/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLGetWaypointsResponseSpec.m
blob: 54e557050244393cdef05dc09d0f99eff614586b (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
//  SDLGetWaypointsResponseSpec.m
//

#import <Foundation/Foundation.h>

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

#import "SDLGetWaypointsResponse.h"

#import "SDLImage.h"
#import "SDLLocationCoordinate.h"
#import "SDLLocationDetails.h"
#import "SDLNames.h"
#import "SDLOasisAddress.h"

QuickSpecBegin(SDLGetWaypointsResponseSpec)

describe(@"Getter/Setter Tests", ^ {
    __block SDLGetWayPointsResponse* testResponse = nil;
    __block NSArray<SDLLocationDetails *>* someWaypoints = nil;
    
    describe(@"when initialized with init", ^{
        beforeEach(^{
            testResponse = [[SDLGetWayPointsResponse alloc] init];
        });
        
        context(@"when parameters are set correctly", ^{
            beforeEach(^{
                SDLLocationDetails* someLocation = [[SDLLocationDetails alloc] init];
                someLocation.coordinate = [[SDLLocationCoordinate alloc] init];
                someLocation.locationName = @"Livio";
                someLocation.locationDescription = @"A great place to work";
                someLocation.addressLines = @[@"3136 Hilton Rd", @"Ferndale, MI", @"48220"];
                someLocation.phoneNumber = @"248-591-0333";
                someLocation.locationImage = [[SDLImage alloc] init];
                someLocation.searchAddress = [[SDLOasisAddress alloc] init];
                
                someWaypoints = @[someLocation];
                
                testResponse.waypoints = someWaypoints;
            });
            
            // Since all the properties are immutable, a copy should be executed as a retain, which means they should be identical
            it(@"should get waypoints correctly", ^{
                expect(testResponse.waypoints).to(equal(someWaypoints));
                expect(testResponse.waypoints).to(beIdenticalTo(someWaypoints));
            });
        });
    });
    
    describe(@"when initialized with a dictionary", ^{
        context(@"when parameters are set correctly", ^{
            beforeEach(^{
                SDLLocationDetails* someLocation = [[SDLLocationDetails alloc] init];
                someLocation.coordinate = [[SDLLocationCoordinate alloc] init];
                someLocation.locationName = @"Livio";
                someLocation.locationDescription = @"A great place to work";
                someLocation.addressLines = @[@"3136 Hilton Rd", @"Ferndale, MI", @"48220"];
                someLocation.phoneNumber = @"248-591-0333";
                someLocation.locationImage = [[SDLImage alloc] init];
                someLocation.searchAddress = [[SDLOasisAddress alloc] init];
                
                someWaypoints = @[someLocation];
                
                NSDictionary *initDict = @{SDLNameResponse : @{
                                                   SDLNameParameters: @{
                                                           SDLNameWaypoints: someWaypoints
                                                           }
                                                   }
                                           };
                
                testResponse = [[SDLGetWayPointsResponse alloc] initWithDictionary:[NSMutableDictionary dictionaryWithDictionary:initDict]];
            });
            
            // Since all the properties are immutable, a copy should be executed as a retain, which means they should be identical
            it(@"should get waypoints correctly", ^{
                expect(testResponse.waypoints).to(equal(someWaypoints));
                expect(testResponse.waypoints).to(beIdenticalTo(someWaypoints));
            });
        });
        
        context(@"when parameters are not set", ^{
            beforeEach(^{
                NSDictionary *initDict = @{
                                           SDLNameRequest: @{
                                                   SDLNameParameters: @{}
                                                   }
                                           };
                
                testResponse = [[SDLGetWayPointsResponse alloc] initWithDictionary:[NSMutableDictionary dictionaryWithDictionary:initDict]];
            });
            
            it(@"should return nil for waypoints", ^{
                expect(testResponse.waypoints).to(beNil());
            });
        });
    });
});

QuickSpecEnd