From 4c0f27350d54a29b9642131bf94f33fc3155d86b Mon Sep 17 00:00:00 2001 From: bragelbytes Date: Fri, 8 Mar 2024 15:10:59 -0800 Subject: [PATCH] Update ShadowSwiftTests.swift --- Tests/ShadowSwiftTests/ShadowSwiftTests.swift | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Tests/ShadowSwiftTests/ShadowSwiftTests.swift b/Tests/ShadowSwiftTests/ShadowSwiftTests.swift index 826bbd5..35ab389 100644 --- a/Tests/ShadowSwiftTests/ShadowSwiftTests.swift +++ b/Tests/ShadowSwiftTests/ShadowSwiftTests.swift @@ -269,6 +269,43 @@ class ShadowSwiftTests: XCTestCase wait(for: [connected], timeout: 3000) } + func testShadowToEchoServer() + { + let message = "Hello".data + let logger = Logger(label: "ShadowToEcho") + let shadowClientConfigPath = FileManager.default.homeDirectoryForCurrentUser.appendingPathComponent("ShadowClientConfig.json") + + guard let shadowClientConfig = ShadowConfig.ShadowClientConfig(path: shadowClientConfigPath.path) else + { + XCTFail() + return + } + + let shadowConnectionFactory = ShadowConnectionFactory(config: shadowClientConfig, logger: logger) + + guard let shadowConnect = shadowConnectionFactory.connect(using: .tcp) else + { + XCTFail() + return + } + + shadowConnect.send(content: message, contentContext: .defaultMessage, isComplete: true, completion: NWConnection.SendCompletion.contentProcessed( + { + (error) in + + if let errorMessage = error + { + print("Error: \(errorMessage)") + XCTFail() + return + } + else + { + print("Send successful.") + } + })) + } + func testShadowSend() throws { let shadowQueue = DispatchQueue(label: "ShadowQueue")