DetermineBasalEnableSmbTests.swift 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. import Foundation
  2. import Testing
  3. @testable import Trio
  4. @Suite("DosingEngine: shouldEnableSmb Tests") struct DetermineBasalEnableSmbTests {
  5. /// Helper to create a default set of inputs.
  6. /// Each test can then modify the specific properties relevant to its case.
  7. private func createDefaultInputs() -> (
  8. profile: Profile,
  9. meal: ComputedCarbs,
  10. currentGlucose: Decimal,
  11. adjustedTargetGlucose: Decimal,
  12. adjustedSensitivity: Decimal,
  13. minGuardGlucose: Decimal,
  14. eventualGlucose: Decimal,
  15. threshold: Decimal,
  16. glucoseStatus: GlucoseStatus,
  17. trioCustomOrefVariables: TrioCustomOrefVariables,
  18. clock: Date
  19. ) {
  20. var profile = Profile()
  21. // Ensure default is false so we can test enabling conditions.
  22. profile.enableSMBAlways = false
  23. profile.temptargetSet = false
  24. let meal = ComputedCarbs(
  25. carbs: 0,
  26. mealCOB: 0,
  27. currentDeviation: 0,
  28. maxDeviation: 0,
  29. minDeviation: 0,
  30. slopeFromMaxDeviation: 0,
  31. slopeFromMinDeviation: 0,
  32. allDeviations: [],
  33. lastCarbTime: Date().timeIntervalSince1970
  34. )
  35. let glucoseStatus = GlucoseStatus(
  36. delta: 0,
  37. glucose: 120,
  38. noise: 0,
  39. shortAvgDelta: 0,
  40. longAvgDelta: 0,
  41. date: Date(),
  42. lastCalIndex: nil,
  43. device: "test"
  44. )
  45. let trioCustomOrefVariables = TrioCustomOrefVariables(
  46. average_total_data: 0,
  47. weightedAverage: 0,
  48. currentTDD: 0,
  49. past2hoursAverage: 0,
  50. date: Date(),
  51. overridePercentage: 100,
  52. useOverride: false,
  53. duration: 0,
  54. unlimited: false,
  55. overrideTarget: 0,
  56. smbIsOff: false,
  57. advancedSettings: false,
  58. isfAndCr: false,
  59. isf: false,
  60. cr: false,
  61. smbIsScheduledOff: false,
  62. start: 0,
  63. end: 0,
  64. smbMinutes: 0,
  65. uamMinutes: 0,
  66. shouldProtectDueToHIGH: false
  67. )
  68. return (
  69. profile: profile,
  70. meal: meal,
  71. currentGlucose: 120,
  72. adjustedTargetGlucose: 100,
  73. adjustedSensitivity: 50,
  74. minGuardGlucose: 110,
  75. eventualGlucose: 115,
  76. threshold: 70,
  77. glucoseStatus: glucoseStatus,
  78. trioCustomOrefVariables: trioCustomOrefVariables,
  79. clock: Date()
  80. )
  81. }
  82. // MARK: - Disabling Conditions
  83. @Test("Should return false by default with no enabling preferences") func defaultIsFalse() throws {
  84. let inputs = createDefaultInputs()
  85. let decision = try DosingEngine.shouldEnableSmb(
  86. profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
  87. adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
  88. minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
  89. threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
  90. trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
  91. )
  92. #expect(decision.isEnabled == false)
  93. }
  94. @Test("Should disable SMB when smbIsOff is true") func disableWhenSmbIsOff() throws {
  95. var inputs = createDefaultInputs()
  96. inputs.trioCustomOrefVariables.smbIsOff = true
  97. inputs.profile.enableSMBAlways = true // Ensure smbIsOff takes precedence
  98. let decision = try DosingEngine.shouldEnableSmb(
  99. profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
  100. adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
  101. minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
  102. threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
  103. trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
  104. )
  105. #expect(decision.isEnabled == false)
  106. }
  107. @Test("Should disable SMB when shouldProtectDueToHIGH is true") func disableWhenProtectDueToHigh() throws {
  108. var inputs = createDefaultInputs()
  109. inputs.trioCustomOrefVariables.shouldProtectDueToHIGH = true
  110. inputs.profile.enableSMBAlways = true // Ensure protection takes precedence
  111. let decision = try DosingEngine.shouldEnableSmb(
  112. profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
  113. adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
  114. minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
  115. threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
  116. trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
  117. )
  118. #expect(decision.isEnabled == false)
  119. }
  120. @Test("Should disable SMB with high temp target when not allowed") func disableWithHighTempTarget() throws {
  121. var inputs = createDefaultInputs()
  122. inputs.profile.allowSMBWithHighTemptarget = false
  123. inputs.profile.temptargetSet = true
  124. inputs.adjustedTargetGlucose = 120
  125. let decision = try DosingEngine.shouldEnableSmb(
  126. profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
  127. adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
  128. minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
  129. threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
  130. trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
  131. )
  132. #expect(decision.isEnabled == false)
  133. }
  134. @Test("Should disable SMB when minGuardGlucose is below threshold") func disableWhenMinGuardBelowThreshold() throws {
  135. var inputs = createDefaultInputs()
  136. inputs.profile.enableSMBAlways = true // Enable SMB initially to test the safety override
  137. inputs.minGuardGlucose = 65
  138. inputs.threshold = 70
  139. let decision = try DosingEngine.shouldEnableSmb(
  140. profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
  141. adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
  142. minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
  143. threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
  144. trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
  145. )
  146. #expect(decision.isEnabled == false)
  147. #expect(decision.manualBolusError == 1)
  148. #expect(decision.minGuardGlucose == 65)
  149. #expect(decision.insulinForManualBolus != nil)
  150. }
  151. @Test("Should disable SMB when maxDelta is too high") func disableWhenMaxDeltaTooHigh() throws {
  152. var inputs = createDefaultInputs()
  153. inputs.profile.enableSMBAlways = true // Enable SMB initially
  154. inputs.profile.maxDeltaBgThreshold = 0.2
  155. inputs.currentGlucose = 100
  156. // Set maxDelta to be > 20% of currentGlucose
  157. inputs.glucoseStatus = GlucoseStatus(
  158. delta: 21,
  159. glucose: 100,
  160. noise: 0,
  161. shortAvgDelta: 5,
  162. longAvgDelta: 5,
  163. date: Date(),
  164. lastCalIndex: nil,
  165. device: "test"
  166. )
  167. let decision = try DosingEngine.shouldEnableSmb(
  168. profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
  169. adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
  170. minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
  171. threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
  172. trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
  173. )
  174. #expect(decision.isEnabled == false)
  175. #expect(decision.reason != nil)
  176. }
  177. // MARK: - Enabling Conditions
  178. @Test("Should enable SMB when enableSMBAlways is true") func enableWhenAlwaysOn() throws {
  179. var inputs = createDefaultInputs()
  180. inputs.profile.enableSMBAlways = true
  181. let decision = try DosingEngine.shouldEnableSmb(
  182. profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
  183. adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
  184. minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
  185. threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
  186. trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
  187. )
  188. #expect(decision.isEnabled == true)
  189. }
  190. @Test("Should enable SMB with COB") func enableWithCob() throws {
  191. var inputs = createDefaultInputs()
  192. inputs.profile.enableSMBWithCOB = true
  193. inputs.meal = ComputedCarbs(
  194. carbs: 20,
  195. mealCOB: 10,
  196. currentDeviation: 0,
  197. maxDeviation: 0,
  198. minDeviation: 0,
  199. slopeFromMaxDeviation: 0,
  200. slopeFromMinDeviation: 0,
  201. allDeviations: [],
  202. lastCarbTime: Date().timeIntervalSince1970
  203. )
  204. let decision = try DosingEngine.shouldEnableSmb(
  205. profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
  206. adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
  207. minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
  208. threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
  209. trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
  210. )
  211. #expect(decision.isEnabled == true)
  212. }
  213. @Test("Should enable SMB after carbs") func enableAfterCarbs() throws {
  214. var inputs = createDefaultInputs()
  215. inputs.profile.enableSMBAfterCarbs = true
  216. inputs.meal = ComputedCarbs(
  217. carbs: 20,
  218. mealCOB: 0,
  219. currentDeviation: 0,
  220. maxDeviation: 0,
  221. minDeviation: 0,
  222. slopeFromMaxDeviation: 0,
  223. slopeFromMinDeviation: 0,
  224. allDeviations: [],
  225. lastCarbTime: Date().timeIntervalSince1970
  226. )
  227. let decision = try DosingEngine.shouldEnableSmb(
  228. profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
  229. adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
  230. minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
  231. threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
  232. trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
  233. )
  234. #expect(decision.isEnabled == true)
  235. }
  236. @Test("Should enable SMB with low temp target") func enableWithLowTempTarget() throws {
  237. var inputs = createDefaultInputs()
  238. inputs.profile.enableSMBWithTemptarget = true
  239. inputs.profile.temptargetSet = true
  240. inputs.adjustedTargetGlucose = 90
  241. let decision = try DosingEngine.shouldEnableSmb(
  242. profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
  243. adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
  244. minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
  245. threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
  246. trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
  247. )
  248. #expect(decision.isEnabled == true)
  249. }
  250. @Test("Should enable SMB for high BG") func enableWithHighBg() throws {
  251. var inputs = createDefaultInputs()
  252. inputs.profile.enableSMBHighBg = true
  253. inputs.profile.enableSMBHighBgTarget = 140
  254. inputs.currentGlucose = 145
  255. let decision = try DosingEngine.shouldEnableSmb(
  256. profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
  257. adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
  258. minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
  259. threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
  260. trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
  261. )
  262. #expect(decision.isEnabled == true)
  263. }
  264. // MARK: - Scheduled Off Tests
  265. @Test("Scheduled Off (Normal): should disable SMB inside the window") func scheduledOffNormal_Inside() throws {
  266. var inputs = createDefaultInputs()
  267. inputs.profile.enableSMBAlways = true // Ensure schedule is the only reason for failure
  268. inputs.trioCustomOrefVariables.smbIsScheduledOff = true
  269. inputs.trioCustomOrefVariables.start = 9 // 9 AM
  270. inputs.trioCustomOrefVariables.end = 17 // 5 PM
  271. inputs.clock = Calendar.current.date(bySettingHour: 14, minute: 0, second: 0, of: Date())!
  272. let decision = try DosingEngine.shouldEnableSmb(
  273. profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
  274. adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
  275. minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
  276. threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
  277. trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
  278. )
  279. #expect(decision.isEnabled == false)
  280. }
  281. @Test("Scheduled Off (Normal): should NOT disable SMB outside the window") func scheduledOffNormal_Outside() throws {
  282. var inputs = createDefaultInputs()
  283. inputs.profile.enableSMBAlways = true
  284. inputs.trioCustomOrefVariables.smbIsScheduledOff = true
  285. inputs.trioCustomOrefVariables.start = 9 // 9 AM
  286. inputs.trioCustomOrefVariables.end = 17 // 5 PM
  287. inputs.clock = Calendar.current.date(bySettingHour: 18, minute: 0, second: 0, of: Date())!
  288. let decision = try DosingEngine.shouldEnableSmb(
  289. profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
  290. adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
  291. minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
  292. threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
  293. trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
  294. )
  295. #expect(decision.isEnabled == true)
  296. }
  297. @Test(
  298. "Scheduled Off (Wrapping): should disable SMB inside the window (after midnight)"
  299. ) func scheduledOffWrapping_InsideAfterMidnight() throws {
  300. var inputs = createDefaultInputs()
  301. inputs.profile.enableSMBAlways = true
  302. inputs.trioCustomOrefVariables.smbIsScheduledOff = true
  303. inputs.trioCustomOrefVariables.start = 22 // 10 PM
  304. inputs.trioCustomOrefVariables.end = 6 // 6 AM
  305. inputs.clock = Calendar.current.date(bySettingHour: 2, minute: 0, second: 0, of: Date())!
  306. let decision = try DosingEngine.shouldEnableSmb(
  307. profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
  308. adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
  309. minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
  310. threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
  311. trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
  312. )
  313. #expect(decision.isEnabled == false)
  314. }
  315. @Test(
  316. "Scheduled Off (Wrapping): should disable SMB inside the window (before midnight)"
  317. ) func scheduledOffWrapping_InsideBeforeMidnight() throws {
  318. var inputs = createDefaultInputs()
  319. inputs.profile.enableSMBAlways = true
  320. inputs.trioCustomOrefVariables.smbIsScheduledOff = true
  321. inputs.trioCustomOrefVariables.start = 22 // 10 PM
  322. inputs.trioCustomOrefVariables.end = 6 // 6 AM
  323. inputs.clock = Calendar.current.date(bySettingHour: 23, minute: 0, second: 0, of: Date())!
  324. let decision = try DosingEngine.shouldEnableSmb(
  325. profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
  326. adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
  327. minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
  328. threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
  329. trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
  330. )
  331. #expect(decision.isEnabled == false)
  332. }
  333. @Test("Scheduled Off (Wrapping): should NOT disable SMB outside the window") func scheduledOffWrapping_Outside() throws {
  334. var inputs = createDefaultInputs()
  335. inputs.profile.enableSMBAlways = true
  336. inputs.trioCustomOrefVariables.smbIsScheduledOff = true
  337. inputs.trioCustomOrefVariables.start = 22 // 10 PM
  338. inputs.trioCustomOrefVariables.end = 6 // 6 AM
  339. inputs.clock = Calendar.current.date(bySettingHour: 12, minute: 0, second: 0, of: Date())!
  340. let decision = try DosingEngine.shouldEnableSmb(
  341. profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
  342. adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
  343. minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
  344. threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
  345. trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
  346. )
  347. #expect(decision.isEnabled == true)
  348. }
  349. @Test("Scheduled Off (All Day): should disable SMB") func scheduledOffAllDay() throws {
  350. var inputs = createDefaultInputs()
  351. inputs.profile.enableSMBAlways = true
  352. inputs.trioCustomOrefVariables.smbIsScheduledOff = true
  353. inputs.trioCustomOrefVariables.start = 0
  354. inputs.trioCustomOrefVariables.end = 0
  355. inputs.clock = Calendar.current.date(bySettingHour: 15, minute: 0, second: 0, of: Date())!
  356. let decision = try DosingEngine.shouldEnableSmb(
  357. profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
  358. adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
  359. minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
  360. threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
  361. trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
  362. )
  363. #expect(decision.isEnabled == false)
  364. }
  365. @Test("Scheduled Off (Single Hour): should disable SMB inside the window") func scheduledOffSingleHour_Inside() throws {
  366. var inputs = createDefaultInputs()
  367. inputs.profile.enableSMBAlways = true
  368. inputs.trioCustomOrefVariables.smbIsScheduledOff = true
  369. inputs.trioCustomOrefVariables.start = 11 // 11 AM
  370. inputs.trioCustomOrefVariables.end = 11 // 11 AM
  371. inputs.clock = Calendar.current.date(bySettingHour: 11, minute: 30, second: 0, of: Date())!
  372. let decision = try DosingEngine.shouldEnableSmb(
  373. profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
  374. adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
  375. minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
  376. threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
  377. trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
  378. )
  379. #expect(decision.isEnabled == false)
  380. }
  381. @Test("Scheduled Off (Single Hour): should NOT disable SMB outside the window") func scheduledOffSingleHour_Outside() throws {
  382. var inputs = createDefaultInputs()
  383. inputs.profile.enableSMBAlways = true
  384. inputs.trioCustomOrefVariables.smbIsScheduledOff = true
  385. inputs.trioCustomOrefVariables.start = 11 // 11 AM
  386. inputs.trioCustomOrefVariables.end = 11 // 11 AM
  387. inputs.clock = Calendar.current.date(bySettingHour: 12, minute: 0, second: 0, of: Date())!
  388. let decision = try DosingEngine.shouldEnableSmb(
  389. profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
  390. adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
  391. minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
  392. threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
  393. trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
  394. )
  395. #expect(decision.isEnabled == true)
  396. }
  397. }