Skip to content

Commit 59e4d65

Browse files
author
Florian Rieger
authored
Merge pull request #12 from AppCron/interactor-status-gateway
Interactor status gateway
2 parents eff291c + 53889eb commit 59e4d65

File tree

4 files changed

+73
-0
lines changed

4 files changed

+73
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import Foundation
2+
3+
protocol InteractorStatusGateway {
4+
func isRunning() -> Bool
5+
func setRunning(running: Bool)
6+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import Foundation
2+
3+
class InteractorStatusInMemoryGateway: InteractorStatusGateway {
4+
5+
private var running = false
6+
7+
func isRunning() -> Bool {
8+
return self.running
9+
}
10+
11+
func setRunning(running: Bool) {
12+
self.running = running
13+
}
14+
15+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import XCTest
2+
@testable import ACInteractor
3+
4+
class InteractorStatusInMemoryGatewayTests: XCTestCase {
5+
6+
let gateway = InteractorStatusInMemoryGateway()
7+
8+
// MARK: isRunning()
9+
10+
func testIsRunning_retursFalseByDefault() {
11+
// Act
12+
let running = gateway.isRunning()
13+
14+
// Assert
15+
XCTAssertEqual(running, false)
16+
}
17+
18+
func testIsRunning_afterSettingTrue_returnsTrue() {
19+
// Arrange
20+
gateway.setRunning(true)
21+
22+
// Act
23+
let running = gateway.isRunning()
24+
25+
// Assert
26+
XCTAssertEqual(running, true)
27+
}
28+
29+
func testIsRunning_afterSettingFalse_returnsFalse() {
30+
// Arrange
31+
gateway.setRunning(false)
32+
33+
// Act
34+
let running = gateway.isRunning()
35+
36+
// Assert
37+
XCTAssertEqual(running, false)
38+
}
39+
40+
}

Xcode/ACInteractor.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
17223A171DF9C80000CF7F6F /* InteractorStatusGateway.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17223A161DF9C80000CF7F6F /* InteractorStatusGateway.swift */; };
11+
17223A191DF9CA3E00CF7F6F /* InteractorStatusInMemoryGateway.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17223A181DF9CA3E00CF7F6F /* InteractorStatusInMemoryGateway.swift */; };
12+
17223A1C1DFACC5200CF7F6F /* InteractorStatusInMemoryGatewayTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17223A1A1DF9CA7A00CF7F6F /* InteractorStatusInMemoryGatewayTests.swift */; };
1013
173A77271D3842A200FF88BA /* ACInteractor.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 173A771C1D3842A200FF88BA /* ACInteractor.framework */; };
1114
173A773B1D3844D400FF88BA /* Interactor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 173A77371D3844D400FF88BA /* Interactor.swift */; };
1215
173A773C1D3844D400FF88BA /* InteractorExecuter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 173A77381D3844D400FF88BA /* InteractorExecuter.swift */; };
@@ -32,6 +35,9 @@
3235
/* End PBXContainerItemProxy section */
3336

3437
/* Begin PBXFileReference section */
38+
17223A161DF9C80000CF7F6F /* InteractorStatusGateway.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InteractorStatusGateway.swift; sourceTree = "<group>"; };
39+
17223A181DF9CA3E00CF7F6F /* InteractorStatusInMemoryGateway.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InteractorStatusInMemoryGateway.swift; sourceTree = "<group>"; };
40+
17223A1A1DF9CA7A00CF7F6F /* InteractorStatusInMemoryGatewayTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InteractorStatusInMemoryGatewayTests.swift; sourceTree = "<group>"; };
3541
173A771C1D3842A200FF88BA /* ACInteractor.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ACInteractor.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3642
173A77261D3842A200FF88BA /* ACInteractorTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ACInteractorTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
3743
173A77371D3844D400FF88BA /* Interactor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Interactor.swift; sourceTree = "<group>"; };
@@ -95,6 +101,8 @@
95101
173A77381D3844D400FF88BA /* InteractorExecuter.swift */,
96102
17B0BF6F1D3CD057004AA98B /* LazyInteractor.swift */,
97103
1794818E1D57475000CA3590 /* ErrorHandlerExtension.swift */,
104+
17223A161DF9C80000CF7F6F /* InteractorStatusGateway.swift */,
105+
17223A181DF9CA3E00CF7F6F /* InteractorStatusInMemoryGateway.swift */,
98106
);
99107
name = Sources;
100108
path = ../Sources;
@@ -107,6 +115,7 @@
107115
17567E581D3A640000C464BB /* InteractorErrorTests.swift */,
108116
17B0BF711D3CD0A9004AA98B /* LazyInteractorTests.swift */,
109117
179481901D57490900CA3590 /* ErrorHandlerExtensionTests.swift */,
118+
17223A1A1DF9CA7A00CF7F6F /* InteractorStatusInMemoryGatewayTests.swift */,
110119
);
111120
name = Tests;
112121
path = ../Tests;
@@ -230,7 +239,9 @@
230239
buildActionMask = 2147483647;
231240
files = (
232241
173A773B1D3844D400FF88BA /* Interactor.swift in Sources */,
242+
17223A191DF9CA3E00CF7F6F /* InteractorStatusInMemoryGateway.swift in Sources */,
233243
17567E551D3A61C900C464BB /* InteractorError.swift in Sources */,
244+
17223A171DF9C80000CF7F6F /* InteractorStatusGateway.swift in Sources */,
234245
173A773C1D3844D400FF88BA /* InteractorExecuter.swift in Sources */,
235246
173A773D1D3844D400FF88BA /* InteractorRequest.swift in Sources */,
236247
17B0BF701D3CD057004AA98B /* LazyInteractor.swift in Sources */,
@@ -246,6 +257,7 @@
246257
173A77411D38461D00FF88BA /* InteractorExecuterTests.swift in Sources */,
247258
179481921D5749A800CA3590 /* ErrorHandlerExtensionTests.swift in Sources */,
248259
17567E591D3A640000C464BB /* InteractorErrorTests.swift in Sources */,
260+
17223A1C1DFACC5200CF7F6F /* InteractorStatusInMemoryGatewayTests.swift in Sources */,
249261
);
250262
runOnlyForDeploymentPostprocessing = 0;
251263
};

0 commit comments

Comments
 (0)