diff --git a/Tests/ElixxirDAppsSDKTests/FactTests.swift b/Tests/ElixxirDAppsSDKTests/FactTests.swift index 21820a78c9a744322a8d81823f81d486ace91be6..0894b22ae4136703d72b5bc64076f2916711a81c 100644 --- a/Tests/ElixxirDAppsSDKTests/FactTests.swift +++ b/Tests/ElixxirDAppsSDKTests/FactTests.swift @@ -4,26 +4,25 @@ import XCTest final class FactTests: XCTestCase { func testCoding() throws { + let factString = "Zezima" + let factType: Int = 0 let jsonString = """ { - "Fact": "Zezima", - "Type": 0 + "Fact": "\(factString)", + "Type": \(factType) } """ let jsonData = jsonString.data(using: .utf8)! - let decoder = JSONDecoder() - decoder.dataDecodingStrategy = .base64 - let fact = try decoder.decode(Fact.self, from: jsonData) + + let fact = try Fact.decode(jsonData) XCTAssertNoDifference(fact, Fact( - fact: "Zezima", - type: 0 + fact: factString, + type: factType )) - let encoder = JSONEncoder() - encoder.dataEncodingStrategy = .base64 - let encodedFact = try encoder.encode(fact) - let decodedFact = try decoder.decode(Fact.self, from: encodedFact) + let encodedFact = try fact.encode() + let decodedFact = try Fact.decode(encodedFact) XCTAssertNoDifference(decodedFact, fact) }