草庐IT

UNUserNotificationCenterProtocol

全部标签

ios - 单元测试 iOS 10 通知

在我的应用程序中,我希望断言已以正确的格式添加了通知。我通常会使用依赖项注入(inject)来执行此操作,但我想不出一种方法来测试新的UNUserNotificationCenterAPI。我开始创建一个模拟对象来捕获通知请求:importFoundationimportUserNotificationsclassNotificationCenterMock:UNUserNotificationCenter{varrequest:UNNotificationRequest?=niloverridefuncadd(_request:UNNotificationRequest,withCo

ios - 单元测试 iOS 10 通知

在我的应用程序中,我希望断言已以正确的格式添加了通知。我通常会使用依赖项注入(inject)来执行此操作,但我想不出一种方法来测试新的UNUserNotificationCenterAPI。我开始创建一个模拟对象来捕获通知请求:importFoundationimportUserNotificationsclassNotificationCenterMock:UNUserNotificationCenter{varrequest:UNNotificationRequest?=niloverridefuncadd(_request:UNNotificationRequest,withCo