blob: 48e11f3bd834b7004f3406cc83cdebe5c4deca58 (
plain)
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
|
@interface MASDictionaryTransformerTests : XCTestCase
@end
@implementation MASDictionaryTransformerTests
- (void) testErrorHandling
{
MASDictionaryTransformer *transformer = [MASDictionaryTransformer new];
XCTAssertNil([transformer transformedValue:nil],
@"Decoding a shortcut from a nil dictionary returns nil.");
XCTAssertNil([transformer transformedValue:(id)@"foo"],
@"Decoding a shortcut from a invalid-type dictionary returns nil.");
XCTAssertNil([transformer transformedValue:@{}],
@"Decoding a shortcut from an empty dictionary returns nil.");
XCTAssertNil([transformer transformedValue:@{@"keyCode":@"foo"}],
@"Decoding a shortcut from a wrong-typed dictionary returns nil.");
XCTAssertNil([transformer transformedValue:@{@"keyCode":@1}],
@"Decoding a shortcut from an incomplete dictionary returns nil.");
XCTAssertNil([transformer transformedValue:@{@"modifierFlags":@1}],
@"Decoding a shortcut from an incomplete dictionary returns nil.");
}
- (void) testNilRepresentation
{
MASDictionaryTransformer *transformer = [MASDictionaryTransformer new];
XCTAssertEqualObjects([transformer reverseTransformedValue:nil], [NSDictionary dictionary],
@"Store nil values as an empty dictionary.");
XCTAssertNil([transformer transformedValue:[NSDictionary dictionary]],
@"Load empty dictionary as nil.");
}
@end
|