Skip to content
Snippets Groups Projects
Commit 4fef1f7f authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

Change type of Fact.type property to FactType

parent 0d5af7e3
No related branches found
No related tags found
2 merge requests!102Release 1.0.0,!71Fact improvements & helpers
......@@ -3,14 +3,14 @@ import Foundation
public struct Fact: Equatable {
public init(
fact: String,
type: Int
type: FactType
) {
self.fact = fact
self.type = type
}
public var fact: String
public var type: Int
public var type: FactType
}
extension Fact: Codable {
......@@ -46,13 +46,13 @@ extension Array where Element == Fact {
extension Array where Element == Fact {
public func get(_ type: FactType) -> Fact? {
first(where: { $0.type == type.rawValue })
first(where: { $0.type == type })
}
public mutating func set(_ type: FactType, _ value: String?) {
removeAll(where: { $0.type == type.rawValue })
removeAll(where: { $0.type == type })
if let value = value {
append(Fact(fact: value, type: type.rawValue))
append(Fact(fact: value, type: type))
sort(by: { $0.type < $1.type })
}
}
......
......@@ -5,7 +5,7 @@ import XCTest
final class FactTests: XCTestCase {
func testCoding() throws {
let factValue = "Zezima"
let factType: Int = 0
let factType: Int = 123
let jsonString = """
{
"Fact": "\(factValue)",
......@@ -17,7 +17,7 @@ final class FactTests: XCTestCase {
XCTAssertNoDifference(model, Fact(
fact: factValue,
type: factType
type: 123
))
let encodedModel = try model.encode()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment