Navigation Menu

Skip to content

Commit

Permalink
Added unit tests for validating inline links processing.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaz committed Feb 20, 2011
1 parent 1e1ad04 commit 2f7fb5b
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions Testing/GBCommentsProcessor-MarkdownTesting.m
Expand Up @@ -15,6 +15,7 @@ @interface GBCommentsProcessorMarkdownTesting : GBObjectsAssertor

- (GBCommentsProcessor *)defaultProcessor;
- (GBStore *)defaultStore;
- (GBStore *)storeWithDefaultObjects;
- (void)assertComment:(GBComment *)comment matchesLongDescMarkdown:(NSString *)first, ... NS_REQUIRES_NIL_TERMINATION;

@end
Expand Down Expand Up @@ -58,6 +59,63 @@ - (void)testProcessCommentWithContextStore_markdown_shouldConvertBug {
[self assertComment:comment matchesLongDescMarkdown:@"Some text", @"> %bug%\n> Another paragraph\n> \n> And another", nil];
}

#pragma mark Cross references handling

- (void)testProcessCommentWithContextStore_markdown_shouldKeepInlineTopLevelObjectsCrossRefsTexts {
// setup
GBStore *store = [self storeWithDefaultObjects];
GBCommentsProcessor *processor = [self defaultProcessor];
GBComment *comment1 = [GBComment commentWithStringValue:@"Class"];
GBComment *comment2 = [GBComment commentWithStringValue:@"Class(Category)"];
GBComment *comment3 = [GBComment commentWithStringValue:@"Protocol"];
GBComment *comment4 = [GBComment commentWithStringValue:@"Document"];
// execute
[processor processComment:comment1 withContext:nil store:store];
[processor processComment:comment2 withContext:nil store:store];
[processor processComment:comment3 withContext:nil store:store];
[processor processComment:comment4 withContext:nil store:store];
// verify
[self assertComment:comment1 matchesLongDescMarkdown:@"[Class](Classes/Class.html)", nil];
[self assertComment:comment2 matchesLongDescMarkdown:@"[Class(Category)](Categories/Class(Category).html)", nil];
[self assertComment:comment3 matchesLongDescMarkdown:@"[Protocol](Protocols/Protocol.html)", nil];
[self assertComment:comment4 matchesLongDescMarkdown:@"[Document](docs/Document.html)", nil];
}

- (void)testProcessCommentWithContextStore_markdown_shouldKeepInlineLocalMemberCrossRefsTexts {
// setup
GBStore *store = [self storeWithDefaultObjects];
GBCommentsProcessor *processor = [self defaultProcessor];
GBComment *comment1 = [GBComment commentWithStringValue:@"instanceMethod:"];
GBComment *comment2 = [GBComment commentWithStringValue:@"classMethod:"];
GBComment *comment3 = [GBComment commentWithStringValue:@"value"];
// execute
id context = [store.classes anyObject];
[processor processComment:comment1 withContext:context store:store];
[processor processComment:comment2 withContext:context store:store];
[processor processComment:comment3 withContext:context store:store];
// verify
[self assertComment:comment1 matchesLongDescMarkdown:@"[instanceMethod:](#//api/name/instanceMethod:)", nil];
[self assertComment:comment2 matchesLongDescMarkdown:@"[classMethod:](#//api/name/classMethod:)", nil];
[self assertComment:comment3 matchesLongDescMarkdown:@"[value](#//api/name/value)", nil];
}

- (void)testProcessCommentWithContextStore_markdown_shouldKeepInlineRemoteMemberCrossRefsTexts {
// setup
GBStore *store = [self storeWithDefaultObjects];
GBCommentsProcessor *processor = [self defaultProcessor];
GBComment *comment1 = [GBComment commentWithStringValue:@"[Class instanceMethod:]"];
GBComment *comment2 = [GBComment commentWithStringValue:@"[Class classMethod:]"];
GBComment *comment3 = [GBComment commentWithStringValue:@"[Class value]"];
// execute
[processor processComment:comment1 withContext:nil store:store];
[processor processComment:comment2 withContext:nil store:store];
[processor processComment:comment3 withContext:nil store:store];
// verify
[self assertComment:comment1 matchesLongDescMarkdown:@"[[Class instanceMethod:]](Classes/Class.html#//api/name/instanceMethod:)", nil];
[self assertComment:comment2 matchesLongDescMarkdown:@"[[Class classMethod:]](Classes/Class.html#//api/name/classMethod:)", nil];
[self assertComment:comment3 matchesLongDescMarkdown:@"[[Class value]](Classes/Class.html#//api/name/value)", nil];
}

#pragma mark Creation methods

- (GBCommentsProcessor *)defaultProcessor {
Expand All @@ -68,6 +126,17 @@ - (GBStore *)defaultStore {
return [GBTestObjectsRegistry store];
}

- (GBStore *)storeWithDefaultObjects {
GBMethodData *instanceMethod = [GBTestObjectsRegistry instanceMethodWithNames:@"instanceMethod", nil];
GBMethodData *classMethod = [GBTestObjectsRegistry classMethodWithNames:@"classMethod", nil];
GBMethodData *property = [GBTestObjectsRegistry propertyMethodWithArgument:@"value"];
GBClassData *class = [GBTestObjectsRegistry classWithName:@"Class" methods:instanceMethod, classMethod, property, nil];
GBCategoryData *category = [GBCategoryData categoryDataWithName:@"Category" className:@"Class"];
GBProtocolData *protocol = [GBProtocolData protocolDataWithName:@"Protocol"];
GBDocumentData *document = [GBDocumentData documentDataWithContents:@"c" path:@"Document.ext"];
return [GBTestObjectsRegistry storeWithObjects:class, category, protocol, document, nil];
}

#pragma mark Assertion methods

- (void)assertComment:(GBComment *)comment matchesLongDescMarkdown:(NSString *)first, ... {
Expand Down

0 comments on commit 2f7fb5b

Please sign in to comment.