-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #204
- Loading branch information
Showing
8 changed files
with
139 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// SimpleMusicPlayerUserDefaults.swift | ||
// Telephone | ||
// | ||
// Copyright (c) 2008-2016 Alexey Kuznetsov | ||
// Copyright (c) 2016 64 Characters | ||
// | ||
// Telephone is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Telephone is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
|
||
public final class SimpleMusicPlayerUserDefaults { | ||
private let defaults: KeyValueUserDefaults | ||
|
||
public init(defaults: KeyValueUserDefaults) { | ||
self.defaults = defaults | ||
defaults.registerDefaults([key: true]) | ||
} | ||
} | ||
|
||
extension SimpleMusicPlayerUserDefaults: MusicPlayerUserDefaults { | ||
public var shouldPause: Bool { | ||
get { | ||
return defaults.boolForKey(key) | ||
} | ||
set { | ||
defaults.setBool(newValue, forKey: key) | ||
} | ||
} | ||
} | ||
|
||
private let key = "PauseITunes" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// SimpleMusicPlayerUserDefaultsTests.swift | ||
// Telephone | ||
// | ||
// Copyright (c) 2008-2016 Alexey Kuznetsov | ||
// Copyright (c) 2016 64 Characters | ||
// | ||
// Telephone is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Telephone is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
|
||
import UseCases | ||
import UseCasesTestDoubles | ||
import XCTest | ||
|
||
final class SimpleMusicPlayerUserDefaultsTests: XCTestCase { | ||
func testGetsFromUserDefaultsWithExpectedKey() { | ||
let defaults = UserDefaultsFake() | ||
defaults.setBool(true, forKey: key) | ||
let sut = SimpleMusicPlayerUserDefaults(defaults: defaults) | ||
|
||
XCTAssertTrue(sut.shouldPause) | ||
} | ||
|
||
func testSetsToUserDefaultsWithExpectedKey() { | ||
let defaults = UserDefaultsFake() | ||
let sut = SimpleMusicPlayerUserDefaults(defaults: defaults) | ||
|
||
sut.shouldPause = true | ||
|
||
XCTAssertTrue(defaults.boolForKey(key)) | ||
} | ||
|
||
func testRegistersDefaults() { | ||
let defaults = UserDefaultsFake() | ||
_ = SimpleMusicPlayerUserDefaults(defaults: defaults) | ||
|
||
XCTAssertTrue(defaults.registeredDefaults[key] as! Bool) | ||
} | ||
} | ||
|
||
private let key = "PauseITunes" |