You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.6 KiB
44 lines
1.6 KiB
import Testing
|
|
@testable import MusubiCore
|
|
|
|
@Suite struct ScreenMatchingTests {
|
|
@Test func matchesByNameRegardlessOfOrder() {
|
|
let ref = ScreenRef(name: "Field Monitor", index: 1)
|
|
#expect(ScreenMatching.index(of: ref, in: ["Field Monitor", "HDMI TO USB"]) == 0)
|
|
}
|
|
|
|
@Test func identicalMonitorsUsePosition() {
|
|
let names = ["LG", "LG", "Built-in"]
|
|
#expect(ScreenMatching.index(of: ScreenRef(name: "LG", index: 1), in: names) == 1)
|
|
#expect(ScreenMatching.index(of: ScreenRef(name: "LG", index: 2), in: names) == 0)
|
|
}
|
|
|
|
@Test func missingScreenIsNil() {
|
|
#expect(ScreenMatching.index(of: ScreenRef(name: "Beamer", index: 0), in: ["Field Monitor"]) == nil)
|
|
}
|
|
|
|
@Test func resolveKeepsFirstClaim() {
|
|
let a = Source(ndiName: "A (a)"), b = Source(ndiName: "B (b)")
|
|
let resolved = ScreenMatching.resolve([
|
|
VideoAssignment(screen: ScreenRef(name: "X", index: 0), source: a),
|
|
VideoAssignment(screen: ScreenRef(name: "X", index: 0), source: b),
|
|
VideoAssignment(screen: ScreenRef(name: "Gone", index: 3), source: b),
|
|
], in: ["X"])
|
|
#expect(resolved == [0: a])
|
|
}
|
|
}
|
|
|
|
@Suite struct ReconcileTests {
|
|
@Test func stopsRemovedStartsNewAndChanged() {
|
|
let plan = Reconcile.plan(current: [1: "A", 2: "B", 3: "C"], desired: [2: "B", 3: "X", 4: "D"])
|
|
#expect(Set(plan.stop) == [1])
|
|
#expect(plan.start == [3: "X", 4: "D"])
|
|
}
|
|
|
|
@Test func nothingToDoWhenEqual() {
|
|
let plan = Reconcile.plan(current: [1: "A"], desired: [1: "A"])
|
|
#expect(plan.stop.isEmpty)
|
|
#expect(plan.start.isEmpty)
|
|
}
|
|
}
|