@@ -18,7 +18,7 @@ class SplitTests: XCTestCase {
1818 splitWrapper. getClient ( matchingKey: " key " , bucketingKey: " bucketing " )
1919 let treatment = splitWrapper. getTreatment ( matchingKey: " key " , splitName: " split " , bucketingKey: " bucketing " , attributes: nil )
2020 XCTAssert ( treatment != nil )
21- XCTAssert ( client. getTreatmentCalled )
21+ XCTAssert ( client. methodCalls [ " getTreatment " ] == true )
2222 }
2323
2424 func testGetTreatments( ) {
@@ -27,7 +27,7 @@ class SplitTests: XCTestCase {
2727 splitWrapper. getClient ( matchingKey: " key " , bucketingKey: " bucketing " )
2828 let treatment = splitWrapper. getTreatments ( matchingKey: " key " , splits: [ " split " ] , bucketingKey: " bucketing " , attributes: nil )
2929 XCTAssert ( !treatment. isEmpty)
30- XCTAssert ( client. getTreatmentsCalled )
30+ XCTAssert ( client. methodCalls [ " getTreatments " ] == true )
3131 }
3232
3333 func testGetTreatmentWithConfig( ) {
@@ -36,7 +36,7 @@ class SplitTests: XCTestCase {
3636 splitWrapper. getClient ( matchingKey: " key " , bucketingKey: " bucketing " )
3737 let treatment = splitWrapper. getTreatmentWithConfig ( matchingKey: " key " , splitName: " split " , bucketingKey: " bucketing " , attributes: nil )
3838 XCTAssert ( treatment != nil )
39- XCTAssert ( client. getTreatmentWithConfigCalled )
39+ XCTAssert ( client. methodCalls [ " getTreatmentWithConfig " ] == true )
4040 }
4141
4242 func testGetTreatmentsWithConfig( ) {
@@ -45,7 +45,40 @@ class SplitTests: XCTestCase {
4545 splitWrapper. getClient ( matchingKey: " key " , bucketingKey: " bucketing " )
4646 let treatment = splitWrapper. getTreatmentsWithConfig ( matchingKey: " key " , splits: [ " split " ] , bucketingKey: " bucketing " , attributes: nil )
4747 XCTAssert ( !treatment. isEmpty)
48- XCTAssert ( client. getTreatmentsWithConfigCalled)
48+ XCTAssert ( client. methodCalls [ " getTreatmentsWithConfig " ] == true )
49+ }
50+
51+ func testGetTreatmentsByFlagSet( ) {
52+ let client = SplitClientStub ( )
53+ splitWrapper = DefaultSplitWrapper ( splitFactoryProvider: SplitFactoryProviderStubWithClient ( client: client) )
54+ splitWrapper. getClient ( matchingKey: " key " , bucketingKey: " bucketing " )
55+ let treatment = splitWrapper. getTreatmentsByFlagSet ( matchingKey: " key " , flagSet: " set_1 " , bucketingKey: " bucketing " , attributes: nil )
56+ XCTAssert ( client. methodCalls [ " getTreatmentsByFlagSet " ] == true )
57+ }
58+
59+ func testGetTreatmentsByFlagSets( ) {
60+ let client = SplitClientStub ( )
61+ splitWrapper = DefaultSplitWrapper ( splitFactoryProvider: SplitFactoryProviderStubWithClient ( client: client) )
62+ splitWrapper. getClient ( matchingKey: " key " , bucketingKey: " bucketing " )
63+ let treatment = splitWrapper. getTreatmentsByFlagSets ( matchingKey: " key " , flagSets: [ " set_1 " ] , bucketingKey: " bucketing " , attributes: nil )
64+ XCTAssert ( client. methodCalls [ " getTreatmentsByFlagSets " ] == true )
65+ }
66+
67+ func testGetTreatmentsWithConfigByFlagSet( ) {
68+ let client = SplitClientStub ( )
69+ splitWrapper = DefaultSplitWrapper ( splitFactoryProvider: SplitFactoryProviderStubWithClient ( client: client) )
70+ splitWrapper. getClient ( matchingKey: " key " , bucketingKey: " bucketing " )
71+ let treatment = splitWrapper. getTreatmentsWithConfigByFlagSet ( matchingKey: " key " , flagSet: " set_1 " , bucketingKey: " bucketing " , attributes: nil )
72+ XCTAssert ( client. methodCalls [ " getTreatmentsWithConfigByFlagSet " ] == true )
73+ }
74+
75+ func testGetTreatmentsWithConfigByFlagSets( ) {
76+ let client = SplitClientStub ( )
77+ splitWrapper = DefaultSplitWrapper ( splitFactoryProvider: SplitFactoryProviderStubWithClient ( client: client) )
78+ splitWrapper. getClient ( matchingKey: " key " , bucketingKey: " bucketing " )
79+ let treatment = splitWrapper. getTreatmentsWithConfigByFlagSets ( matchingKey: " key " , flagSets: [ " set_1 " ] , bucketingKey: " bucketing " , attributes: nil )
80+
81+ XCTAssert ( client. methodCalls [ " getTreatmentsWithConfigByFlagSets " ] == true )
4982 }
5083
5184 func testTrack( ) {
@@ -146,7 +179,7 @@ class SplitTests: XCTestCase {
146179 usedKeys. insert ( Key ( matchingKey: " key " , bucketingKey: " bucketing " ) )
147180 splitWrapper = DefaultSplitWrapper ( splitFactoryProvider: SplitFactoryProviderStubWithClient ( client: client) , usedKeys: usedKeys)
148181 splitWrapper. flush ( matchingKey: " key " , bucketingKey: " bucketing " )
149- XCTAssert ( client. flushCalled )
182+ XCTAssert ( ( client. methodCalls [ " flush " ] != nil ) )
150183 }
151184
152185 func testDestroy( ) {
@@ -303,11 +336,17 @@ class SplitFactoryStub: SplitFactory {
303336class SplitClientStub : SplitClient {
304337
305338 var destroyCalled : Bool = false
306- var getTreatmentCalled : Bool = false
307- var getTreatmentWithConfigCalled : Bool = false
308- var getTreatmentsCalled : Bool = false
309- var getTreatmentsWithConfigCalled : Bool = false
310- var flushCalled : Bool = false
339+ var methodCalls = [
340+ " getTreatment " : false ,
341+ " getTreatmentWithConfig " : false ,
342+ " getTreatments " : false ,
343+ " getTreatmentsWithConfig " : false ,
344+ " getTreatmentsByFlagSet " : false ,
345+ " getTreatmentsByFlagSets " : false ,
346+ " getTreatmentsWithConfigByFlagSet " : false ,
347+ " getTreatmentsWithConfigByFlagSets " : false ,
348+ " flush " : false ,
349+ ]
311350 var eventTypeValue : String = " "
312351 var trafficTypeValue : String ?
313352 var valueValue : Double ?
@@ -319,35 +358,55 @@ class SplitClientStub: SplitClient {
319358 var sdkReadyEventAction : SplitAction ?
320359
321360 func getTreatment( _ split: String , attributes: [ String : Any ] ? ) -> String {
322- getTreatmentCalled = true
361+ methodCalls [ " getTreatment " ] = true
323362 return SplitConstants . control
324363 }
325364
326365 func getTreatment( _ split: String ) -> String {
327- getTreatmentCalled = true
366+ methodCalls [ " getTreatment " ] = true
328367 return SplitConstants . control
329368 }
330369
331370 func getTreatments( splits: [ String ] , attributes: [ String : Any ] ? ) -> [ String : String ] {
332- getTreatmentsCalled = true
371+ methodCalls [ " getTreatments " ] = true
333372 return [ " feature " : SplitConstants . control]
334373 }
335374
336375 func getTreatmentWithConfig( _ split: String ) -> SplitResult {
337- getTreatmentWithConfigCalled = true
376+ methodCalls [ " getTreatmentWithConfig " ] = true
338377 return SplitResult ( treatment: SplitConstants . control)
339378 }
340379
341380 func getTreatmentWithConfig( _ split: String , attributes: [ String : Any ] ? ) -> SplitResult {
342- getTreatmentWithConfigCalled = true
381+ methodCalls [ " getTreatmentWithConfig " ] = true
343382 return SplitResult ( treatment: SplitConstants . control)
344383 }
345384
346385 func getTreatmentsWithConfig( splits: [ String ] , attributes: [ String : Any ] ? ) -> [ String : SplitResult ] {
347- getTreatmentsWithConfigCalled = true
386+ methodCalls [ " getTreatmentsWithConfig " ] = true
348387 return [ " feature " : SplitResult ( treatment: SplitConstants . control) ]
349388 }
350389
390+ func getTreatmentsByFlagSet( _ flagSet: String , attributes: [ String : Any ] ? ) -> [ String : String ] {
391+ methodCalls [ " getTreatmentsByFlagSet " ] = true
392+ return [ : ]
393+ }
394+
395+ func getTreatmentsByFlagSets( _ flagSets: [ String ] , attributes: [ String : Any ] ? ) -> [ String : String ] {
396+ methodCalls [ " getTreatmentsByFlagSets " ] = true
397+ return [ : ]
398+ }
399+
400+ func getTreatmentsWithConfigByFlagSet( _ flagSet: String , attributes: [ String : Any ] ? ) -> [ String : SplitResult ] {
401+ methodCalls [ " getTreatmentsWithConfigByFlagSet " ] = true
402+ return [ : ]
403+ }
404+
405+ func getTreatmentsWithConfigByFlagSets( _ flagSets: [ String ] , attributes: [ String : Any ] ? ) -> [ String : SplitResult ] {
406+ methodCalls [ " getTreatmentsWithConfigByFlagSets " ] = true
407+ return [ : ]
408+ }
409+
351410 func on( event: SplitEvent , execute action: @escaping SplitAction ) {
352411 if event == SplitEvent . sdkReady {
353412 sdkReadyEventAction = action
@@ -430,7 +489,7 @@ class SplitClientStub: SplitClient {
430489 }
431490
432491 func flush( ) {
433- flushCalled = true
492+ methodCalls [ " flush " ] = true
434493 }
435494
436495 func destroy( ) {
0 commit comments