|
| 1 | +// |
| 2 | +// EPAnnotationArrayTest.m |
| 3 | +// iOSMapExtension |
| 4 | +// |
| 5 | +// Created by Eriprando Pacces on 5/20/13. |
| 6 | +// Copyright (c) 2013 it.reply. All rights reserved. |
| 7 | +// |
| 8 | + |
| 9 | +#import "EPAnnotationArrayTest.h" |
| 10 | +#import "EPAnnotationArray.h" |
| 11 | +#import "EPPointOfInterest.h" |
| 12 | + |
| 13 | +@implementation EPAnnotationArrayTest { |
| 14 | + EPAnnotationArray *_annotationArray; |
| 15 | + EPPointOfInterest *_poi; |
| 16 | +} |
| 17 | + |
| 18 | +- (void)setUp |
| 19 | +{ |
| 20 | + _annotationArray = [[EPAnnotationArray alloc] init]; |
| 21 | + _poi = [[EPPointOfInterest alloc] initWithCoordinate:CLLocationCoordinate2DMake(22, 22)]; |
| 22 | +} |
| 23 | + |
| 24 | +- (void)testAddAnnotation |
| 25 | +{ |
| 26 | + [_annotationArray addAnnotation:_poi]; |
| 27 | + STAssertTrue([_annotationArray count] == 1, @"annotation array count shold be equal to 1"); |
| 28 | + EPPointOfInterest *poi = [_annotationArray allAnnotations][0]; |
| 29 | + STAssertTrue(poi.coordinate.latitude == 22 && poi.coordinate.longitude == 22, @"the array should contain annotation just added"); |
| 30 | +} |
| 31 | + |
| 32 | +- (void)testAddNonAnnotation |
| 33 | +{ |
| 34 | + STAssertThrows([_annotationArray addAnnotation:(id<MKAnnotation>)@"ciao"], @"should raise a bad argument exception"); |
| 35 | +} |
| 36 | + |
| 37 | +- (void)testAddBadAnnotations |
| 38 | +{ |
| 39 | + STAssertThrows([_annotationArray addAnnotations:(@[@"foo", @"meow", @"bar"])], @"should raise a bad argument exception"); |
| 40 | +} |
| 41 | + |
| 42 | +- (void)testAddAnnotations |
| 43 | +{ |
| 44 | + NSArray *annotations = [NSArray arrayWithObjects:_poi, _poi, _poi, nil]; |
| 45 | + [_annotationArray addAnnotations:annotations]; |
| 46 | + STAssertTrue([_annotationArray count] == 3, @"annotation collection should contain three elements"); |
| 47 | + EPPointOfInterest *poi = [_annotationArray allAnnotations][1]; |
| 48 | + STAssertTrue(poi.coordinate.longitude == 22 && poi.coordinate.longitude == 22, @"collection should contain annotation just added"); |
| 49 | +} |
| 50 | + |
| 51 | +- (void)testMutability |
| 52 | +{ |
| 53 | + [_annotationArray addAnnotation:_poi]; |
| 54 | + EPPointOfInterest *poi = [_annotationArray allAnnotations][0]; |
| 55 | + [poi setCoordinate:CLLocationCoordinate2DMake(1, 2)]; |
| 56 | + EPPointOfInterest *poi2 = [_annotationArray allAnnotations][0]; |
| 57 | + STAssertTrue(poi2.coordinate.longitude != poi.coordinate.longitude && poi2.coordinate.latitude != poi.coordinate.latitude, |
| 58 | + @"coordinates should be different"); |
| 59 | +} |
| 60 | + |
| 61 | +@end |
0 commit comments