55 lines
1.4 KiB
Swift
55 lines
1.4 KiB
Swift
//
|
|
// VehicleRecordServiceTests.swift
|
|
// AutoCatCoreTests
|
|
//
|
|
// Created by Selim Mustafaev on 16.03.2025.
|
|
// Copyright © 2025 Selim Mustafaev. All rights reserved.
|
|
//
|
|
|
|
import Testing
|
|
import Mockable
|
|
import AutoCatCore
|
|
|
|
struct VehicleRecordServiceTests {
|
|
|
|
let storageServiceMock = MockStorageServiceProtocol()
|
|
let locationServiceMock: MockLocationServiceProtocol
|
|
let audioRecordServiceMock = MockAudioRecordServiceProtocol()
|
|
|
|
let vehicleRecordService: VehicleRecordService
|
|
init() async {
|
|
|
|
self.locationServiceMock = await .init()
|
|
|
|
self.vehicleRecordService = .init(
|
|
recordService: audioRecordServiceMock,
|
|
storageService: storageServiceMock,
|
|
locationService: locationServiceMock
|
|
)
|
|
}
|
|
|
|
@Test("Requesting permissions")
|
|
func requestPermissions() async throws {
|
|
|
|
given(audioRecordServiceMock)
|
|
.requestRecordPermissions()
|
|
.willReturn(true)
|
|
|
|
given(audioRecordServiceMock)
|
|
.requestRecognitionAuthorization()
|
|
.willReturn(.authorized)
|
|
|
|
await vehicleRecordService.requestPermissionsIfNeeded()
|
|
|
|
verify(audioRecordServiceMock)
|
|
.requestRecordPermissions()
|
|
.called(.once)
|
|
|
|
verify(audioRecordServiceMock)
|
|
.requestRecognitionAuthorization()
|
|
.called(.once)
|
|
}
|
|
|
|
|
|
}
|