This replaces the integration test of `addSource` when duplicate identifiers are used in `MGLSourceTests` with a more direct unit test in the style class's unit test file `MGLStyleTests`. Although tests of the case where the same instance are actually integration tests where the source instance itself throws, it is easier to test all of this functionality in one place using the public facing MGLStyle API.
25 lines
734 B
Objective-C
25 lines
734 B
Objective-C
#import "MGLMapViewTests.h"
|
|
|
|
@interface MGLSourceTests : MGLMapViewTests
|
|
|
|
@end
|
|
|
|
@implementation MGLSourceTests
|
|
|
|
- (void)testDuplicateSources {
|
|
MGLVectorSource *source1 = [[MGLVectorSource alloc] initWithIdentifier:@"my-source" URL:[NSURL URLWithString:@"mapbox://mapbox.mapbox-terrain-v2"]];
|
|
MGLVectorSource *source2 = [[MGLVectorSource alloc] initWithIdentifier:@"my-source" URL:[NSURL URLWithString:@"mapbox://mapbox.mapbox-terrain-v2"]];
|
|
|
|
[self.mapView.style addSource: source1];
|
|
|
|
@try {
|
|
[self.mapView.style addSource: source2];
|
|
XCTFail(@"Should not have reached this point");
|
|
}
|
|
@catch (NSException *e) {
|
|
XCTAssertNotNil(e, @"Should have thrown an exception");
|
|
}
|
|
}
|
|
|
|
@end
|