summaryrefslogtreecommitdiff
path: root/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTemplateColorSchemeSpec.m
blob: 48112cf6f5a95c58e6693540ce0fdc0bbbe6c216 (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
#import <Quick/Quick.h>
#import <Nimble/Nimble.h>

#import "SDLRGBColor.h"
#import "SDLTemplateColorScheme.h"

#import "SDLNames.h"

QuickSpecBegin(SDLTemplateColorSchemeSpec)

describe(@"TemplateColor Tests", ^{
    __block SDLRGBColor *testRed = nil;
    __block SDLRGBColor *testGreen = nil;
    __block SDLRGBColor *testBlue = nil;

    beforeEach(^{
        testRed = [[SDLRGBColor alloc] initWithRed:255 green:0 blue:0];
        testGreen = [[SDLRGBColor alloc] initWithRed:0 green:255 blue:0];
        testBlue = [[SDLRGBColor alloc] initWithRed:0 green:0 blue:255];
    });

    it(@"Should set and get correctly", ^{
        SDLTemplateColorScheme *testStruct = [[SDLTemplateColorScheme alloc] init];

        testStruct.primaryColor = testRed;
        testStruct.secondaryColor = testGreen;
        testStruct.backgroundColor = testBlue;

        expect(testStruct.primaryColor).to(equal(testRed));
        expect(testStruct.secondaryColor).to(equal(testGreen));
        expect(testStruct.backgroundColor).to(equal(testBlue));
    });

    it(@"Should get correctly when initialized with parameters", ^{
        SDLTemplateColorScheme *testStruct = [[SDLTemplateColorScheme alloc] initWithPrimaryRGBColor:testRed secondaryRGBColor:testGreen backgroundRGBColor:testBlue];

        expect(testStruct.primaryColor).to(equal(testRed));
        expect(testStruct.secondaryColor).to(equal(testGreen));
        expect(testStruct.backgroundColor).to(equal(testBlue));
    });

    it(@"Should get correctly when initialized with colors", ^{
        UIColor *testRedColor = [UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:1.0];
        UIColor *testGreenColor = [UIColor colorWithRed:0.0 green:1.0 blue:0.0 alpha:1.0];
        UIColor *testBlueColor = [UIColor colorWithRed:0.0 green:0.0 blue:1.0 alpha:1.0];
        SDLTemplateColorScheme *testStruct = [[SDLTemplateColorScheme alloc] initWithPrimaryColor:testRedColor secondaryColor:testGreenColor backgroundColor:testBlueColor];

        expect(testStruct.primaryColor).to(equal(testRed));
        expect(testStruct.secondaryColor).to(equal(testGreen));
        expect(testStruct.backgroundColor).to(equal(testBlue));
    });

    it(@"Should get correctly when initialized with a dict", ^{
        NSDictionary *dict = @{SDLNameRed: @0,
                               SDLNameGreen: @100,
                               SDLNameBlue: @255};
        SDLRGBColor *testStruct = [[SDLRGBColor alloc] initWithDictionary:dict];

        expect(testStruct.red).to(equal(@0));
        expect(testStruct.green).to(equal(@100));
        expect(testStruct.blue).to(equal(@255));
    });

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

        expect(testStruct.red).to(beNil());
        expect(testStruct.green).to(beNil());
        expect(testStruct.blue).to(beNil());
    });
});

QuickSpecEnd