1
exercism fetch objective-c secret-handshake

SecretHandshakeTest.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
#import <XCTest/XCTest.h>

#if __has_include("SecretHandshakeExample.h")
# import "SecretHandshakeExample.h"
# else
# import "SecretHandshake.h"
#endif

@interface SecretHandshakeTest : XCTestCase

@end

@implementation SecretHandshakeTest

- (void)testHandshake1ToWink {
    SecretHandshake *handshake = [[SecretHandshake alloc] initWithNumber:1];
    XCTAssertEqualObjects(@[@"wink"], handshake.commands);
}

- (void)testHandshake10ToDoubleBlink {
    SecretHandshake *handshake = [[SecretHandshake alloc] initWithNumber:2];
    XCTAssertEqualObjects(@[@"double blink"], handshake.commands);
}

- (void)testHandshake100ToCloseYourEyes {
    SecretHandshake *handshake = [[SecretHandshake alloc] initWithNumber:4];
    XCTAssertEqualObjects(@[@"close your eyes"], handshake.commands);
}

- (void)testHandshake1000ToJump {
    SecretHandshake *handshake = [[SecretHandshake alloc] initWithNumber:8];
    XCTAssertEqualObjects(@[@"jump"], handshake.commands);
}

- (void)testHandshake11ToWinkAndDoubleBlink {
    SecretHandshake *handshake = [[SecretHandshake alloc] initWithNumber:3];
    NSArray<NSString *> *expected = @[@"wink", @"double blink"];
    XCTAssertEqualObjects(expected, handshake.commands);
}

- (void)testHandshake10011ToDoubleBlinkAndWink {
    SecretHandshake *handshake = [[SecretHandshake alloc] initWithNumber:19];
    NSArray<NSString *> *expected = @[@"double blink", @"wink"];
    XCTAssertEqualObjects(expected, handshake.commands);
}

- (void)testHandshake11111ToDoubleBlinkAndWink {
    SecretHandshake *handshake = [[SecretHandshake alloc] initWithNumber:31];
    NSArray<NSString *> *expected = @[@"jump", @"close your eyes", @"double blink", @"wink"];
    XCTAssertEqualObjects(expected, handshake.commands);
}

- (void)testNonValidHandshake {
    SecretHandshake *handshake = [[SecretHandshake alloc] initWithNumber:0];
    XCTAssertEqualObjects(@[], handshake.commands);
}

@end