Add factory methods

pull/2/head
Michael Scoff 7 years ago
parent f61f9f31aa
commit ba0c8bb06b
  1. 17
      TrustTests/Factories/Account.swift
  2. 14
      TrustTests/Factories/Address.swift
  3. 21
      TrustTests/Factories/FakeKeystore.swift

@ -0,0 +1,17 @@
// Copyright SIX DAY LLC, Inc. All rights reserved.
import Foundation
@testable import Trust
extension Account {
static func make(
address: Address = .make()
) -> Account {
return Account(
address: address
)
}
}

@ -0,0 +1,14 @@
// Copyright SIX DAY LLC, Inc. All rights reserved.
import Foundation
@testable import Trust
extension Address {
static func make(
address: String = "0x123f681646d4a755815f9cb19e1acc8565a0c2ac "
) -> Address {
return Address(
address: address
)
}
}

@ -0,0 +1,21 @@
// Copyright SIX DAY LLC, Inc. All rights reserved.
import Foundation
@testable import Trust
struct FakeKeystore: Keystore {
var hasAccounts: Bool {
return accounts.count > 0
}
var accounts: [Account] = []
}
extension FakeKeystore {
static func make(
accounts: [Account] = []
) -> FakeKeystore {
return FakeKeystore(
accounts: accounts
)
}
}
Loading…
Cancel
Save