PluginManagerTests.swift 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. @testable import FreeAPS
  2. import Swinject
  3. import XCTest
  4. class PluginManagerTests: XCTestCase, Injectable {
  5. let fileStorage = BaseFileStorage()
  6. @Injected() var pluginManager: PluginManager!
  7. let resolver = FreeAPSApp().resolver
  8. override func setUp() {
  9. injectServices(resolver)
  10. }
  11. func testCGMManagerLoad() {
  12. let cgmLoopManagers = pluginManager.availableCGMManagers
  13. XCTAssertNotNil(cgmLoopManagers)
  14. XCTAssertTrue(!cgmLoopManagers.isEmpty)
  15. if let cgmLoop = cgmLoopManagers.first {
  16. let cgmLoopManager = pluginManager.getCGMManagerTypeByIdentifier(cgmLoop.identifier)
  17. XCTAssertNotNil(cgmLoopManager)
  18. } else {
  19. XCTFail("Not found CGM loop manager")
  20. }
  21. /// try to load a Pump manager with a CGM identifier
  22. if let cgmLoop = cgmLoopManagers.last {
  23. let cgmLoopManager = pluginManager.getPumpManagerTypeByIdentifier(cgmLoop.identifier)
  24. XCTAssertNil(cgmLoopManager)
  25. } else {
  26. XCTFail("Not found CGM loop manager")
  27. }
  28. }
  29. func testPumpManagerLoad() {
  30. let pumpLoopManagers = pluginManager.availablePumpManagers
  31. XCTAssertNotNil(pumpLoopManagers)
  32. XCTAssertTrue(!pumpLoopManagers.isEmpty)
  33. if let pumpLoop = pumpLoopManagers.first {
  34. let pumpLoopManager = pluginManager.getPumpManagerTypeByIdentifier(pumpLoop.identifier)
  35. XCTAssertNotNil(pumpLoopManager)
  36. } else {
  37. XCTFail("Not found pump loop manager")
  38. }
  39. /// try to load a CGM manager with a pump identifier
  40. if let pumpLoop = pumpLoopManagers.last {
  41. let pumpLoopManager = pluginManager.getCGMManagerTypeByIdentifier(pumpLoop.identifier)
  42. XCTAssertNil(pumpLoopManager)
  43. } else {
  44. XCTFail("Not found pump loop manager")
  45. }
  46. }
  47. func testServiceManagerLoad() {
  48. let serviceManagers = pluginManager.availableServices
  49. XCTAssertNotNil(serviceManagers)
  50. XCTAssertTrue(!serviceManagers.isEmpty)
  51. if let serviceLoop = serviceManagers.first {
  52. let serviceManager = pluginManager.getServiceTypeByIdentifier(serviceLoop.identifier)
  53. XCTAssertNotNil(serviceManager)
  54. } else {
  55. XCTFail("Not found Service loop manager")
  56. }
  57. }
  58. override func setUpWithError() throws {
  59. // Put setup code here. This method is called before the invocation of each test method in the class.
  60. }
  61. override func tearDownWithError() throws {
  62. // Put teardown code here. This method is called after the invocation of each test method in the class.
  63. }
  64. }