Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MulticastDelegateDemo/DemoService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
import MulticastDelegateDemo

protocol DemoServiceDelegate {

Expand Down
49 changes: 35 additions & 14 deletions MulticastDelegateDemoTests/MulticastDelegateDemoTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -275,47 +275,68 @@ class MulticastDelegateDemoTests: XCTestCase {

XCTAssertTrue(multicastDelegate.containsDelegate(delegate))
}

func testContainsDelegateNeverAddedDelegateReturnsFalse() {

let multicastDelegate = MulticastDelegate<TestDelegate>()
let delegate = DelegateTestClass()

XCTAssertFalse(multicastDelegate.containsDelegate(delegate))
}

func testEmptyAfterCreation() {

let multicastDelegate = MulticastDelegate<TestDelegate>()

XCTAssertTrue(multicastDelegate.isEmpty)
}
func testNotEmptyAfterAdd() {

func testNotEmptyAfterAddStrongReference() {

let multicastDelegate = MulticastDelegate<TestDelegate>()
multicastDelegate += DelegateTestClass()

let delegate1 = DelegateTestClass()
multicastDelegate += delegate1

XCTAssertFalse(multicastDelegate.isEmpty)
}

func testNotEmptyAfterDoubleAdd() {


func testNotEmptyAfterDoubleAddStrongReferences() {

let multicastDelegate = MulticastDelegate<TestDelegate>()
let delegate1 = DelegateTestClass()
let delegate2 = DelegateTestClass()
multicastDelegate += delegate1
multicastDelegate += delegate2

XCTAssertFalse(multicastDelegate.isEmpty)
}

// Thank you ARC + Weak References
func testEmptyAfterAddWeakReference() {

let multicastDelegate = MulticastDelegate<TestDelegate>()
multicastDelegate += DelegateTestClass()

XCTAssertTrue(multicastDelegate.isEmpty)
}

func testEmptyAfterDoubleAddWeakReferences() {

let multicastDelegate = MulticastDelegate<TestDelegate>()
multicastDelegate += DelegateTestClass()

XCTAssertFalse(multicastDelegate.isEmpty)
multicastDelegate += DelegateTestClass()

XCTAssertTrue(multicastDelegate.isEmpty)
}

func testEmptyAfterAddAndDelete() {

let multicastDelegate = MulticastDelegate<TestDelegate>()
let delegate = DelegateTestClass()
multicastDelegate += delegate
multicastDelegate -= delegate

XCTAssertTrue(multicastDelegate.isEmpty)
}

}