PageRenderTime 31ms CodeModel.GetById 12ms app.highlight 15ms RepoModel.GetById 2ms app.codeStats 0ms

/core/externals/update-engine/Core/KSServerTest.m

http://macfuse.googlecode.com/
Objective C | 77 lines | 49 code | 15 blank | 13 comment | 0 complexity | 10f910f14e529f9834bd6e30c77a8c66 MD5 | raw file
 1// Copyright 2008 Google Inc.
 2//
 3// Licensed under the Apache License, Version 2.0 (the "License");
 4// you may not use this file except in compliance with the License.
 5// You may obtain a copy of the License at
 6//
 7//     http://www.apache.org/licenses/LICENSE-2.0
 8//
 9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#import <SenTestingKit/SenTestingKit.h>
16#import "KSServer.h"
17
18
19@interface KSServerTest : SenTestCase
20@end
21
22
23@implementation KSServerTest
24
25- (void)testCreation {
26
27  KSServer *s = [[KSServer alloc] initWithURL:nil];
28  STAssertNil(s, nil);
29  
30  s = [[KSServer alloc] init];
31  STAssertNil(s, nil);
32
33  s = [[KSServer alloc] initWithURL:[NSURL URLWithString:@"http://foo"]];
34  STAssertNotNil(s, nil);
35  STAssertEqualObjects([s url], [NSURL URLWithString:@"http://foo"], nil);
36  STAssertNil([s params], nil);
37  [s release];
38
39  NSURL *url = [NSURL URLWithString:@"http://www.foo.com:8000/file.txt"];
40  STAssertNotNil(url, nil);
41  s = [[KSServer alloc] initWithURL:url];
42  STAssertNotNil(s, nil);
43  STAssertEqualObjects([s url], url, nil);
44  STAssertNil([s params], nil);
45  STAssertTrue([[s description] length] > 1, nil);
46  [s release];
47
48  NSDictionary *params = [NSDictionary dictionaryWithObject:@"a" forKey:@"b"];
49  s = [[KSServer alloc] initWithURL:url params:params];
50  STAssertNotNil(s, nil);
51  STAssertEqualObjects([s url], url, nil);
52  STAssertNotNil([s params], nil);
53  STAssertEqualObjects([s params], params, nil);
54  STAssertTrue([[s description] length] > 1, nil);
55  [s release];
56}
57
58- (void)testAbstractMethods {
59  NSURL *url = [NSURL URLWithString:@"http://www.foo.com:8000/file.txt"];
60  STAssertNotNil(url, nil);
61  KSServer *s = [[[KSServer alloc] initWithURL:url] autorelease];
62  STAssertNotNil(s, nil);
63  STAssertNil([s requestsForTickets:nil], nil);
64  STAssertNil([s requestsForTickets:[NSMutableArray arrayWithCapacity:1]], nil);
65  NSData *data = [NSData dataWithBytes:(void *)"hi mom" length:6];
66  STAssertNil([s updateInfosForResponse:nil data:data outOfBandData:NULL], nil);
67  STAssertNil([s updateInfosForResponse:nil data:nil outOfBandData:NULL], nil);
68  STAssertNil([s updateInfosForResponse:nil data:data outOfBandData:NULL], nil);
69  STAssertNil([s updateInfosForResponse:nil data:nil outOfBandData:NULL], nil);
70  NSDictionary *oob;
71  STAssertNil([s updateInfosForResponse:nil data:nil outOfBandData:&oob], nil);
72  STAssertNil(oob, nil);
73}
74
75@end
76
77