Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the testFromFile paths and add support for watchOS and tvOS. #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 26 additions & 14 deletions Tests/PrephirencesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ typealias Color = UIColor
import AppKit
typealias Color = NSColor
#endif
#if os(watchOS)
import WatchKit
typealias Color = UIColor
#endif
#if os(tvOS)
import TVUIKit
typealias Color = UIColor
#endif

class PrephirencesTests: XCTestCase {

Expand Down Expand Up @@ -66,21 +74,21 @@ class PrephirencesTests: XCTestCase {
}*/

func testFromFile() {
if let filePath = path(forResource: "Test", ofType: "plist", in: Bundle(for: type(of: self))) {
if let preference = DictionaryPreferences(filePath: filePath) {
for (key,value) in preference.dictionary() {
print("\(key)=\(value)")
}

} else {
XCTFail("Failed to read from file")
}
} else {
XCTFail("Failed to get file url")
}
guard let filePath = path(forResource: "Test", ofType: "plist", in: Bundle(for: type(of: self))) else {
XCTFail("Failed to get file url")
return
}
if let preference = DictionaryPreferences(filePath: filePath) {
for (key,value) in preference.dictionary() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comma Spacing Violation: There should be no space before and one after any comma. (comma)

print("\(key)=\(value)")
}

} else {
XCTFail("Failed to read from file")
}

if let preference = DictionaryPreferences(filename: "Test", ofType: "plist", bundle: Bundle(for: type(of: self))) ??
DictionaryPreferences(filePath: "Tests/Test.plist") {
DictionaryPreferences(filePath: filePath) {
for (key,value) in preference.dictionary() {
print("\(key)=\(value)")
}
Expand All @@ -95,7 +103,11 @@ class PrephirencesTests: XCTestCase {
return url
}
#endif
let path = "Tests/\(resource).\(ext)"
let path = URL(fileURLWithPath: #filePath)
.deletingLastPathComponent()
.deletingLastPathComponent()
.appendingPathComponent("Tests/\(resource).\(ext)")
.path
if FileManager.default.fileExists(atPath: path) {
return path
}
Expand Down