GetBatteryCarelinkMessageBodyTests.swift 991 B

1234567891011121314151617181920212223242526272829303132
  1. //
  2. // GetBatteryCarelinkMessageBodyTests.swift
  3. // RileyLink
  4. //
  5. // Created by Pete Schwamb on 3/16/16.
  6. // Copyright © 2016 Pete Schwamb. All rights reserved.
  7. //
  8. import XCTest
  9. @testable import MinimedKit
  10. class GetBatteryCarelinkMessageBodyTests: XCTestCase {
  11. func testValidGetBatteryResponse() {
  12. let message = PumpMessage(rxData: Data(hexadecimalString: "a7350535720300008c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")!)
  13. if let message = message {
  14. XCTAssertTrue(message.messageBody is GetBatteryCarelinkMessageBody)
  15. let body = message.messageBody as! GetBatteryCarelinkMessageBody
  16. XCTAssertEqual(body.volts, 1.4)
  17. if case .normal = body.status {
  18. // OK
  19. } else {
  20. XCTFail()
  21. }
  22. } else {
  23. XCTFail("\(String(describing: message)) is nil")
  24. }
  25. }
  26. }