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


#import <Foundation/Foundation.h>

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

#import "SDLFileType.h"
#import "SDLImageField.h"
#import "SDLImageFieldName.h"
#import "SDLImageResolution.h"
#import "SDLNames.h"


QuickSpecBegin(SDLImageFieldSpec)

SDLImageResolution* resolution = [[SDLImageResolution alloc] init];

describe(@"Getter/Setter Tests", ^ {
    it(@"Should set and get correctly", ^ {
        SDLImageField* testStruct = [[SDLImageField alloc] init];
        
        testStruct.name = SDLImageFieldNameTurnIcon;
        testStruct.imageTypeSupported = [@[SDLFileTypePNG, SDLFileTypeJPEG] copy];
        testStruct.imageResolution = resolution;
        
        expect(testStruct.name).to(equal(SDLImageFieldNameTurnIcon));
        expect(testStruct.imageTypeSupported).to(equal([@[SDLFileTypePNG, SDLFileTypeJPEG] copy]));
        expect(testStruct.imageResolution).to(equal(resolution));
    });
    
    it(@"Should get correctly when initialized", ^ {
        NSMutableDictionary* dict = [@{SDLNameName:SDLImageFieldNameTurnIcon,
                                       SDLNameImageTypeSupported:[@[SDLFileTypePNG, SDLFileTypeJPEG] copy],
                                       SDLNameImageResolution:resolution} mutableCopy];
        SDLImageField* testStruct = [[SDLImageField alloc] initWithDictionary:dict];
        
        expect(testStruct.name).to(equal(SDLImageFieldNameTurnIcon));
        expect(testStruct.imageTypeSupported).to(equal([@[SDLFileTypePNG, SDLFileTypeJPEG] copy]));
        expect(testStruct.imageResolution).to(equal(resolution));
    });
    
    it(@"Should return nil if not set", ^ {
        SDLImageField* testStruct = [[SDLImageField alloc] init];
        
        expect(testStruct.name).to(beNil());
        expect(testStruct.imageTypeSupported).to(beNil());
        expect(testStruct.imageResolution).to(beNil());
    });
});

QuickSpecEnd