Add tests for ServerProfile

This commit is contained in:
Rainux Luo
2017-01-07 09:26:32 +08:00
parent 5e06b4b4f0
commit 9dafb4fb79
5 changed files with 64 additions and 3 deletions

View File

@ -123,7 +123,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
for url in urls {
let profielDict = ParseSSURL(url)
if let profielDict = profielDict {
let profile = ServerProfile.fromDictionary(profielDict as [String : AnyObject])
let profile = ServerProfile.fromDictionary(profielDict)
mgr.profiles.append(profile)
isChanged = true

View File

@ -28,7 +28,7 @@ class ServerProfile: NSObject {
self.uuid = uuid
}
static func fromDictionary(_ data:[String:AnyObject]) -> ServerProfile {
static func fromDictionary(_ data:[String: Any?]) -> ServerProfile {
let cp = {
(profile: ServerProfile) in
profile.serverHost = data["ServerHost"] as! String

View File

@ -21,7 +21,7 @@ class ServerProfileManager: NSObject {
let defaults = UserDefaults.standard
if let _profiles = defaults.array(forKey: "ServerProfiles") {
for _profile in _profiles {
let profile = ServerProfile.fromDictionary(_profile as! [String : AnyObject])
let profile = ServerProfile.fromDictionary(_profile as! [String: Any])
profiles.append(profile)
}
}