Skip to content

Commit 3ccb1d0

Browse files
author
Joey Lorich
committed
Merge in testing
2 parents 5496a68 + 5d759e2 commit 3ccb1d0

28 files changed

Lines changed: 1290 additions & 76 deletions
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//
2+
// CSNilAdditionsTests.m
3+
// EasyReader
4+
//
5+
// Created by Alfredo Uribe on 4/17/14.
6+
// Copyright (c) 2014 Cloudspace. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
#import "EZRBaseCategoryTests.h"
11+
#import "NSObject+CSNilAdditions.h"
12+
13+
@interface CSNilAdditionsTests : EZRBaseCategoryTests
14+
{
15+
NSObject *object;
16+
}
17+
@end
18+
19+
@implementation CSNilAdditionsTests
20+
21+
- (void)setUp
22+
{
23+
[super setUp];
24+
}
25+
26+
- (void)tearDown
27+
{
28+
[super tearDown];
29+
}
30+
31+
- (void)testIsBlankWithSet
32+
{
33+
NSSet *toTest = [NSSet setWithArray:@[]];
34+
XCTAssertTrue([toTest isBlank], @"");
35+
}
36+
37+
- (void)testIsBlankWithArray
38+
{
39+
XCTAssertTrue([@[] isBlank], @"");
40+
}
41+
42+
- (void)testIsBlankWithEmptyString
43+
{
44+
XCTAssertTrue([@"" isBlank], @"");
45+
}
46+
47+
- (void)testIsBlankWithNull
48+
{
49+
XCTAssertTrue([[NSNull null] isBlank], @"");
50+
}
51+
52+
@end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// EZRBaseCategoryTests.h
3+
// EasyReader
4+
//
5+
// Created by Alfredo Uribe on 4/17/14.
6+
// Copyright (c) 2014 Cloudspace. All rights reserved.
7+
//
8+
9+
#import "CSBaseTestCase.h"
10+
11+
@interface EZRBaseCategoryTests : CSBaseTestCase
12+
{
13+
NSBundle *bundle;
14+
id mockAPIClient;
15+
id mockObserver;
16+
}
17+
@end
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// EZRBaseCategoryTests.m
3+
// EasyReader
4+
//
5+
// Created by Alfredo Uribe on 4/17/14.
6+
// Copyright (c) 2014 Cloudspace. All rights reserved.
7+
//
8+
9+
#import "EZRBaseCategoryTests.h"
10+
#import "APIClient.h"
11+
12+
@implementation EZRBaseCategoryTests
13+
14+
- (void)setUp
15+
{
16+
mockAPIClient = [OCMockObject mockForClass:[APIClient class]];
17+
mockObserver = [OCMockObject observerMock];
18+
19+
[APIClient setSharedClient:mockAPIClient];
20+
21+
// Set up core data
22+
[MagicalRecord setupCoreDataStackWithInMemoryStore];
23+
}
24+
25+
26+
- (void)tearDown
27+
{
28+
// Clean up core data
29+
[MagicalRecord cleanUp];
30+
31+
[super tearDown];
32+
}
33+
34+
@end
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//
2+
// EZRFeedImageAdditions.m
3+
// EasyReader
4+
//
5+
// Created by Alfredo Uribe on 4/17/14.
6+
// Copyright (c) 2014 Cloudspace. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
#import "EZRBaseCategoryTests.h"
11+
#import "UIImageView+EZRFeedImageAdditions.h"
12+
#import "EZRFeedImageService.h"
13+
14+
@interface EZRFeedImageAdditions : EZRBaseCategoryTests
15+
{
16+
id mockImageService;
17+
UIImageView *imageView;
18+
}
19+
@end
20+
21+
@implementation EZRFeedImageAdditions
22+
23+
- (void)setUp
24+
{
25+
[super setUp];
26+
imageView = [[UIImageView alloc] init];
27+
mockImageService = [OCMockObject mockForClass:[EZRFeedImageService class]];
28+
[EZRFeedImageService setShared:mockImageService];
29+
}
30+
31+
- (void)tearDown
32+
{
33+
[super tearDown];
34+
}
35+
36+
- (void)testSetImageForURLString
37+
{
38+
[[mockImageService expect] fetchImageAtURLString:@"test"
39+
success:[OCMArg any]
40+
failure:[OCMArg any]];
41+
42+
[imageView setImageForURLString:@"test"];
43+
[mockImageService verify];
44+
}
45+
46+
- (void)testSetBlurredImageForURLString
47+
{
48+
[[mockImageService expect] fetchImageAtURLString:@"test"
49+
success:[OCMArg any]
50+
failure:[OCMArg any]];
51+
52+
[imageView setBlurredImageForURLString:@"test"];
53+
[mockImageService verify];
54+
}
55+
56+
@end
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
//
2+
// EZRSortingAdditionsTests.m
3+
// EasyReader
4+
//
5+
// Created by Alfredo Uribe on 4/17/14.
6+
// Copyright (c) 2014 Cloudspace. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
#import "EZRBaseCategoryTests.h"
11+
#import "NSSet+CSSortingAdditions.h"
12+
13+
@interface EZRSortingAdditionsTests : EZRBaseCategoryTests
14+
15+
@end
16+
17+
@implementation EZRSortingAdditionsTests
18+
19+
- (void)setUp
20+
{
21+
[super setUp];
22+
}
23+
24+
- (void)tearDown
25+
{
26+
[super tearDown];
27+
}
28+
29+
- (void)testSortedArrayByAttributes
30+
{
31+
NSArray *data = @[
32+
@{@"name" : @"b"},
33+
@{@"name" : @"a"},
34+
@{@"name" : @"c"}
35+
];
36+
NSSet *toSort = [NSSet setWithArray:data];
37+
38+
NSArray *sorted = @[
39+
@{@"name" : @"a"},
40+
@{@"name" : @"b"},
41+
@{@"name" : @"c"}
42+
];
43+
44+
BOOL assert = [[toSort sortedArrayByAttributes:@[@"name"] ascending:YES] isEqualToArray:sorted];
45+
XCTAssertTrue(assert, @"");
46+
}
47+
48+
- (void)testSortedArrayByTwoAttributes
49+
{
50+
NSArray *data = @[
51+
@{ @"first" : @"b", @"second" : @"b" },
52+
@{ @"first" : @"c", @"second" : @"a" },
53+
@{ @"first" : @"a", @"second" : @"b" },
54+
@{ @"first" : @"a", @"second" : @"a" },
55+
@{ @"first" : @"b", @"second" : @"a" },
56+
@{ @"first" : @"c", @"second" : @"b" }
57+
];
58+
NSSet *toSort = [NSSet setWithArray:data];
59+
60+
NSArray *sorted = @[
61+
@{ @"first" : @"a", @"second" : @"a" },
62+
@{ @"first" : @"a", @"second" : @"b" },
63+
@{ @"first" : @"b", @"second" : @"a" },
64+
@{ @"first" : @"b", @"second" : @"b" },
65+
@{ @"first" : @"c", @"second" : @"a" },
66+
@{ @"first" : @"c", @"second" : @"b" }
67+
];
68+
69+
BOOL assert = [[toSort sortedArrayByAttributes:@[@"first",@"second"] ascending:YES] isEqualToArray:sorted];
70+
XCTAssertTrue(assert, @"");
71+
}
72+
73+
@end
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
//
2+
// EZRMenuSearchControllerTests.m
3+
// EasyReader
4+
//
5+
// Created by Alfredo Uribe on 4/17/14.
6+
// Copyright (c) 2014 Cloudspace. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
11+
// Models
12+
#import "Feed.h"
13+
14+
#import "EZRBaseControllerTests.h"
15+
#import "EZRMenuSearchController.h"
16+
17+
18+
@interface EZRMenuSearchController (Test)
19+
20+
- (BOOL)isURL:(NSString *)string;
21+
- (void)search:(NSString*)searchText;
22+
- (void)postSearchStateChangeNotification:(EZRSearchState)state;
23+
24+
@end
25+
26+
@interface EZRMenuSearchControllerTests : EZRBaseControllerTests
27+
{
28+
EZRMenuSearchController *controller;
29+
}
30+
@end
31+
32+
@implementation EZRMenuSearchControllerTests
33+
34+
- (void)setUp
35+
{
36+
[super setUp];
37+
controller = [[EZRMenuSearchController alloc] init];
38+
}
39+
40+
- (void)tearDown
41+
{
42+
[super tearDown];
43+
}
44+
45+
- (void)testIsURLForHttp
46+
{
47+
XCTAssertTrue([controller isURL:@"http://www.test.com"],@"");
48+
}
49+
50+
- (void)testIsURLForHttps
51+
{
52+
XCTAssertTrue([controller isURL:@"https://www.test.com"],@"");
53+
}
54+
55+
- (void)testIsURLWithWrongString
56+
{
57+
XCTAssertFalse([controller isURL:@"www.test.com"],@"");
58+
}
59+
60+
- (void)testSearch
61+
{
62+
id mockFeed = [OCMockObject mockForClass:[Feed class]];
63+
[[mockFeed expect] requestFeedsByName:@"test"
64+
success:[OCMArg any]
65+
failure:[OCMArg any]];
66+
67+
[controller search:@"test"];
68+
69+
[mockAPIClient verify];
70+
}
71+
72+
- (void)testSearchCancel
73+
{
74+
[[mockAPIClient expect] requestRoute:@"feedSearch"
75+
parameters:[OCMArg any]
76+
success:[OCMArg any]
77+
failure:[OCMArg any]];
78+
79+
[controller search:@"test1"];
80+
81+
[[mockAPIClient expect] cancelOperationsForRoute:@"feedSearch"
82+
parameters:@{@"name": @"test1"}];
83+
84+
[[mockAPIClient expect] requestRoute:@"feedSearch"
85+
parameters:[OCMArg any]
86+
success:[OCMArg any]
87+
failure:[OCMArg any]];
88+
89+
[controller search:@"test2"];
90+
91+
[mockAPIClient verify];
92+
}
93+
94+
@end
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// EZRCustomFeedCellTests.m
3+
// EasyReader
4+
//
5+
// Created by Alfredo Uribe on 3/28/14.
6+
// Copyright (c) 2014 Cloudspace. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
#import "EZRBaseControllerTests.h"
11+
12+
// Models
13+
#import "EZRMenuFeedCell.h"
14+
15+
16+
@interface EZRMenuFeedCellTests : EZRBaseControllerTests
17+
{
18+
EZRMenuFeedCell *cell;
19+
}
20+
@end
21+
22+
23+
@implementation EZRMenuFeedCellTests
24+
25+
- (void)setUp
26+
{
27+
cell = [[EZRMenuFeedCell alloc] init];
28+
[super setUp];
29+
}
30+
31+
- (void)tearDown
32+
{
33+
[super tearDown];
34+
}
35+
36+
37+
@end

EasyReader - Unit Tests/Application/Controllers/Menu/MenuDataSources/CSMenuSearchFeedDataSourceTests.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,15 @@ - (void)tearDown
4646
[super tearDown];
4747
}
4848

49+
- (void)testSetFeedData
50+
{
51+
NSDictionary *feed = @{ @"url" : @"search" };
52+
NSDictionary *feedData = @{ @"feeds" : @[feed] };
53+
54+
[searchFeedDataSource setFeedData:feedData];
55+
56+
XCTAssertTrue([((NSArray *)searchFeedDataSource.source) containsObject:feed], @"");
57+
}
58+
59+
4960
@end

0 commit comments

Comments
 (0)