Refactor ParseSSURL as ServerProfile initializer
This commit is contained in:
@ -37,7 +37,7 @@ class ServerProfileTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testServerProfileURL() {
|
||||
let parsed = ParseSSURL(profile.URL())
|
||||
let parsed = ServerProfile(url: profile.URL())?.toDictionary()
|
||||
|
||||
XCTAssertNotNil(parsed)
|
||||
|
||||
@ -49,6 +49,17 @@ class ServerProfileTests: XCTestCase {
|
||||
XCTAssertEqual(parsed?["OTA"] as? Bool, profile.ota)
|
||||
}
|
||||
|
||||
func testServerProfileInitFromURL() {
|
||||
let newProfile = ServerProfile.init(url: profile.URL())
|
||||
|
||||
XCTAssertEqual(newProfile?.serverHost, profile.serverHost)
|
||||
XCTAssertEqual(newProfile?.serverPort, profile.serverPort)
|
||||
XCTAssertEqual(newProfile?.method, profile.method)
|
||||
XCTAssertEqual(newProfile?.password, profile.password)
|
||||
XCTAssertEqual(newProfile?.remark, profile.remark)
|
||||
XCTAssertEqual(newProfile?.ota, profile.ota)
|
||||
}
|
||||
|
||||
func testPerformanceExample() {
|
||||
// This is an example of a performance test case.
|
||||
self.measure {
|
||||
|
@ -32,5 +32,5 @@ class ShadowsocksX_NGTests: XCTestCase {
|
||||
// Put the code you want to measure the time of here.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class UtilsTests: XCTestCase {
|
||||
func testParseSSURLwithPlainURL() {
|
||||
let url = URL(string: "ss://aes-256-cfb:password@example.com:8388")
|
||||
|
||||
let profile = ParseSSURL(url)
|
||||
let profile = ServerProfile(url: url)?.toDictionary()
|
||||
|
||||
XCTAssertNotNil(profile)
|
||||
|
||||
@ -37,7 +37,7 @@ class UtilsTests: XCTestCase {
|
||||
func testParseSSURLwithPlainURLandQuery() {
|
||||
let url = URL(string: "ss://aes-256-cfb:password@example.com:8388?Remark=Prism&OTA=true")
|
||||
|
||||
let profile = ParseSSURL(url)
|
||||
let profile = ServerProfile(url: url)?.toDictionary()
|
||||
|
||||
XCTAssertNotNil(profile)
|
||||
|
||||
@ -52,7 +52,7 @@ class UtilsTests: XCTestCase {
|
||||
func testParseSSURLwithPlainURLandAnotherQuery() {
|
||||
let url = URL(string: "ss://aes-256-cfb:password@example.com:8388?Remark=Prism&OTA=0")
|
||||
|
||||
let profile = ParseSSURL(url)
|
||||
let profile = ServerProfile(url: url)?.toDictionary()
|
||||
|
||||
XCTAssertNotNil(profile)
|
||||
|
||||
@ -68,7 +68,7 @@ class UtilsTests: XCTestCase {
|
||||
// "ss://aes-256-cfb:password@example.com:8388"
|
||||
let url = URL(string: "ss://YWVzLTI1Ni1jZmI6cGFzc3dvcmRAZXhhbXBsZS5jb206ODM4OA")
|
||||
|
||||
let profile = ParseSSURL(url)
|
||||
let profile = ServerProfile(url: url)?.toDictionary()
|
||||
|
||||
XCTAssertNotNil(profile)
|
||||
|
||||
@ -82,7 +82,7 @@ class UtilsTests: XCTestCase {
|
||||
// "ss://aes-256-cfb:password@example.com:8388?Remark=Prism&OTA=true"
|
||||
let url = URL(string: "ss://YWVzLTI1Ni1jZmI6cGFzc3dvcmRAZXhhbXBsZS5jb206ODM4OD9SZW1hcms9UHJpc20mT1RBPXRydWU")
|
||||
|
||||
let profile = ParseSSURL(url)
|
||||
let profile = ServerProfile(url: url)?.toDictionary()
|
||||
|
||||
XCTAssertNotNil(profile)
|
||||
|
||||
@ -97,7 +97,7 @@ class UtilsTests: XCTestCase {
|
||||
func testParseSSURLwithEmptyURL() {
|
||||
let url = URL(string: "ss://")
|
||||
|
||||
let profile = ParseSSURL(url)
|
||||
let profile = ServerProfile(url: url)
|
||||
|
||||
XCTAssertNil(profile)
|
||||
}
|
||||
@ -105,7 +105,7 @@ class UtilsTests: XCTestCase {
|
||||
func testParseSSURLwithInvalidURL() {
|
||||
let url = URL(string: "ss://invalid url")
|
||||
|
||||
let profile = ParseSSURL(url)
|
||||
let profile = ServerProfile(url: url)
|
||||
|
||||
XCTAssertNil(profile)
|
||||
}
|
||||
@ -114,7 +114,7 @@ class UtilsTests: XCTestCase {
|
||||
// "ss://invalid url"
|
||||
let url = URL(string: "ss://aW52YWxpZCB1cmw")
|
||||
|
||||
let profile = ParseSSURL(url)
|
||||
let profile = ServerProfile(url: url)
|
||||
|
||||
XCTAssertNil(profile)
|
||||
}
|
||||
|
Reference in New Issue
Block a user