// // BasalRateScheduleTests.swift // Naterade // // Created by Nathan Racklyeft on 2/5/16. // Copyright © 2016 Nathan Racklyeft. All rights reserved. // import XCTest @testable import LoopKit func ==(lhs: RepeatingScheduleValue, rhs: RepeatingScheduleValue) -> Bool { return lhs.startTime == rhs.startTime && lhs.value == rhs.value } func ==(lhs: AbsoluteScheduleValue, rhs: AbsoluteScheduleValue) -> Bool { return lhs.startDate == rhs.startDate && lhs.endDate == rhs.endDate && lhs.value == rhs.value } func ==(lhs: ArraySlice>, rhs: ArraySlice>) -> Bool { guard lhs.count == rhs.count else { return false } for (l, r) in zip(lhs, rhs) { if !(l == r) { return false } } return true } class BasalRateScheduleTests: XCTestCase { var items: [RepeatingScheduleValue]! override func setUp() { super.setUp() let path = Bundle(for: type(of: self)).path(forResource: "basal", ofType: "json")! let fixture = try! JSONSerialization.jsonObject(with: Data(contentsOf: URL(fileURLWithPath: path)), options: []) as! [JSONDictionary] items = fixture.map { return RepeatingScheduleValue(startTime: TimeInterval(minutes: $0["minutes"] as! Double), value: $0["rate"] as! Double) } } func testBasalScheduleRanges() { let schedule = BasalRateSchedule(dailyItems: items, timeZone: nil)! let calendar = Calendar.current let midnight = calendar.startOfDay(for: Date()) var absoluteItems: [AbsoluteScheduleValue] = (0..