This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Configuration | |
public class Configuration { | |
public var serverName: String | |
public var serverPort: Int | |
public var logFile: String | |
public var databaseHost: String | |
public var datanaseName: String | |
public var databaseUser: String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Configuration | |
extension ConfigurationManager { | |
public func build() -> Configuration { | |
let configuration = Configuration(manager: self) | |
return configuration | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TasksRepository : TasksRepositoryProtocol { | |
init(configuration: Configuration) { | |
print("Database host: \(configuration.databaseHost)") | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// DependencyContainer.swift | |
// TaskerServerPackageDescription | |
// | |
// Created by Marcin Czachurski on 12.02.2018. | |
// | |
import Foundation | |
import Dip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PerfectHTTP | |
import PerfectHTTPServer | |
import PerfectLib | |
import Dip | |
import TaskerServerLib | |
import Configuration | |
// Read configuration file. | |
let configurationManager = ConfigurationManager() | |
.load(file: "configuration.json", relativeFrom: .pwd) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Read configuration file. | |
let configurationManager = ConfigurationManager() | |
.load(file: "configuration.json", relativeFrom: .pwd) | |
.load(.environmentVariables) | |
.load(.commandLineArguments) | |
let configuration = configurationManager.build() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func testGetUsersShouldReturnUsersCollection() { | |
// Arrange. | |
let fakeHttpRequest = FakeHTTPRequest() | |
let fakeHttpResponse = FakeHTTPResponse() | |
let fakeUsersRepository = FakeUsersRepository() | |
fakeUsersRepository.getUsersMock.expect(any()) | |
fakeUsersRepository.getUsersStub.on(any(), return: [ | |
User(id: 1, name: "John Doe", email: "[email protected]", isLocked: false), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import TaskerServerLib | |
import Dobby | |
class FakeUsersRepository : UsersRepositoryProtocol { | |
let getUsersMock = Mock<()>() | |
let getUsersStub = Stub<(), [User]>() | |
let getUserMock = Mock<(Int)>() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import XCTest | |
import PerfectHTTP | |
import Dobby | |
@testable import TaskerServerLib | |
class UsersControllerTests: XCTestCase { | |
func testInitRoutesShouldInitializeGetAllUsersRoute() { | |
// Arrange. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// swift-tools-version:4.0 | |
// The swift-tools-version declares the minimum version of Swift required to build this package. | |
import PackageDescription | |
let package = Package( | |
name: "TaskerServer", | |
dependencies: [ | |
// Dependencies declare other packages that this package depends on. | |
.package(url: "https://github.com/PerfectlySoft/Perfect-HTTPServer.git", from: "3.0.0"), |