Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion UnitTests/MPAppNotificationHandlerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ @interface MParticle ()
+ (dispatch_queue_t)messageQueue;
@property (nonatomic, strong) MPStateMachine_PRIVATE *stateMachine;
@property (nonatomic, strong, readonly) MPAppNotificationHandler *appNotificationHandler;
@property (nonatomic, strong, readonly) MPPersistenceController *persistenceController;
@property (nonatomic, strong, readonly) MPPersistenceController_PRIVATE *persistenceController;

@end

Expand Down
211 changes: 105 additions & 106 deletions UnitTests/MPBackendControllerTests.m

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions UnitTests/MPBaseTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#import "MPIConstants.h"

@interface MParticle (Tests)
@property (nonatomic, strong) MPPersistenceController *persistenceController;
@property (nonatomic, strong) MPPersistenceController_PRIVATE *persistenceController;
@end

@interface MPTestConnectorFactory : NSObject <MPConnectorFactoryProtocol>
Expand All @@ -39,7 +39,7 @@ - (void)setUpWithCompletionHandler:(void (^)(NSError * _Nullable))completion {
MParticle *instance = [MParticle sharedInstance];
if (!instance.persistenceController) {
// Ensure we have a persistence controller to reset the db etc
instance.persistenceController = [[MPPersistenceController alloc] init];
instance.persistenceController = [[MPPersistenceController_PRIVATE alloc] init];
}

[instance reset:^{
Expand Down
2 changes: 1 addition & 1 deletion UnitTests/MPCustomModuleTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ - (NSDictionary *)customModuleConfiguration {

- (void)setUp {
[super setUp];
[MPPersistenceController setMpid:@1];
[MPPersistenceController_PRIVATE setMpid:@1];
}

- (void)testConfiguration {
Expand Down
17 changes: 9 additions & 8 deletions UnitTests/MPDataModelTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#import "MPPersistenceController.h"
#import "MPBaseTestCase.h"
#import "mParticle.h"
#import "MParticleSwift.h"

@interface MParticle ()

Expand All @@ -29,7 +30,7 @@ - (void)setUp {
}

- (void)testSessionInstance {
MPSession *session = [[MPSession alloc] initWithStartTime:[[NSDate date] timeIntervalSince1970] userId:[MPPersistenceController mpId]];
MPSession *session = [[MPSession alloc] initWithStartTime:[[NSDate date] timeIntervalSince1970] userId:[MPPersistenceController_PRIVATE mpId]];
XCTAssertNotNil(session, @"Should not have been nil");

MPSession *sessionCopy = [session copy];
Expand Down Expand Up @@ -63,7 +64,7 @@ - (void)testSessionInstance {
}

- (void)testMessageInstance {
MPSession *session = [[MPSession alloc] initWithStartTime:[[NSDate date] timeIntervalSince1970] userId:[MPPersistenceController mpId]];
MPSession *session = [[MPSession alloc] initWithStartTime:[[NSDate date] timeIntervalSince1970] userId:[MPPersistenceController_PRIVATE mpId]];

MPMessageBuilder *messageBuilder = [[MPMessageBuilder alloc] initWithMessageType:MPMessageTypeEvent
session:session
Expand Down Expand Up @@ -149,7 +150,7 @@ - (void)testFixInvalidKeysInDictionary {
}

- (void)testMessageInstanceWithInfinite {
MPSession *session = [[MPSession alloc] initWithStartTime:[[NSDate date] timeIntervalSince1970] userId:[MPPersistenceController mpId]];
MPSession *session = [[MPSession alloc] initWithStartTime:[[NSDate date] timeIntervalSince1970] userId:[MPPersistenceController_PRIVATE mpId]];

double four = 4.0;
double zed = 0.0;
Expand Down Expand Up @@ -185,7 +186,7 @@ - (void)testMessageInstanceWithInfinite {
}

- (void)testUploadInstance {
MPSession *session = [[MPSession alloc] initWithStartTime:[[NSDate date] timeIntervalSince1970] userId:[MPPersistenceController mpId]];
MPSession *session = [[MPSession alloc] initWithStartTime:[[NSDate date] timeIntervalSince1970] userId:[MPPersistenceController_PRIVATE mpId]];

MPMessageBuilder *messageBuilder = [[MPMessageBuilder alloc] initWithMessageType:MPMessageTypeEvent
session:session
Expand All @@ -199,7 +200,7 @@ - (void)testUploadInstance {
kMPMessagesKey:@[[message dictionaryRepresentation]],
kMPMessageIdKey:[[NSUUID UUID] UUIDString]};

MPUpload *upload = [[MPUpload alloc] initWithSessionId:[NSNumber numberWithLongLong:session.sessionId] uploadDictionary:uploadDictionary dataPlanId:@"test" dataPlanVersion:@(1) uploadSettings:[MPUploadSettings currentUploadSettings]];
MPUpload *upload = [[MPUpload alloc] initWithSessionId:[NSNumber numberWithLongLong:session.sessionId] uploadDictionary:uploadDictionary dataPlanId:@"test" dataPlanVersion:@(1) uploadSettings:[MPUploadSettings currentUploadSettingsWithStateMachine:[MParticle sharedInstance].stateMachine networkOptions:[MParticle sharedInstance].networkOptions]];
XCTAssertNotNil(upload, @"Should not have been nil.");

NSString *description = [upload description];
Expand Down Expand Up @@ -227,7 +228,7 @@ - (void)testUploadInstance {
}

- (void)testBreadcrumbInstance {
MPSession *session = [[MPSession alloc] initWithStartTime:[[NSDate date] timeIntervalSince1970] userId:[MPPersistenceController mpId]];
MPSession *session = [[MPSession alloc] initWithStartTime:[[NSDate date] timeIntervalSince1970] userId:[MPPersistenceController_PRIVATE mpId]];

MPMessageBuilder *messageBuilder = [[MPMessageBuilder alloc] initWithMessageType:MPMessageTypeEvent
session:session
Expand Down Expand Up @@ -275,7 +276,7 @@ - (void)testBreadcrumbInstance {
}

- (void)testMessageEncoding {
MPSession *session = [[MPSession alloc] initWithStartTime:[[NSDate date] timeIntervalSince1970] userId:[MPPersistenceController mpId]];
MPSession *session = [[MPSession alloc] initWithStartTime:[[NSDate date] timeIntervalSince1970] userId:[MPPersistenceController_PRIVATE mpId]];

MPMessageBuilder *messageBuilder = [[MPMessageBuilder alloc] initWithMessageType:MPMessageTypeEvent
session:session
Expand All @@ -290,7 +291,7 @@ - (void)testMessageEncoding {
}

- (void)testBreadcrumbEncoding {
MPSession *session = [[MPSession alloc] initWithStartTime:[[NSDate date] timeIntervalSince1970] userId:[MPPersistenceController mpId]];
MPSession *session = [[MPSession alloc] initWithStartTime:[[NSDate date] timeIntervalSince1970] userId:[MPPersistenceController_PRIVATE mpId]];

MPMessageBuilder *messageBuilder = [[MPMessageBuilder alloc] initWithMessageType:MPMessageTypeEvent
session:session
Expand Down
12 changes: 10 additions & 2 deletions UnitTests/MPDeviceTests.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import "MPDevice.h"
#import "MPIUserDefaults.h"
#import "mParticle.h"
#import "MPIConstants.h"
#import "MParticleSwift.h"

@interface MParticle ()

@property (nonatomic, strong, readonly) MPStateMachine_PRIVATE *stateMachine;
@property (nonatomic, strong, nonnull) MPBackendController_PRIVATE *backendController;

@end

@interface MPDeviceTests : XCTestCase

Expand All @@ -23,7 +31,7 @@ - (void)testTelephonyRadioAccessTechnology {

- (void)testDictionaryDescription {
#if TARGET_OS_IOS == 1
MPIUserDefaults *userDefaults = [MPIUserDefaults standardUserDefaults];
MPUserDefaults *userDefaults = [MPUserDefaults standardUserDefaultsWithStateMachine:[MParticle sharedInstance].stateMachine backendController:[MParticle sharedInstance].backendController identity:[MParticle sharedInstance].identity];
NSData *testDeviceToken = [@"<000000000000000000000000000000>" dataUsingEncoding:NSUTF8StringEncoding];
userDefaults[kMPDeviceTokenKey] = testDeviceToken;

Expand Down
8 changes: 4 additions & 4 deletions UnitTests/MPEventTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ - (void)testInvalidTypes {
}

- (void)testDictionaryRepresentation {
MPSession *session = [[MPSession alloc] initWithStartTime:[[NSDate date] timeIntervalSince1970] userId:[MPPersistenceController mpId]];
MPSession *session = [[MPSession alloc] initWithStartTime:[[NSDate date] timeIntervalSince1970] userId:[MPPersistenceController_PRIVATE mpId]];
MPStateMachine_PRIVATE *stateMachine = [MParticle sharedInstance].stateMachine;
stateMachine.currentSession = session;

Expand Down Expand Up @@ -179,7 +179,7 @@ - (void)testDictionaryRepresentation {
}

- (void)testDictionaryRepresentationWithDictionaryValues {
MPSession *session = [[MPSession alloc] initWithStartTime:[[NSDate date] timeIntervalSince1970] userId:[MPPersistenceController mpId]];
MPSession *session = [[MPSession alloc] initWithStartTime:[[NSDate date] timeIntervalSince1970] userId:[MPPersistenceController_PRIVATE mpId]];
MPStateMachine_PRIVATE *stateMachine = [MParticle sharedInstance].stateMachine;
stateMachine.currentSession = session;

Expand Down Expand Up @@ -214,7 +214,7 @@ - (void)testDictionaryRepresentationWithDictionaryValues {
}

- (void)testDictionaryRepresentationWithDictionaryValuesContainingDictionary {
MPSession *session = [[MPSession alloc] initWithStartTime:[[NSDate date] timeIntervalSince1970] userId:[MPPersistenceController mpId]];
MPSession *session = [[MPSession alloc] initWithStartTime:[[NSDate date] timeIntervalSince1970] userId:[MPPersistenceController_PRIVATE mpId]];
MPStateMachine_PRIVATE *stateMachine = [MParticle sharedInstance].stateMachine;
stateMachine.currentSession = session;

Expand Down Expand Up @@ -249,7 +249,7 @@ - (void)testDictionaryRepresentationWithDictionaryValuesContainingDictionary {
}

- (void)testDictionaryRepresentationWithNullValues {
MPSession *session = [[MPSession alloc] initWithStartTime:[[NSDate date] timeIntervalSince1970] userId:[MPPersistenceController mpId]];
MPSession *session = [[MPSession alloc] initWithStartTime:[[NSDate date] timeIntervalSince1970] userId:[MPPersistenceController_PRIVATE mpId]];
MPStateMachine_PRIVATE *stateMachine = [MParticle sharedInstance].stateMachine;
stateMachine.currentSession = session;

Expand Down
17 changes: 8 additions & 9 deletions UnitTests/MPIdentityTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#import "MPKitContainer.h"
#import "MPPersistenceController.h"
#import "MPStateMachine.h"
#import "MPIUserDefaults.h"

typedef NS_ENUM(NSUInteger, MPIdentityRequestType) {
MPIdentityRequestIdentify = 0,
Expand Down Expand Up @@ -59,7 +58,7 @@ - (instancetype)initWithIdentities:(NSDictionary *)identities;
@interface MParticle ()

@property (nonatomic, strong) MPKitContainer_PRIVATE *kitContainer_PRIVATE;
@property (nonatomic, strong, readonly) MPPersistenceController *persistenceController;
@property (nonatomic, strong, readonly) MPPersistenceController_PRIVATE *persistenceController;

@end

Expand Down Expand Up @@ -610,7 +609,7 @@ - (void)testIdentityRequestComplete {
}

- (void)testIdentifyIdentityRequestCompleteWithKits {
id mockPersistenceController = OCMClassMock([MPPersistenceController class]);
id mockPersistenceController = OCMClassMock([MPPersistenceController_PRIVATE class]);
[[[mockPersistenceController stub] andReturn:@"42"] mpId];

id mockInstance = OCMClassMock([MParticle class]);
Expand Down Expand Up @@ -642,7 +641,7 @@ - (void)testIdentifyIdentityRequestCompleteWithKits {
}

- (void)testLoginIdentityRequestCompleteWithKits {
id mockPersistenceController = OCMClassMock([MPPersistenceController class]);
id mockPersistenceController = OCMClassMock([MPPersistenceController_PRIVATE class]);
[[[mockPersistenceController stub] andReturn:@"42"] mpId];

id mockInstance = OCMClassMock([MParticle class]);
Expand Down Expand Up @@ -674,7 +673,7 @@ - (void)testLoginIdentityRequestCompleteWithKits {
}

- (void)testLogoutIdentityRequestCompleteWithKits {
id mockPersistenceController = OCMClassMock([MPPersistenceController class]);
id mockPersistenceController = OCMClassMock([MPPersistenceController_PRIVATE class]);
[[[mockPersistenceController stub] andReturn:@"42"] mpId];

id mockInstance = OCMClassMock([MParticle class]);
Expand Down Expand Up @@ -702,7 +701,7 @@ - (void)testLogoutIdentityRequestCompleteWithKits {
}

- (void)testIdentifyIdentityRequestCompleteWithKitsAndNoUserChange {
id mockPersistenceController = OCMClassMock([MPPersistenceController class]);
id mockPersistenceController = OCMClassMock([MPPersistenceController_PRIVATE class]);
[[[mockPersistenceController stub] andReturn:@"42"] mpId];

id mockInstance = OCMClassMock([MParticle class]);
Expand Down Expand Up @@ -734,7 +733,7 @@ - (void)testIdentifyIdentityRequestCompleteWithKitsAndNoUserChange {
}

- (void)testLoginIdentityRequestCompleteWithKitsAndNoUserChange {
id mockPersistenceController = OCMClassMock([MPPersistenceController class]);
id mockPersistenceController = OCMClassMock([MPPersistenceController_PRIVATE class]);
[[[mockPersistenceController stub] andReturn:@"42"] mpId];

id mockInstance = OCMClassMock([MParticle class]);
Expand Down Expand Up @@ -766,7 +765,7 @@ - (void)testLoginIdentityRequestCompleteWithKitsAndNoUserChange {
}

- (void)testLogoutIdentityRequestCompleteWithKitsAndNoUserChange {
id mockPersistenceController = OCMClassMock([MPPersistenceController class]);
id mockPersistenceController = OCMClassMock([MPPersistenceController_PRIVATE class]);
[[[mockPersistenceController stub] andReturn:@"42"] mpId];

id mockInstance = OCMClassMock([MParticle class]);
Expand Down Expand Up @@ -794,7 +793,7 @@ - (void)testLogoutIdentityRequestCompleteWithKitsAndNoUserChange {
}

- (void)testMPIdZeroToMPId {
id mockPersistenceController = OCMClassMock([MPPersistenceController class]);
id mockPersistenceController = OCMClassMock([MPPersistenceController_PRIVATE class]);
[[[mockPersistenceController stub] andReturn:@"0"] mpId];

id mockInstance = OCMClassMock([MParticle class]);
Expand Down
10 changes: 5 additions & 5 deletions UnitTests/MPKitAPITests.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#import "MPPersistenceController.h"
#import "MPKitContainer.h"
#import "MPKitConfiguration.h"
#import "MPIUserDefaults.h"
#import "MPIConstants.h"

@interface MPKitContainer_PRIVATE ()
Expand All @@ -22,8 +21,9 @@ @interface MPKitContainer_PRIVATE ()
@interface MParticle ()

+ (dispatch_queue_t)messageQueue;
@property (nonatomic, strong) MPStateMachine_PRIVATE *stateMachine;
@property (nonatomic, strong) MPBackendController_PRIVATE *backendController;
@property (nonatomic, strong) MPPersistenceController *persistenceController;
@property (nonatomic, strong) MPPersistenceController_PRIVATE *persistenceController;
@property (nonatomic, strong) MPKitContainer_PRIVATE *kitContainer_PRIVATE;

@end
Expand Down Expand Up @@ -58,7 +58,7 @@ - (void)setUp {
[MParticle sharedInstance].kitContainer_PRIVATE = [[MPKitContainer_PRIVATE alloc] init];
_kitContainer = [MParticle sharedInstance].kitContainer_PRIVATE;

[MParticle sharedInstance].persistenceController = [[MPPersistenceController alloc] init];
[MParticle sharedInstance].persistenceController = [[MPPersistenceController_PRIVATE alloc] init];

NSSet<id<MPExtensionProtocol>> *registeredKits = [MPKitContainer_PRIVATE registeredKits];
if (!registeredKits) {
Expand Down Expand Up @@ -119,7 +119,7 @@ - (void)testUserIdentities {
@"f":@NO
}
];
MPIUserDefaults *userDefaults = [MPIUserDefaults standardUserDefaults];
MPUserDefaults *userDefaults = [MPUserDefaults standardUserDefaultsWithStateMachine:[MParticle sharedInstance].stateMachine backendController:[MParticle sharedInstance].backendController identity:[MParticle sharedInstance].identity];
[userDefaults setMPObject:userIdentities forKey:kMPUserIdentityArrayKey userId:currentUser.userId];
[userDefaults removeMPObjectForKey:@"ua"];

Expand Down Expand Up @@ -162,7 +162,7 @@ - (void)testUserAttributeFromCache {
@"better data":@"ABC",
@"bad data":@"12345"
};
MPIUserDefaults *userDefaults = [MPIUserDefaults standardUserDefaults];
MPUserDefaults *userDefaults = [MPUserDefaults standardUserDefaultsWithStateMachine:[MParticle sharedInstance].stateMachine backendController:[MParticle sharedInstance].backendController identity:[MParticle sharedInstance].identity];
[userDefaults setMPObject:userAttributes forKey:kMPUserAttributeKey userId:currentUser.userId];

NSString *goodHashedKey = [MPIHasher hashString:@"good data"];
Expand Down
Loading
Loading