feat: Starts manual-d client and adds friction rate calculation and tests.

This commit is contained in:
2025-12-19 11:57:21 -05:00
parent 5b67792051
commit 0aabd612b2
11 changed files with 228 additions and 9 deletions

View File

@@ -0,0 +1,45 @@
import Dependencies
import Foundation
import ManualDClient
import ManualDCore
import Testing
@Suite("ManualDClient Tests")
struct ManualDClientTests {
var numberFormatter: NumberFormatter {
let formatter = NumberFormatter()
formatter.minimumFractionDigits = 2
formatter.maximumFractionDigits = 2
formatter.roundingMode = .halfUp
return formatter
}
@Test
func frictionRate() async throws {
let manualD = ManualDClient.liveValue
let response = try await manualD.frictionRate(
.init(
externalStaticPressure: 0.5,
componentPressureLosses: .mock,
totalEffectiveLength: 185
)
)
#expect(numberFormatter.string(for: response.availableStaticPressure) == "0.11")
#expect(numberFormatter.string(for: response.frictionRate) == "0.06")
}
@Test
func frictionRateFails() async throws {
await #expect(throws: ManualDError.self) {
let manualD = ManualDClient.liveValue
_ = try await manualD.frictionRate(
.init(
externalStaticPressure: 0.5,
componentPressureLosses: .mock,
totalEffectiveLength: 0
)
)
}
}
}