@@ -150,74 +150,4 @@ final class AggregateRepositoryTests: CoreDataXCTestCase {
150150 } )
151151 wait ( for: [ exp] , timeout: 5 )
152152 }
153-
154- func testCountSubscriptionSuccess( ) {
155- let firstExp = expectation ( description: " Get count of CoreData Movies boxOffice " )
156- let secondExp = expectation ( description: " Get count again after CoreData context is updated " )
157- let result : AnyPublisher < Success < Int > , Failure > = repository. count ( predicate: NSPredicate ( value: true ) , entityDesc: RepoMovie . entity ( ) ) . subscription ( repository)
158- var resultCount = 0
159- let cancellable = result. subscribe ( on: backgroundQueue)
160- . receive ( on: mainQueue)
161- . sink ( receiveCompletion: { completion in
162- switch completion {
163- case . finished:
164- XCTFail ( " Not expecting completion since subscription finishes after subscriber cancel " )
165- default :
166- XCTFail ( " Not expecting failure " )
167- }
168- } , receiveValue: { value in
169- resultCount += 1
170- let aggValue = value. result. first!. values. first!
171- switch resultCount {
172- case 1 :
173- assert ( aggValue == 5 , " Result value (count) should equal number of movies. " )
174- firstExp. fulfill ( )
175- case 2 :
176- assert ( aggValue == 4 , " Result value (count) should equal number of movies. " )
177- secondExp. fulfill ( )
178- default :
179- break
180- }
181- } )
182- wait ( for: [ firstExp] , timeout: 5 )
183- let crudRepository = CRUDRepository ( context: self . backgroundContext)
184- let _: AnyPublisher < CRUDRepository . Success < Movie > , CRUDRepository . Failure < Movie > > = crudRepository. delete ( self . objectIDs. last!)
185- wait ( for: [ secondExp] , timeout: 5 )
186- cancellable. cancel ( )
187- }
188-
189- func testSumSubscriptionSuccess( ) {
190- let firstExp = expectation ( description: " Get count of CoreData Movies boxOffice " )
191- let secondExp = expectation ( description: " Get count again after CoreData context is updated " )
192- var resultCount = 0
193- let result : AnyPublisher < Success < Int > , Failure > = repository. sum ( predicate: NSPredicate ( value: true ) , entityDesc: RepoMovie . entity ( ) , attributeDesc: RepoMovie . entity ( ) . attributesByName. values. first ( where: { $0. name == " boxOffice " } ) !) . subscription ( repository)
194- let cancellable = result. subscribe ( on: backgroundQueue)
195- . receive ( on: mainQueue)
196- . sink ( receiveCompletion: { completion in
197- switch completion {
198- case . finished:
199- XCTFail ( " Not expecting completion since subscription finishes after subscriber cancel " )
200- default :
201- XCTFail ( " Not expecting failure " )
202- }
203- } , receiveValue: { value in
204- resultCount += 1
205- let aggValue = value. result. first!. values. first!
206- switch resultCount {
207- case 1 :
208- assert ( aggValue == 150 , " Result value (count) should equal number of movies. " )
209- firstExp. fulfill ( )
210- case 2 :
211- assert ( aggValue == 150 , " Result value (count) should equal number of movies. " )
212- secondExp. fulfill ( )
213- default :
214- XCTFail ( " Not expecting any values past the first two. " )
215- }
216- } )
217- wait ( for: [ firstExp] , timeout: 10 )
218- let crudRepository = CRUDRepository ( context: self . backgroundContext)
219- let _: AnyPublisher < CRUDRepository . Success < Movie > , CRUDRepository . Failure < Movie > > = crudRepository. delete ( self . objectIDs. last!)
220- wait ( for: [ secondExp] , timeout: 5 )
221- cancellable. cancel ( )
222- }
223153}
0 commit comments