-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExpectsStringTests.m
64 lines (53 loc) · 2 KB
/
ExpectsStringTests.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
62
63
64
//
// STLogExpressionParserDelegateTests.m
// StoryTeller
//
// Created by Derek Clarkson on 25/06/2015.
// Copyright © 2015 Derek Clarkson. All rights reserved.
//
@import XCTest;
@import StoryTeller.Private;
@import StoryTeller;
@import OCMock;
#import "MainClass.h"
#import "SubClass.h"
#import "AProtocol.h"
@interface ExpectsStringTests : XCTestCase
@end
@implementation ExpectsStringTests {
STLogExpressionParserDelegate *_factory;
id _mockStoryTeller;
}
-(void) setUp {
_factory = [[STLogExpressionParserDelegate alloc] init];
_mockStoryTeller = OCMClassMock([STStoryTeller class]);
}
-(void) testQuotedStringMatches {
id<STMatcher> matcher = [_factory parseExpression:@"[MainClass].stringProperty == \"abc\""];
MainClass *mainClass = [[MainClass alloc] init];
mainClass.stringProperty = @"abc";
XCTAssertTrue([matcher storyTeller:_mockStoryTeller matches:mainClass]);
}
-(void) testMatches {
id<STMatcher> matcher = [_factory parseExpression:@"[MainClass].stringProperty == abc"];
MainClass *mainClass = [[MainClass alloc] init];
mainClass.stringProperty = @"abc";
XCTAssertTrue([matcher storyTeller:_mockStoryTeller matches:mainClass]);
}
-(void) testFailsMatch {
id<STMatcher> matcher = [_factory parseExpression:@"[MainClass].stringProperty == abc"];
MainClass *mainClass = [[MainClass alloc] init];
mainClass.stringProperty = @"def";
XCTAssertFalse([matcher storyTeller:_mockStoryTeller matches:mainClass]);
}
-(void) testFailsMatchWhenAProtocolProperty {
id<STMatcher> matcher = [_factory parseExpression:@"[MainClass].protocolProperty == abc"];
MainClass *mainClass = [[MainClass alloc] init];
XCTAssertFalse([matcher storyTeller:_mockStoryTeller matches:mainClass]);
}
-(void) testFailsMatchWhenAIntProperty {
id<STMatcher> matcher = [_factory parseExpression:@"[MainClass].intProperty == abc"];
MainClass *mainClass = [[MainClass alloc] init];
XCTAssertFalse([matcher storyTeller:_mockStoryTeller matches:mainClass]);
}
@end