import Foundation
import Testing
import WireProtocol
import HostRegistry

@Test("Host Codable 往返:id/name/endpoint 全保真(originHeader 重派生一致)")
func hostCodableRoundTripPreservesAllFields() throws {
    // Arrange
    let host = Fixtures.makeHost(name: "studio", urlString: "https://mac.ts.net:8443")

    // Act
    let data = try JSONEncoder().encode(host)
    let decoded = try JSONDecoder().decode(Host.self, from: data)

    // Assert
    #expect(decoded == host)
    #expect(decoded.endpoint.originHeader == "https://mac.ts.net:8443")
}

@Test("Identifiable:Host.id 即协议 id")
func hostIdentifiableIdIsItsOwnId() {
    // Arrange / Act
    let host = Fixtures.makeHost()

    // Assert
    let identifiable: any Identifiable<UUID> = host
    #expect(identifiable.id == host.id)
}
