Files
hyperoslo-Cache/Tests/Shared/TestHelper.swift
T
Kristaps Grinbergs 3453f681c6 * setting Swift4.2 version in appropriate places
* fixing tests for Swift 4.2
* Xcode 10 parallel testing
* code sanitasion
* remove comments from Package.swift
2018-09-23 13:00:34 +03:00

28 lines
956 B
Swift

import Foundation
#if os(iOS) || os(tvOS)
import UIKit
#elseif os(OSX)
import AppKit
#endif
struct TestHelper {
static func data(_ length : Int) -> Data {
let buffer = [UInt8](repeating: 0, count: length)
return Data(bytes: buffer)
}
static func triggerApplicationEvents() {
#if (iOS)
NotificationCenter.default.post(name: UIApplication.didEnterBackgroundNotification, object: nil)
NotificationCenter.default.post(name: UIApplication.willTerminateNotification, object: nil)
#elseif os(tvOS)
NotificationCenter.default.post(name: Notification.Name.UIApplicationDidEnterBackground, object: nil)
NotificationCenter.default.post(name: Notification.Name.UIApplicationWillTerminate, object: nil)
#else
NotificationCenter.default.post(name: NSApplication.willTerminateNotification, object: nil)
NotificationCenter.default.post(name: NSApplication.didResignActiveNotification, object: nil)
#endif
}
}