Add tests for PrinterRequestManager , remove singleton implementation in favor of view constructor arguments
This commit is contained in:
33
SoyuzTests/PrinterRequestManagerTests.swift
Normal file
33
SoyuzTests/PrinterRequestManagerTests.swift
Normal file
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// PrinterRequestsManagerTests.swift
|
||||
// SoyuzTests
|
||||
//
|
||||
// Created by maddiefuzz on 2/21/23.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
import Network
|
||||
@testable import Soyuz
|
||||
|
||||
class PrinterRequestManagerTests: XCTestCase {
|
||||
var printerRequestManager: PrinterRequestManager?
|
||||
|
||||
var testBonjourListener: NWListener?
|
||||
|
||||
override func setUp() {
|
||||
printerRequestManager = PrinterRequestManager(browser: NWBrowser(for: .bonjour(type: "_http._tcp", domain: "local."), using: .tcp))
|
||||
|
||||
// Set up test bonjour server
|
||||
//let parameters = NWParameters(tls: .none, tcp: NWListener.)
|
||||
do {
|
||||
testBonjourListener = try NWListener(using: .tcp, on: .http)
|
||||
testBonjourListener!.start(queue: DispatchQueue.main)
|
||||
} catch {
|
||||
print("Error: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
func testBonjourDiscoveredItemsNotNil() {
|
||||
XCTAssertNotNil(printerRequestManager?.nwBrowserDiscoveredItems)
|
||||
}
|
||||
}
|
@@ -1,24 +0,0 @@
|
||||
//
|
||||
// PrinterRequestsManagerTests.swift
|
||||
// SoyuzTests
|
||||
//
|
||||
// Created by maddiefuzz on 2/21/23.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import Soyuz
|
||||
|
||||
class FileHandleMock: FileHandle {
|
||||
override func write(_ data: Data) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
class PrinterRequestManagerTests: XCTestCase {
|
||||
var printerRequestsManager: PrinterRequestManager?
|
||||
|
||||
override func setUp() {
|
||||
printerRequestsManager = PrinterRequestManager.shared
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user