-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCocoaWagonTest.m
61 lines (45 loc) · 1.64 KB
/
CocoaWagonTest.m
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
//
// CocoaWagonTest.m
// CocoaWagon
//
// Created by Yves Vogl on 01.06.10.
// Copyright 2010 DEETUNE. All rights reserved.
//
#import "CocoaWagonTest.h"
@implementation CocoaWagonTest
-(void)setUp {
[CocoaWagon setBaseURLString:@"http://cocoa-wagon.local"];
}
-(void)testInitialization {
STAssertThrows([[CocoaWagon alloc] init], @"Should raise exception!");
STAssertNoThrow([[TestObject alloc] init], @"Should not raise an exception!");
}
-(void)testRemoteConnection {
TestObject *testObject = [[[TestObject alloc] initWithDelegate:self willPaginate:NO] autorelease];
STAssertNotNil(testObject, @"Could not initialize test object");
STAssertTrue([testObject findAll], @"Something went wrong with the connection");
}
#pragma mark CocoaWagon Delegates
/*
* See RFC 2616 10 Status Code Definitions for details
* http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
*/
-(void)didFinishWithResults:(NSArray *)results {
STAssertNotNil(results, @"Result shouldn't be nil");
}
-(void)didFailWithError:(NSError *)error {
STAssertNotNil(error, @"Should contain an error");
}
/*
* See RFC 2616 10 Status Code Definitions for details
* http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
*/
-(void)didRespondWithStatusCode:(NSInteger)statusCode {
NSRange validStatusCodeRange = NSMakeRange(100, 505);
STAssertTrue(NSLocationInRange(statusCode, validStatusCodeRange), @"Every response should have a valid HTTP status code");
/*
NSRange validStatusCodeRangeIndicatingSuccess = NSMakeRange(200, 206);
STAssertTrue(NSLocationInRange(statusCode, validStatusCodeRangeIndicatingSuccess), @"Should have a 2xx response code.");
*/
}
@end