MDMSetupMock.swift 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // _____ _
  2. // |_ _| |_ _ _ ___ ___ _ __ __ _
  3. // | | | ' \| '_/ -_) -_) ' \/ _` |_
  4. // |_| |_||_|_| \___\___|_|_|_\__,_(_)
  5. //
  6. // Threema iOS Client
  7. // Copyright (c) 2019-2020 Threema GmbH
  8. //
  9. // This program is free software: you can redistribute it and/or modify
  10. // it under the terms of the GNU Affero General Public License, version 3,
  11. // as published by the Free Software Foundation.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU Affero General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Affero General Public License
  19. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. import Foundation
  21. @testable import Threema
  22. class MDMSetupMock: MDMSetup {
  23. private var _disabelBackups: Bool?
  24. private var _safeEanble: Int?
  25. private var _safeServerUrl: String?
  26. private var _safePassword: String?
  27. private var _safeRestoreEnable: Bool?
  28. private var _safeRestoreId: String?
  29. override convenience init() {
  30. self.init()
  31. }
  32. convenience init(disableBackups: Bool?, safeEnable: Int?, safeServerUrl: String?, safePassword: String?, safeRestoreEnable: Bool?, safeRestoreId: String?) {
  33. self.init(setup: false)
  34. self._disabelBackups = disableBackups
  35. self._safeEanble = safeEnable
  36. self._safeServerUrl = safeServerUrl
  37. self._safePassword = safePassword
  38. self._safeRestoreEnable = safeRestoreEnable
  39. self._safeRestoreId = safeRestoreId
  40. }
  41. override func disableBackups() -> Bool {
  42. return self._disabelBackups != nil ? self._disabelBackups! : false
  43. }
  44. override func safeEnable() -> NSNumber? {
  45. return self._safeEanble != nil ? NSNumber(value: self._safeEanble!) : nil
  46. }
  47. override func safeServerUrl() -> String? {
  48. return self._safeServerUrl
  49. }
  50. override func safePassword() -> String? {
  51. return self._safePassword
  52. }
  53. override func safeRestoreEnable() -> Bool {
  54. return self._safeRestoreEnable != nil ? self._safeRestoreEnable! : true
  55. }
  56. override func safeRestoreId() -> String? {
  57. return self._safeRestoreId
  58. }
  59. }