-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDoorKnobTest.m
47 lines (39 loc) · 1.03 KB
/
DoorKnobTest.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
//
// DoorKnobTest.m
// Doors
//
// Created by Mathias Kegelmann on 10/16/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import "DoorKnobTest.h"
@interface WorldSpy : NSObject {
NSMutableArray *trace;
}
@property(readonly) NSMutableArray *trace;
- (id)init;
- (void)toggleDoor:(DoorLocator *)doorLocator;
@end
@implementation WorldSpy
- (id)init
{
trace = [NSMutableArray new];
return self;
}
- (void)toggleDoor:(DoorLocator *)doorLocator
{
[trace addObject:doorLocator];
}
@synthesize trace;
@end
@implementation DoorKnobTest
- (void)testToggle
{
DoorLocator *locator1 = [DoorLocator newWithHorizontalDoor:true x:1 y:2];
DoorLocator *locator2 = [DoorLocator newWithHorizontalDoor:false x:2 y:0];
NSArray *locators = [NSArray arrayWithObjects: locator1, locator2];
id world = [[WorldSpy alloc] init];
DoorKnob *doorKnob = [[DoorKnob alloc] initWithWorldModel:world andDoorLocators:locators];
[doorKnob toggle];
STAssertEqualObjects(locators, [world trace], nil);
}
@end