diff options
-rw-r--r-- | SmartDeviceLink/SDLAddCommand.h | 2 | ||||
-rw-r--r-- | SmartDeviceLink/SDLAddCommand.m | 2 | ||||
-rw-r--r-- | SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAddCommandSpec.m | 81 |
3 files changed, 80 insertions, 5 deletions
diff --git a/SmartDeviceLink/SDLAddCommand.h b/SmartDeviceLink/SDLAddCommand.h index f4eed257e..f7c494df9 100644 --- a/SmartDeviceLink/SDLAddCommand.h +++ b/SmartDeviceLink/SDLAddCommand.h @@ -49,7 +49,7 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands handler:(nullable SDLRPCCommandNotificationHandler)handler; -- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands menuName:(NSString *)menuName handler:(SDLRPCCommandNotificationHandler)handler; +- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands menuName:(NSString *)menuName handler:(nullable SDLRPCCommandNotificationHandler)handler; - (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands menuName:(NSString *)menuName parentId:(UInt32)parentId position:(UInt16)position iconValue:(nullable NSString *)iconValue iconType:(nullable SDLImageType)iconType handler:(nullable SDLRPCCommandNotificationHandler)handler; diff --git a/SmartDeviceLink/SDLAddCommand.m b/SmartDeviceLink/SDLAddCommand.m index b97b0e402..28c60219d 100644 --- a/SmartDeviceLink/SDLAddCommand.m +++ b/SmartDeviceLink/SDLAddCommand.m @@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN return self; } -- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands menuName:(NSString *)menuName handler:(SDLRPCCommandNotificationHandler)handler { +- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands menuName:(NSString *)menuName handler:(nullable SDLRPCCommandNotificationHandler)handler { self = [self initWithId:commandId vrCommands:vrCommands handler:handler]; if (!self) { return nil; diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAddCommandSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAddCommandSpec.m index 0119291d9..919932f18 100644 --- a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAddCommandSpec.m +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAddCommandSpec.m @@ -15,10 +15,10 @@ QuickSpecBegin(SDLAddCommandSpec) -SDLMenuParams* menu = [[SDLMenuParams alloc] init]; -SDLImage* image = [[SDLImage alloc] init]; - describe(@"Getter/Setter Tests", ^ { + SDLMenuParams* menu = [[SDLMenuParams alloc] init]; + SDLImage* image = [[SDLImage alloc] init]; + it(@"Should set and get correctly", ^ { SDLAddCommand* testRequest = [[SDLAddCommand alloc] init]; @@ -60,4 +60,79 @@ describe(@"Getter/Setter Tests", ^ { }); }); +describe(@"initializers", ^{ + __block SDLAddCommand *testCommand = nil; + __block UInt32 commandId = 1234; + __block NSArray<NSString *> *vrCommands = @[@"commands"]; + __block NSString *menuName = @"Menu Name"; + void (^handler)(SDLOnCommand *) = ^(SDLOnCommand *command) {}; + + beforeEach(^{ + testCommand = nil; + }); + + context(@"initWithHandler", ^{ + it(@"should initialize correctly", ^{ + testCommand = [[SDLAddCommand alloc] initWithHandler:handler]; + + expect(testCommand).toNot(beNil()); + expect(testCommand.vrCommands).to(beNil()); + expect(testCommand.menuParams).to(beNil()); + expect(testCommand.cmdIcon).to(beNil()); + }); + }); + + context(@"initWithId:vrCommands:handler:", ^{ + it(@"should initialize correctly", ^{ + testCommand = [[SDLAddCommand alloc] initWithId:commandId vrCommands:vrCommands handler:nil]; + + expect(testCommand.cmdID).to(equal(commandId)); + expect(testCommand.vrCommands).to(equal(vrCommands)); + expect(testCommand.menuParams).to(beNil()); + expect(testCommand.cmdIcon).to(beNil()); + }); + }); + + context(@"initWithId:vrCommands:menuName:handler:", ^{ + it(@"should initialize correctly", ^{ + testCommand = [[SDLAddCommand alloc] initWithId:commandId vrCommands:vrCommands menuName:menuName handler:nil]; + + expect(testCommand.cmdID).to(equal(commandId)); + expect(testCommand.vrCommands).to(equal(vrCommands)); + expect(testCommand.menuParams).toNot(beNil()); + expect(testCommand.cmdIcon).to(beNil()); + }); + }); + + context(@"initWithId:vrCommands:menuName:parentId:position:iconValue:iconType:handler:", ^{ + __block UInt32 parentId = 1234; + __block UInt16 position = 2; + + it(@"should initialize with an image", ^{ + NSString *iconValue = @"Icon"; + SDLImageType imageType = SDLImageTypeDynamic; + + testCommand = [[SDLAddCommand alloc] initWithId:commandId vrCommands:vrCommands menuName:menuName parentId:parentId position:position iconValue:iconValue iconType:imageType handler:nil]; + + expect(testCommand.cmdID).to(equal(commandId)); + expect(testCommand.vrCommands).to(equal(vrCommands)); + expect(testCommand.menuParams.menuName).toNot(beNil()); + expect(testCommand.menuParams.parentID).to(equal(parentId)); + expect(testCommand.menuParams.position).to(equal(position)); + expect(testCommand.cmdIcon).toNot(beNil()); + }); + + it(@"should initialize without an image", ^{ + testCommand = [[SDLAddCommand alloc] initWithId:commandId vrCommands:vrCommands menuName:menuName parentId:parentId position:position iconValue:nil iconType:nil handler:nil]; + + expect(testCommand.cmdID).to(equal(commandId)); + expect(testCommand.vrCommands).to(equal(vrCommands)); + expect(testCommand.menuParams.menuName).toNot(beNil()); + expect(testCommand.menuParams.parentID).to(equal(parentId)); + expect(testCommand.menuParams.position).to(equal(position)); + expect(testCommand.cmdIcon).to(beNil()); + }); + }); +}); + QuickSpecEnd |