Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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 testNotEmptyAfterAddtrongReference() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in strong

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

omg... I'm sorry about that. I have the correction coming soon.


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)
}

}