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

Update tests #384

Merged
merged 16 commits into from
Jul 21, 2016
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update the getDialogFile test function
- Verify that the file exists at the given path
- Verify that the extension of the downloaded file is correct
- Remove the downloaded file to avoid collisions with subsequent tests
  • Loading branch information
glennrfisher committed Jul 17, 2016
commit 99fb783a09d05d4bc9403ac1cdf9ccb2cd71f08f
24 changes: 18 additions & 6 deletions Source/DialogV1/Tests/DialogTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,17 +200,29 @@ class DialogTests: XCTestCase {
func getDialogFile(format: DialogV1.Format? = nil) {
let description = "Download the dialog file associated with the test application."
let expectation = expectationWithDescription(description)

dialog.getDialogFile(dialogID!, format: format, failure: failWithError) { file in
guard let path = file.path else {
XCTFail("Dialog file does not exist at the given path.")
return
}
XCTAssertTrue(NSFileManager().fileExistsAtPath(path))
let fileManager = NSFileManager.defaultManager()
XCTAssertTrue(fileManager.fileExistsAtPath(file.path!))
XCTAssertTrue(self.verifyFiletype(format, url: file))
try! fileManager.removeItemAtURL(file)
expectation.fulfill()
}
waitForExpectations()
}

/** Verify the filetype (extension) of a downloaded dialog file. */
func verifyFiletype(format: DialogV1.Format?, url: NSURL) -> Bool {
var filetype = ".mct"
if let format = format {
switch format {
case .OctetStream: filetype = ".mct"
case .WDSJSON: filetype = ".json"
case .WDSXML: filetype = ".xml"
}
}
return url.path!.hasSuffix(filetype)
}

/** Download the dialog file associated with the test application. */
func testGetDialogFile() {
Expand Down