- Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathTestNotification.swift
41 lines (34 loc) · 1.66 KB
/
TestNotification.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
classTestNotification:XCTestCase{
func test_customReflection(){
letsomeName="somenotifname"
lettargetObject=NSObject()
letuserInfo=["hello":"world","indexThis":350]as[AnyHashable:Any]
letnotif=Notification(name:Notification.Name(rawValue: someName), object: targetObject, userInfo: userInfo)
letmirror= notif.customMirror
XCTAssertEqual(mirror.displayStyle,.class)
XCTAssertNil(mirror.superclassMirror)
varchildren=Array(mirror.children).makeIterator()
letfirstChild= children.next()
letsecondChild= children.next()
letthirdChild= children.next()
XCTAssertEqual(firstChild?.label,"name")
XCTAssertEqual(firstChild?.value as?String, someName)
XCTAssertEqual(secondChild?.label,"object")
XCTAssertEqual(secondChild?.value as?NSObject, targetObject)
XCTAssertEqual(thirdChild?.label,"userInfo")
XCTAssertEqual((thirdChild?.value as?[AnyHashable:Any])?["hello"]as?String,"world")
XCTAssertEqual((thirdChild?.value as?[AnyHashable:Any])?["indexThis"]as?Int,350)
}
func test_NotificationNameInit(){
letname="TestNotificationNameInit"
XCTAssertEqual(Notification.Name(name),Notification.Name(rawValue: name))
}
}