@@ -7,7 +7,7 @@ import RxTest
77@testable import TestMiddleware
88import XCTest
99
10- private func equalAction< A: Action > ( _ by: A ) -> Predicate < A > {
10+ private func equalAction< A: Action & Equatable > ( _ by: A ) -> Predicate < A > {
1111 return Predicate { expression in
1212 guard let action = try expression. evaluate ( ) else {
1313 return PredicateResult ( status: . fail,
@@ -25,22 +25,21 @@ private func equalAction<A: Action>(_ by: A) -> Predicate<A> {
2525final class PrimitiveSequenceTypeTests : XCTestCase {
2626 fileprivate enum Error : Swift . Error { case dummy }
2727
28- class TestCompletableAction : CompletableAction {
28+ class TestCompletableAction : CompletableAction , Equatable {
2929 typealias Payload = Int
3030
3131 let counter : Promise < Payload >
3232
3333 required init ( promise: Promise < Payload > ) {
3434 counter = promise
3535 }
36-
37- func isEqual( to other: Action ) -> Bool {
38- guard let action = other as? TestCompletableAction else { return false }
39- return counter == action. counter
36+
37+ static func == ( lhs: TestCompletableAction , rhs: TestCompletableAction ) -> Bool {
38+ lhs. counter == rhs. counter
4039 }
4140 }
4241
43- class TestKeyedCompletableAction : KeyedCompletableAction {
42+ class TestKeyedCompletableAction : KeyedCompletableAction , Equatable {
4443 typealias Payload = Int
4544 typealias Key = String
4645
@@ -49,23 +48,21 @@ final class PrimitiveSequenceTypeTests: XCTestCase {
4948 required init ( promise: [ Key : Promise < Payload > ] ) {
5049 counterMap = promise
5150 }
52-
53- func isEqual( to other: Action ) -> Bool {
54- guard let action = other as? TestKeyedCompletableAction else { return false }
55- return counterMap == action. counterMap
51+
52+ static func == ( lhs: TestKeyedCompletableAction , rhs: TestKeyedCompletableAction ) -> Bool {
53+ lhs. counterMap == rhs. counterMap
5654 }
5755 }
5856
59- class TestEmptyAction : EmptyAction {
57+ class TestEmptyAction : EmptyAction , Equatable {
6058 let promise : Promise < Void >
6159
6260 required init ( promise: Promise < Void > ) {
6361 self . promise = promise
6462 }
65-
66- func isEqual( to other: Action ) -> Bool {
67- guard let action = other as? TestEmptyAction else { return false }
68- return promise == action. promise
63+
64+ static func == ( lhs: TestEmptyAction , rhs: TestEmptyAction ) -> Bool {
65+ true
6966 }
7067 }
7168
@@ -103,7 +100,9 @@ final class PrimitiveSequenceTypeTests: XCTestCase {
103100 self . testMiddleware. actions ( of: TestCompletableAction . self) . count
104101 ) . toEventually ( be ( 1 ) )
105102
106- expect ( self . testMiddleware. contains ( action: TestCompletableAction ( promise: . error( Error . dummy) ) )
103+ expect ( self . testMiddleware. action ( of: TestCompletableAction . self) {
104+ $0. counter == . error( Error . dummy)
105+ }
107106 ) . toEventually ( beTrue ( ) )
108107 }
109108
@@ -115,7 +114,9 @@ final class PrimitiveSequenceTypeTests: XCTestCase {
115114
116115 expect (
117116 self . testMiddleware
118- . contains ( action: TestKeyedCompletableAction ( promise: [ " hello " : . value( 1 ) ] ) )
117+ . action ( of: TestKeyedCompletableAction . self) {
118+ $0. counterMap == [ " hello " : . value( 1 ) ]
119+ }
119120 ) . toEventually ( beTrue ( ) )
120121 }
121122
@@ -127,7 +128,9 @@ final class PrimitiveSequenceTypeTests: XCTestCase {
127128
128129 expect (
129130 self . testMiddleware
130- . contains ( action: TestKeyedCompletableAction ( promise: [ " hello " : . error( Error . dummy) ] ) )
131+ . action ( of: TestKeyedCompletableAction . self) {
132+ $0. counterMap == [ " hello " : . error( Error . dummy) ]
133+ }
131134 ) . toEventually ( beTrue ( ) )
132135 }
133136
0 commit comments