blob: 7b896ca2828f685491d59ec3c0ac0868f7a1d7e7 (
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
|
//
// SDLWeatherServiceDataSpec.m
// SmartDeviceLinkTests
//
// Created by Nicole on 2/8/19.
// Copyright © 2019 smartdevicelink. All rights reserved.
//
#import <Quick/Quick.h>
#import <Nimble/Nimble.h>
#import "SDLLocationDetails.h"
#import "SDLNames.h"
#import "SDLWeatherData.h"
#import "SDLWeatherAlert.h"
#import "SDLWeatherServiceData.h"
QuickSpecBegin(SDLWeatherServiceDataSpec)
describe(@"Getter/Setter Tests", ^{
__block SDLLocationDetails *testLocation = nil;
__block SDLWeatherData *testCurrentForecast = nil;
__block NSArray<SDLWeatherData *> *testMinuteForecast = nil;
__block NSArray<SDLWeatherData *> *testHourlyForecast = nil;
__block NSArray<SDLWeatherData *> *testMultidayForecast = nil;
__block NSArray<SDLWeatherAlert *> *testAlerts = nil;
beforeEach(^{
testLocation = [[SDLLocationDetails alloc] init];
testLocation.locationName = @"testLocationName";
SDLWeatherData *testWeatherDataA = [[SDLWeatherData alloc] initWithDictionary:@{SDLNameWeatherSummary:@"testWeatherDataA"}];
SDLWeatherData *testWeatherDataB = [[SDLWeatherData alloc] initWithDictionary:@{SDLNameWeatherSummary:@"testWeatherDataB"}];
SDLWeatherData *testWeatherDataC = [[SDLWeatherData alloc] initWithDictionary:@{SDLNameWeatherSummary:@"testWeatherDataC"}];
testCurrentForecast = testWeatherDataA;
testMinuteForecast = @[testWeatherDataA];
testHourlyForecast = @[testWeatherDataB, testWeatherDataA];
testMultidayForecast = @[testWeatherDataA, testWeatherDataC];
SDLWeatherAlert *testWeatherAlertA = [[SDLWeatherAlert alloc] initWithDictionary:@{SDLNameTitle:@"testWeatherAlertA"}];
testAlerts = @[testWeatherAlertA];
});
it(@"Should set and get correctly", ^{
SDLWeatherServiceData *testStruct = [[SDLWeatherServiceData alloc] init];
testStruct.location = testLocation;
testStruct.currentForecast = testCurrentForecast;
testStruct.minuteForecast = testMinuteForecast;
testStruct.hourlyForecast = testHourlyForecast;
testStruct.multidayForecast = testMultidayForecast;
testStruct.alerts = testAlerts;
expect(testStruct.location).to(equal(testLocation));
expect(testStruct.currentForecast).to(equal(testCurrentForecast));
expect(testStruct.minuteForecast).to(equal(testMinuteForecast));
expect(testStruct.hourlyForecast).to(equal(testHourlyForecast));
expect(testStruct.multidayForecast).to(equal(testMultidayForecast));
expect(testStruct.alerts).to(equal(testAlerts));
});
it(@"Should get correctly when initialized with a dictionary", ^{
NSDictionary *dict = @{SDLNameLocation:testLocation,
SDLNameCurrentForecast:testCurrentForecast,
SDLNameMinuteForecast:testMinuteForecast,
SDLNameHourlyForecast:testHourlyForecast,
SDLNameMultidayForecast:testMultidayForecast,
SDLNameAlerts:testAlerts
};
SDLWeatherServiceData *testStruct = [[SDLWeatherServiceData alloc] initWithDictionary:dict];
expect(testStruct.location).to(equal(testLocation));
expect(testStruct.currentForecast).to(equal(testCurrentForecast));
expect(testStruct.minuteForecast).to(equal(testMinuteForecast));
expect(testStruct.hourlyForecast).to(equal(testHourlyForecast));
expect(testStruct.multidayForecast).to(equal(testMultidayForecast));
expect(testStruct.alerts).to(equal(testAlerts));
});
it(@"Should return nil if not set", ^{
SDLWeatherServiceData *testStruct = [[SDLWeatherServiceData alloc] init];
expect(testStruct.location).to(beNil());
expect(testStruct.currentForecast).to(beNil());
expect(testStruct.minuteForecast).to(beNil());
expect(testStruct.hourlyForecast).to(beNil());
expect(testStruct.multidayForecast).to(beNil());
expect(testStruct.alerts).to(beNil());
});
});
QuickSpecEnd
|