Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 67 lines (57 sloc) 2.989 kb
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
//
// GBProtocolDataTesting.m
// appledoc
//
// Created by Tomaz Kragelj on 28.7.10.
// Copyright (C) 2010 Gentle Bytes. All rights reserved.
//

#import "GBDataObjects.h"

@interface GBProtocolDataTesting : GHTestCase
@end

@implementation GBProtocolDataTesting

- (void)testMergeDataFromObject_shouldMergeImplementationDetails {
// setup - protocols don't merge any data, except they need to send base class merging message!
GBProtocolData *original = [GBProtocolData protocolDataWithName:@"MyProtocol"];
GBProtocolData *source = [GBProtocolData protocolDataWithName:@"MyProtocol"];
[source registerSourceInfo:[GBSourceInfo infoWithFilename:@"file" lineNumber:1]];
// execute
[original mergeDataFromObject:source];
// verify - simple testing here, fully tested in GBModelBaseTesting!
assertThatInteger([original.sourceInfos count], equalToInteger(1));
}

- (void)testMergeDataFromObject_shouldMergeAdoptedProtocolsAndPreserveSourceData {
//setup - only basic handling is done here; details are tested within GBAdoptedProtocolsProviderTesting!
GBProtocolData *original = [GBProtocolData protocolDataWithName:@"MyProtocol"];
[original.adoptedProtocols registerProtocol:[GBProtocolData protocolDataWithName:@"P1"]];
[original.adoptedProtocols registerProtocol:[GBProtocolData protocolDataWithName:@"P2"]];
GBProtocolData *source = [GBProtocolData protocolDataWithName:@"MyProtocol"];
[source.adoptedProtocols registerProtocol:[GBProtocolData protocolDataWithName:@"P1"]];
[source.adoptedProtocols registerProtocol:[GBProtocolData protocolDataWithName:@"P3"]];
// execute
[original mergeDataFromObject:source];
// verify
assertThatInteger([[original.adoptedProtocols protocols] count], equalToInteger(3));
assertThatInteger([[source.adoptedProtocols protocols] count], equalToInteger(2));
}

- (void)testMergeDataFromObject_shouldMergeMethodsAndPreserveSourceData {
//setup - only basic handling is done here; details are tested within GBIvarsProviderTesting!
GBProtocolData *original = [GBProtocolData protocolDataWithName:@"MyProtocol"];
[original.methods registerMethod:[GBTestObjectsRegistry instanceMethodWithNames:@"m1", nil]];
[original.methods registerMethod:[GBTestObjectsRegistry instanceMethodWithNames:@"m2", nil]];
GBProtocolData *source = [GBProtocolData protocolDataWithName:@"MyProtocol"];
[source.methods registerMethod:[GBTestObjectsRegistry instanceMethodWithNames:@"m1", nil]];
[source.methods registerMethod:[GBTestObjectsRegistry instanceMethodWithNames:@"m3", nil]];
// execute
[original mergeDataFromObject:source];
// verify
assertThatInteger([[original.methods methods] count], equalToInteger(3));
assertThatInteger([[source.methods methods] count], equalToInteger(2));
}

#pragma mark Helper methods

- (void)testIsTopLevelObject_shouldReturnYES {
// setup & execute
GBProtocolData *protocol = [GBProtocolData protocolDataWithName:@"Protocol"];
// verify
assertThatBool(protocol.isTopLevelObject, equalToBool(YES));
}

@end
Something went wrong with that request. Please try again.