-
Notifications
You must be signed in to change notification settings - Fork 644
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructured unit tests for undocumented objects and members to get m…
…ore specific testing in separate files. All unit tests specific to undocumented objects and members were moved to a separate file to keep test cases more understandable and up to the point.
- Loading branch information
Showing
4 changed files
with
135 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
// | ||
// GBProcessor-UndocumentedObjectsTesting.m | ||
// appledoc | ||
// | ||
// Created by Tomaz Kragelj on 5.12.10. | ||
// Copyright (C) 2010 Gentle Bytes. All rights reserved. | ||
// | ||
|
||
#import "GBDataObjects.h" | ||
#import "GBStore.h" | ||
#import "GBProcessor.h" | ||
|
||
@interface GBProcessorUndocumentedObjectsTesting : GHTestCase | ||
|
||
- (OCMockObject *)settingsProviderKeepObjects:(BOOL)objects keepMembers:(BOOL)members; | ||
- (GBClassData *)classWithComment:(BOOL)comment; | ||
- (NSArray *)registerMethodsOfCount:(NSUInteger)count withComment:(BOOL)comment toObject:(id<GBObjectDataProviding>)provider; | ||
- (NSString *)randomName; | ||
|
||
@end | ||
|
||
#pragma mark - | ||
|
||
@implementation GBProcessorUndocumentedObjectsTesting | ||
|
||
#pragma mark Undocumented objects handling | ||
|
||
- (void)testProcessObjectsFromStore_shouldKeepUncommentedObjectIfKeepObjectsIsYes { | ||
// setup | ||
GBProcessor *processor = [GBProcessor processorWithSettingsProvider:[self settingsProviderKeepObjects:YES keepMembers:NO]]; | ||
GBClassData *class = [self classWithComment:NO]; | ||
GBStore *store = [GBTestObjectsRegistry storeByPerformingSelector:@selector(registerClass:) withObject:class]; | ||
// execute | ||
[processor processObjectsFromStore:store]; | ||
// verify | ||
assertThatInteger([store.classes count], equalToInteger(1)); | ||
assertThatBool([store.classes containsObject:class], equalToBool(YES)); | ||
} | ||
|
||
- (void)testProcessObjectsFromStore_shouldKeepUncommentedObjectIfItHasCommentedMembers { | ||
// setup | ||
GBProcessor *processor = [GBProcessor processorWithSettingsProvider:[self settingsProviderKeepObjects:NO keepMembers:NO]]; | ||
GBClassData *class = [self classWithComment:NO]; | ||
GBStore *store = [GBTestObjectsRegistry storeByPerformingSelector:@selector(registerClass:) withObject:class]; | ||
[self registerMethodsOfCount:1 withComment:YES toObject:class]; | ||
[self registerMethodsOfCount:1 withComment:NO toObject:class]; | ||
// execute | ||
[processor processObjectsFromStore:store]; | ||
// verify | ||
assertThatInteger([store.classes count], equalToInteger(1)); | ||
assertThatBool([store.classes containsObject:class], equalToBool(YES)); | ||
} | ||
|
||
- (void)testProcessObjectsFromStore_shouldDeleteUncommentedObjectIfKeepObjectsIsNo { | ||
// setup | ||
GBProcessor *processor = [GBProcessor processorWithSettingsProvider:[self settingsProviderKeepObjects:NO keepMembers:NO]]; | ||
GBClassData *class = [self classWithComment:NO]; | ||
GBStore *store = [GBTestObjectsRegistry storeByPerformingSelector:@selector(registerClass:) withObject:class]; | ||
// execute | ||
[processor processObjectsFromStore:store]; | ||
// verify | ||
assertThatInteger([store.classes count], equalToInteger(0)); | ||
} | ||
|
||
#pragma mark Undocumented methods handling | ||
|
||
- (void)testProcessObjectsFromStore_shouldKeepUncommentedMethodsIfKeepMembersIsYes { | ||
// setup | ||
GBProcessor *processor = [GBProcessor processorWithSettingsProvider:[self settingsProviderKeepObjects:YES keepMembers:YES]]; | ||
GBClassData *class = [self classWithComment:YES]; | ||
NSArray *uncommented = [self registerMethodsOfCount:1 withComment:NO toObject:class]; | ||
GBStore *store = [GBTestObjectsRegistry storeByPerformingSelector:@selector(registerClass:) withObject:class]; | ||
// execute | ||
[processor processObjectsFromStore:store]; | ||
// verify | ||
NSArray *methods = [class.methods methods]; | ||
assertThatInteger([methods count], equalToInteger(1)); | ||
assertThatBool([methods containsObject:[uncommented objectAtIndex:0]], equalToBool(YES)); | ||
} | ||
|
||
- (void)testProcessObjectsFromStore_shouldDeleteUncommentedMethodsIfKeepMembersIsNo { | ||
// setup | ||
GBProcessor *processor = [GBProcessor processorWithSettingsProvider:[self settingsProviderKeepObjects:YES keepMembers:NO]]; | ||
GBClassData *class = [self classWithComment:YES]; | ||
NSArray *commented = [self registerMethodsOfCount:1 withComment:YES toObject:class]; | ||
NSArray *uncommented = [self registerMethodsOfCount:1 withComment:NO toObject:class]; | ||
GBStore *store = [GBTestObjectsRegistry storeByPerformingSelector:@selector(registerClass:) withObject:class]; | ||
// execute | ||
[processor processObjectsFromStore:store]; | ||
// verify | ||
NSArray *methods = [class.methods methods]; | ||
assertThatInteger([methods count], equalToInteger(1)); | ||
assertThatBool([methods containsObject:[commented objectAtIndex:0]], equalToBool(YES)); | ||
assertThatBool([methods containsObject:[uncommented objectAtIndex:0]], equalToBool(NO)); | ||
} | ||
|
||
#pragma mark Creation methods | ||
|
||
- (OCMockObject *)settingsProviderKeepObjects:(BOOL)objects keepMembers:(BOOL)members { | ||
OCMockObject *result = [GBTestObjectsRegistry mockSettingsProvider]; | ||
[GBTestObjectsRegistry settingsProvider:result keepObjects:objects keepMembers:members]; | ||
return result; | ||
} | ||
|
||
- (GBClassData *)classWithComment:(BOOL)comment { | ||
GBClassData *result = [GBClassData classDataWithName:[self randomName]]; | ||
if (comment) result.comment = [GBComment commentWithStringValue:@"comment"]; | ||
return result; | ||
} | ||
|
||
- (NSArray *)registerMethodsOfCount:(NSUInteger)count withComment:(BOOL)comment toObject:(id<GBObjectDataProviding>)provider { | ||
NSMutableArray *result = [NSMutableArray arrayWithCapacity:count]; | ||
for (NSUInteger i=0; i<count; i++) { | ||
GBMethodData *method = [GBTestObjectsRegistry instanceMethodWithNames:[self randomName], nil]; | ||
if (comment) method.comment = [GBComment commentWithStringValue:@"comment"]; | ||
if (provider) [provider.methods registerMethod:method]; | ||
[result addObject:method]; | ||
} | ||
return result; | ||
} | ||
|
||
- (NSString *)randomName { | ||
NSUInteger value = random(); | ||
return [NSString stringWithFormat:@"N%ld", value]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters