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

Add IsReadyInfo model

parent e92895bd
No related branches found
No related tags found
2 merge requests!130Update Bindings,!102Release 1.0.0
import Foundation
public struct IsReadyInfo: Equatable {
public init(isReady: Bool, howClose: Double) {
self.isReady = isReady
self.howClose = howClose
}
public var isReady: Bool
public var howClose: Double
}
extension IsReadyInfo: Codable {
enum CodingKeys: String, CodingKey {
case isReady = "IsReady"
case howClose = "HowClose"
}
public static func decode(_ data: Data) throws -> Self {
try JSONDecoder().decode(Self.self, from: data)
}
public func encode() throws -> Data {
try JSONEncoder().encode(self)
}
}
import CustomDump
import XCTest
@testable import XXClient
final class IsReadyInfoTests: XCTestCase {
func testCoding() throws {
let jsonString = """
{
"IsReady": true,
"HowClose": 0.534
}
"""
let jsonData = jsonString.data(using: .utf8)!
let model = try IsReadyInfo.decode(jsonData)
XCTAssertNoDifference(model, IsReadyInfo(
isReady: true,
howClose: 0.534
))
let encodedModel = try model.encode()
let decodedModel = try IsReadyInfo.decode(encodedModel)
XCTAssertNoDifference(decodedModel, model)
}
}
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