@@ -36,46 +36,47 @@ public class OneSignalUserMocks: NSObject {
3636
3737 public static func reset( ) {
3838 resetStaticUserExecutor ( )
39- resetUserManager ( )
39+ // TODO: Reset Operation Repo first
40+ // OSCoreMocks.resetOperationRepo()
41+ OneSignalUserManagerImpl . sharedInstance. reset ( )
4042 }
4143
4244 public static func resetStaticUserExecutor( ) {
4345 OSUserExecutor . userRequestQueue. removeAll ( )
4446 OSUserExecutor . transferSubscriptionRequestQueue. removeAll ( )
4547 }
48+ }
49+
50+ extension OSIdentityModelRepo {
51+ func reset( ) {
52+ self . models = [ : ]
53+ }
54+ }
4655
47- /**
56+ extension OneSignalUserManagerImpl {
57+ /**
4858 User Manager needs to reset between tests until we dependency inject the User Manager.
4959 For example, executors it owns may have cached requests or deltas that would have carried over.
5060 This is adapting as more data needs to be considered and reset...
5161 */
52- public static func resetUserManager( ) {
53- OneSignalUserManagerImpl . sharedInstance. identityModelRepo. reset ( )
54-
55- OneSignalUserManagerImpl . sharedInstance. identityModelStore. clearModelsFromStore ( )
56- OneSignalUserManagerImpl . sharedInstance. propertiesModelStore. clearModelsFromStore ( )
57- OneSignalUserManagerImpl . sharedInstance. subscriptionModelStore. clearModelsFromStore ( )
58- OneSignalUserManagerImpl . sharedInstance. pushSubscriptionModelStore. clearModelsFromStore ( )
62+ func reset( ) {
63+ identityModelRepo. reset ( )
5964
60- let propertyExecutor = OSPropertyOperationExecutor ( )
61- let identityExecutor = OSIdentityOperationExecutor ( )
62- let subscriptionExecutor = OSSubscriptionOperationExecutor ( )
65+ // Model store listeners unsubscribe to their models
66+ // User Manager start() will subscribe them
67+ identityModelStoreListener. close ( )
68+ propertiesModelStoreListener. close ( )
69+ subscriptionModelStoreListener. close ( )
70+ pushSubscriptionModelStoreListener. close ( )
6371
64- OneSignalUserManagerImpl . sharedInstance. propertyExecutor = propertyExecutor
65- OneSignalUserManagerImpl . sharedInstance. identityExecutor = identityExecutor
66- OneSignalUserManagerImpl . sharedInstance. subscriptionExecutor = subscriptionExecutor
72+ // Executor instances do no need to be reset, they are initailized in start()
6773
68- // TODO: Reset Operation Repo first
69- // OSCoreMocks.resetOperationRepo()
74+ identityModelStore. clearModelsFromStore ( )
75+ propertiesModelStore. clearModelsFromStore ( )
76+ subscriptionModelStore. clearModelsFromStore ( )
77+ pushSubscriptionModelStore. clearModelsFromStore ( )
7078
71- OSOperationRepo . sharedInstance. addExecutor ( identityExecutor)
72- OSOperationRepo . sharedInstance. addExecutor ( propertyExecutor)
73- OSOperationRepo . sharedInstance. addExecutor ( subscriptionExecutor)
74- }
75- }
76-
77- extension OSIdentityModelRepo {
78- func reset( ) {
79- self . models = [ : ]
79+ _user = nil
80+ hasCalledStart = false
8081 }
8182}
0 commit comments