Reputation: 27407
I'm trying to verify that my AppDelegate object has a specific protocol
@interface AppDelegate : UIResponder <UIApplicationDelegate>
Currently the test below adds some value but does a custom assert exist that would allow me to verify what protocols a specific object has?
- (void)testAppDelegateIsUiResponder
{
AppDelegate *appDelegate = [[AppDelegate alloc] init];
STAssertTrue([appDelegate isKindOfClass:[UIResponder class]], @"AppDelegate is not UIResponder");
}
Upvotes: 1
Views: 391
Reputation: 27407
@Jim mentioned another question that had the answer I was looking for. I simply added an assert true statement to get my assertion to fail as expected
- (void)testAppDelegateIsUiResponder
{
AppDelegate *appDelegate = [[AppDelegate alloc] init];
STAssertTrue([appDelegate isKindOfClass:[UIResponder class]], @"AppDelegate is not UIResponder");
}
- (void)testAppDelegateHasUiApplicationDelegateProtocol
{
AppDelegate *appDelegate = [[AppDelegate alloc] init];
STAssertTrue([appDelegate conformsToProtocol:@protocol(UIApplicationDelegate)], @"Protocol Missing");
}
Upvotes: 0
Reputation: 1441
As indicated by the comment - this does the trick: [someObject conformsToProtocol:@protocol(WhatEver)];
Upvotes: 2