summaryrefslogtreecommitdiff
path: root/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLMediaServiceDataSpec.m
blob: dc2731c470a98cf5a16467e0763a1232deb642d2 (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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//
//  SDLMediaServiceDataSpec.m
//  SmartDeviceLinkTests
//
//  Created by Nicole on 2/8/19.
//  Copyright © 2019 smartdevicelink. All rights reserved.
//

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

#import "SDLMediaServiceData.h"
#import "SDLMediaType.h"
#import "SDLNames.h"

QuickSpecBegin(SDLMediaServiceDataSpec)

describe(@"Getter/Setter Tests", ^{
    __block SDLMediaType testMediaType = nil;
    __block NSString *testMediaTitle = nil;
    __block NSString *testMediaArtist = nil;
    __block NSString *testMediaAlbum = nil;
    __block NSString *testPlaylistName = nil;
    __block BOOL testIsExplicit = nil;
    __block int testTrackPlaybackProgress = 45;
    __block int testTrackPlaybackDuration = 3;
    __block int testQueuePlaybackProgress = 21;
    __block int testQueuePlaybackDuration = 5;
    __block int testQueueCurrentTrackNumber = 3;
    __block int testQueueTotalTrackCount = 56;

    beforeEach(^{
        testMediaType = SDLMediaTypePodcast;
        testMediaTitle = @"testMediaTitle";
        testMediaArtist = @"testMediaArtist";
        testMediaAlbum = @"testMediaAlbum";
        testPlaylistName = @"testPlaylistName";
        testIsExplicit = true;
    });

    it(@"Should set and get correctly", ^{
        SDLMediaServiceData *testStruct = [[SDLMediaServiceData alloc] init];
        testStruct.mediaType = testMediaType;
        testStruct.mediaTitle = testMediaTitle;
        testStruct.mediaArtist = testMediaArtist;
        testStruct.mediaAlbum = testMediaAlbum;
        testStruct.playlistName = testPlaylistName;
        testStruct.isExplicit = @(testIsExplicit);
        testStruct.trackPlaybackProgress = @(testTrackPlaybackProgress);
        testStruct.trackPlaybackDuration = @(testTrackPlaybackDuration);
        testStruct.queuePlaybackProgess = @(testQueuePlaybackProgress);
        testStruct.queuePlaybackDuration = @(testQueuePlaybackDuration);
        testStruct.queueCurrentTrackNumber = @(testQueueCurrentTrackNumber);
        testStruct.queueTotalTrackCount = @(testQueueTotalTrackCount);

        expect(testStruct.mediaType).to(equal(testMediaType));
        expect(testStruct.mediaTitle).to(equal(testMediaTitle));
        expect(testStruct.mediaArtist).to(equal(testMediaArtist));
        expect(testStruct.mediaAlbum).to(equal(testMediaAlbum));
        expect(testStruct.playlistName).to(equal(testPlaylistName));
        expect(testStruct.isExplicit).to(equal(testIsExplicit));
        expect(testStruct.trackPlaybackProgress).to(equal(testTrackPlaybackProgress));
        expect(testStruct.trackPlaybackDuration).to(equal(testTrackPlaybackDuration));
        expect(testStruct.queuePlaybackProgess).to(equal(testQueuePlaybackProgress));
        expect(testStruct.queuePlaybackDuration).to(equal(testQueuePlaybackDuration));
        expect(testStruct.queueCurrentTrackNumber).to(equal(testQueueCurrentTrackNumber));
        expect(testStruct.queueTotalTrackCount).to(equal(testQueueTotalTrackCount));
    });

    it(@"Should get correctly when initialized with a dictionary", ^{
        NSDictionary *dict = @{SDLNameMediaType:testMediaType,
                               SDLNameMediaTitle:testMediaTitle,
                               SDLNameMediaArtist:testMediaArtist,
                               SDLNameMediaAlbum:testMediaAlbum,
                               SDLNamePlaylistName:testPlaylistName,
                               SDLNameIsExplicit:@(testIsExplicit),
                               SDLNameTrackPlaybackProgress:@(testTrackPlaybackProgress),
                               SDLNameTrackPlaybackDuration:@(testTrackPlaybackDuration),
                               SDLNameQueuePlaybackProgess:@(testQueuePlaybackProgress),
                               SDLNameQueuePlaybackDuration:@(testQueuePlaybackDuration),
                               SDLNameQueueCurrentTrackNumber:@(testQueueCurrentTrackNumber),
                               SDLNameQueueTotalTrackCount:@(testQueueTotalTrackCount)
                               };
        SDLMediaServiceData *testStruct = [[SDLMediaServiceData alloc] initWithDictionary:dict];

        expect(testStruct.mediaType).to(equal(testMediaType));
        expect(testStruct.mediaTitle).to(equal(testMediaTitle));
        expect(testStruct.mediaArtist).to(equal(testMediaArtist));
        expect(testStruct.mediaAlbum).to(equal(testMediaAlbum));
        expect(testStruct.playlistName).to(equal(testPlaylistName));
        expect(testStruct.isExplicit).to(equal(testIsExplicit));
        expect(testStruct.trackPlaybackProgress).to(equal(testTrackPlaybackProgress));
        expect(testStruct.trackPlaybackDuration).to(equal(testTrackPlaybackDuration));
        expect(testStruct.queuePlaybackProgess).to(equal(testQueuePlaybackProgress));
        expect(testStruct.queuePlaybackDuration).to(equal(testQueuePlaybackDuration));
        expect(testStruct.queueCurrentTrackNumber).to(equal(testQueueCurrentTrackNumber));
        expect(testStruct.queueTotalTrackCount).to(equal(testQueueTotalTrackCount));
    });

    it(@"Should get correctly when initialized with initWithMediaType:mediaTitle:mediaArtist:mediaAlbum:playlistName:isExplicit:trackPlaybackProgress:trackPlaybackDuration:queuePlaybackProgess:queuePlaybackDuration:queueCurrentTrackNumber:queueTotalTrackCount:", ^{
        SDLMediaServiceData *testStruct = [[SDLMediaServiceData alloc] initWithMediaType:testMediaType mediaTitle:testMediaTitle mediaArtist:testMediaArtist mediaAlbum:testMediaAlbum playlistName:testPlaylistName isExplicit:testIsExplicit trackPlaybackProgress:testTrackPlaybackProgress trackPlaybackDuration:testTrackPlaybackDuration queuePlaybackProgess:testQueuePlaybackProgress queuePlaybackDuration:testQueuePlaybackDuration queueCurrentTrackNumber:testQueueCurrentTrackNumber queueTotalTrackCount:testQueueTotalTrackCount];

        expect(testStruct.mediaType).to(equal(testMediaType));
        expect(testStruct.mediaTitle).to(equal(testMediaTitle));
        expect(testStruct.mediaArtist).to(equal(testMediaArtist));
        expect(testStruct.mediaAlbum).to(equal(testMediaAlbum));
        expect(testStruct.playlistName).to(equal(testPlaylistName));
        expect(testStruct.isExplicit).to(equal(testIsExplicit));
        expect(testStruct.trackPlaybackProgress).to(equal(testTrackPlaybackProgress));
        expect(testStruct.trackPlaybackDuration).to(equal(testTrackPlaybackDuration));
        expect(testStruct.queuePlaybackProgess).to(equal(testQueuePlaybackProgress));
        expect(testStruct.queuePlaybackDuration).to(equal(testQueuePlaybackDuration));
        expect(testStruct.queueCurrentTrackNumber).to(equal(testQueueCurrentTrackNumber));
        expect(testStruct.queueTotalTrackCount).to(equal(testQueueTotalTrackCount));
    });

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

        expect(testStruct.mediaType).to(beNil());
        expect(testStruct.mediaTitle).to(beNil());
        expect(testStruct.mediaArtist).to(beNil());
        expect(testStruct.mediaAlbum).to(beNil());
        expect(testStruct.playlistName).to(beNil());
        expect(testStruct.isExplicit).to(beNil());
        expect(testStruct.trackPlaybackProgress).to(beNil());
        expect(testStruct.trackPlaybackDuration).to(beNil());
        expect(testStruct.queuePlaybackProgess).to(beNil());
        expect(testStruct.queuePlaybackDuration).to(beNil());
        expect(testStruct.queueCurrentTrackNumber).to(beNil());
        expect(testStruct.queueTotalTrackCount).to(beNil());
    });
});

QuickSpecEnd