Skip to content

Commit

Permalink
Move over MPApplication and KitContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonStalnaker committed Dec 6, 2024
1 parent e2e4662 commit b337ea9
Show file tree
Hide file tree
Showing 33 changed files with 150 additions and 158 deletions.
12 changes: 6 additions & 6 deletions UnitTests/MPBackendControllerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ + (dispatch_queue_t)messageQueue;
@property (nonatomic, strong, nonnull) MPBackendController_PRIVATE *backendController;
@property (nonatomic, strong) MPPersistenceController *persistenceController;
@property (nonatomic, strong) MPStateMachine_PRIVATE *stateMachine;
@property (nonatomic, strong) MPKitContainer *kitContainer;
@property (nonatomic, strong) MPKitContainer_PRIVATE *kitContainer;
@property (nonatomic, strong, nullable) NSString *dataPlanId;
@property (nonatomic, strong, nullable) NSNumber *dataPlanVersion;
@property (nonatomic, strong, nonnull) MParticleOptions *options;

@end

#pragma mark - MPKitContainer category for unit tests
@interface MPKitContainer(Tests)
@interface MPKitContainer_PRIVATE(Tests)

- (id<MPKitProtocol>)startKit:(NSNumber *)integrationId configuration:(MPKitConfiguration *)kitConfiguration;

Expand Down Expand Up @@ -121,7 +121,7 @@ - (void)setUp {
[MParticle sharedInstance].stateMachine.apiKey = @"unit_test_app_key";
[MParticle sharedInstance].stateMachine.secret = @"unit_test_secret";

[MParticle sharedInstance].kitContainer = [[MPKitContainer alloc] init];
[MParticle sharedInstance].kitContainer = [[MPKitContainer_PRIVATE alloc] init];

[MParticle sharedInstance].backendController = [[MPBackendController_PRIVATE alloc] initWithDelegate:(id<MPBackendControllerDelegate>)[MParticle sharedInstance]];
self.backendController = [MParticle sharedInstance].backendController;
Expand Down Expand Up @@ -1058,12 +1058,12 @@ - (void)testSetUserTagFromUser {
}

- (void)testSetUserAttributeKits {
if (![MPKitContainer registeredKits]) {
if (![MPKitContainer_PRIVATE registeredKits]) {
MPKitRegister *kitRegister = [[MPKitRegister alloc] initWithName:@"KitTest" className:@"MPKitTestClassNoStartImmediately"];
[MPKitContainer registerKit:kitRegister];
[MPKitContainer_PRIVATE registerKit:kitRegister];

kitRegister = [[MPKitRegister alloc] initWithName:@"KitSecondTest" className:@"MPKitSecondTestClass"];
[MPKitContainer registerKit:kitRegister];
[MPKitContainer_PRIVATE registerKit:kitRegister];

NSDictionary *configuration1 = @{
@"id":@42,
Expand Down
10 changes: 5 additions & 5 deletions UnitTests/MPIUserDefaultsTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ @interface MParticle ()

@property (nonatomic, strong, readonly) MPPersistenceController *persistenceController;
@property (nonatomic, strong) MPStateMachine_PRIVATE *stateMachine;
@property (nonatomic, strong) MPKitContainer *kitContainer;
@property (nonatomic, strong) MPKitContainer_PRIVATE *kitContainer;

@end

@interface MPIUserDefaultsTests : MPBaseTestCase {
MPKitContainer *kitContainer;
MPKitContainer_PRIVATE *kitContainer;
}

@end
Expand All @@ -29,12 +29,12 @@ - (void)setUp {
[MParticle sharedInstance].stateMachine.apiKey = @"unit_test_app_key";
[MParticle sharedInstance].stateMachine.secret = @"unit_test_secret";

[MParticle sharedInstance].kitContainer = [[MPKitContainer alloc] init];
[MParticle sharedInstance].kitContainer = [[MPKitContainer_PRIVATE alloc] init];
kitContainer = [MParticle sharedInstance].kitContainer;
}

- (void)tearDown {
for (MPKitRegister *kitRegister in [MPKitContainer registeredKits]) {
for (MPKitRegister *kitRegister in [MPKitContainer_PRIVATE registeredKits]) {
kitRegister.wrapperInstance = nil;
}
kitContainer = nil;
Expand Down Expand Up @@ -471,7 +471,7 @@ - (void)testConfigParameters {
XCTAssertNotNil(firstParameters);

MPKitRegister *kitRegister = [[MPKitRegister alloc] initWithName:@"KitTest" className:@"MPKitTestClassNoStartImmediately"];
[MPKitContainer registerKit:kitRegister];
[MPKitContainer_PRIVATE registerKit:kitRegister];

XCTAssertEqualObjects(responseConfiguration, [[MPIUserDefaults standardUserDefaults] getConfiguration]);
XCTAssertTrue([[MPIUserDefaults standardUserDefaults] isConfigurationParametersOutdated]);
Expand Down
20 changes: 10 additions & 10 deletions UnitTests/MPIdentityTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ typedef NS_ENUM(NSUInteger, MPIdentityRequestType) {
};

@interface MPIdentityTests : MPBaseTestCase {
MPKitContainer *kitContainer;
MPKitContainer_PRIVATE *kitContainer;
}

@end
Expand Down Expand Up @@ -58,7 +58,7 @@ - (instancetype)initWithIdentities:(NSDictionary *)identities;

@interface MParticle ()

@property (nonatomic, strong) MPKitContainer *kitContainer;
@property (nonatomic, strong) MPKitContainer_PRIVATE *kitContainer;
@property (nonatomic, strong, readonly) MPPersistenceController *persistenceController;

@end
Expand Down Expand Up @@ -614,7 +614,7 @@ - (void)testIdentifyIdentityRequestCompleteWithKits {
[[[mockPersistenceController stub] andReturn:@"42"] mpId];

id mockInstance = OCMClassMock([MParticle class]);
id mockContainer = OCMClassMock([MPKitContainer class]);
id mockContainer = OCMClassMock([MPKitContainer_PRIVATE class]);
[[[mockInstance stub] andReturn:mockContainer] kitContainer];
[[[mockInstance stub] andReturn:mockInstance] sharedInstance];

Expand Down Expand Up @@ -646,7 +646,7 @@ - (void)testLoginIdentityRequestCompleteWithKits {
[[[mockPersistenceController stub] andReturn:@"42"] mpId];

id mockInstance = OCMClassMock([MParticle class]);
id mockContainer = OCMClassMock([MPKitContainer class]);
id mockContainer = OCMClassMock([MPKitContainer_PRIVATE class]);
[[[mockInstance stub] andReturn:mockContainer] kitContainer];
[[[mockInstance stub] andReturn:mockInstance] sharedInstance];

Expand Down Expand Up @@ -678,7 +678,7 @@ - (void)testLogoutIdentityRequestCompleteWithKits {
[[[mockPersistenceController stub] andReturn:@"42"] mpId];

id mockInstance = OCMClassMock([MParticle class]);
id mockContainer = OCMClassMock([MPKitContainer class]);
id mockContainer = OCMClassMock([MPKitContainer_PRIVATE class]);
[[[mockInstance stub] andReturn:mockContainer] kitContainer];
[[[mockInstance stub] andReturn:mockInstance] sharedInstance];

Expand Down Expand Up @@ -706,7 +706,7 @@ - (void)testIdentifyIdentityRequestCompleteWithKitsAndNoUserChange {
[[[mockPersistenceController stub] andReturn:@"42"] mpId];

id mockInstance = OCMClassMock([MParticle class]);
id mockContainer = OCMClassMock([MPKitContainer class]);
id mockContainer = OCMClassMock([MPKitContainer_PRIVATE class]);
[[[mockInstance stub] andReturn:mockContainer] kitContainer];
[[[mockInstance stub] andReturn:mockInstance] sharedInstance];

Expand Down Expand Up @@ -738,7 +738,7 @@ - (void)testLoginIdentityRequestCompleteWithKitsAndNoUserChange {
[[[mockPersistenceController stub] andReturn:@"42"] mpId];

id mockInstance = OCMClassMock([MParticle class]);
id mockContainer = OCMClassMock([MPKitContainer class]);
id mockContainer = OCMClassMock([MPKitContainer_PRIVATE class]);
[[[mockInstance stub] andReturn:mockContainer] kitContainer];
[[[mockInstance stub] andReturn:mockInstance] sharedInstance];

Expand Down Expand Up @@ -770,7 +770,7 @@ - (void)testLogoutIdentityRequestCompleteWithKitsAndNoUserChange {
[[[mockPersistenceController stub] andReturn:@"42"] mpId];

id mockInstance = OCMClassMock([MParticle class]);
id mockContainer = OCMClassMock([MPKitContainer class]);
id mockContainer = OCMClassMock([MPKitContainer_PRIVATE class]);
[[[mockInstance stub] andReturn:mockContainer] kitContainer];
[[[mockInstance stub] andReturn:mockInstance] sharedInstance];

Expand Down Expand Up @@ -798,7 +798,7 @@ - (void)testMPIdZeroToMPId {
[[[mockPersistenceController stub] andReturn:@"0"] mpId];

id mockInstance = OCMClassMock([MParticle class]);
id mockContainer = OCMClassMock([MPKitContainer class]);
id mockContainer = OCMClassMock([MPKitContainer_PRIVATE class]);
[[[mockInstance stub] andReturn:mockContainer] kitContainer];
[[[mockInstance stub] andReturn:mockPersistenceController] persistenceController];
[[[mockInstance stub] andReturn:mockInstance] sharedInstance];
Expand Down Expand Up @@ -855,7 +855,7 @@ - (void)testModifyRequestComplete {

- (void)testModifyRequestCompleteWithKits {
id mockInstance = OCMClassMock([MParticle class]);
id mockContainer = OCMClassMock([MPKitContainer class]);
id mockContainer = OCMClassMock([MPKitContainer_PRIVATE class]);
[[[mockInstance stub] andReturn:mockContainer] kitContainer];
[[[mockInstance stub] andReturn:mockInstance] sharedInstance];

Expand Down
12 changes: 6 additions & 6 deletions UnitTests/MPKitAPITests.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#import "MPIUserDefaults.h"
#import "MPIConstants.h"

@interface MPKitContainer ()
@interface MPKitContainer_PRIVATE ()

- (id<MPKitProtocol>)startKit:(NSNumber *)integrationId configuration:(MPKitConfiguration *)kitConfiguration;

Expand All @@ -24,7 +24,7 @@ @interface MParticle ()
+ (dispatch_queue_t)messageQueue;
@property (nonatomic, strong) MPBackendController_PRIVATE *backendController;
@property (nonatomic, strong) MPPersistenceController *persistenceController;
@property (nonatomic, strong) MPKitContainer *kitContainer;
@property (nonatomic, strong) MPKitContainer_PRIVATE *kitContainer;

@end

Expand All @@ -46,7 +46,7 @@ - (id)initWithKitCode:(NSNumber *)integrationId;
@interface MPKitAPITests : MPBaseTestCase <MPKitProtocol>

@property (nonatomic) MPKitAPI *kitApi;
@property (nonatomic) MPKitContainer *kitContainer;
@property (nonatomic) MPKitContainer_PRIVATE *kitContainer;

@end

Expand All @@ -55,15 +55,15 @@ @implementation MPKitAPITests
- (void)setUp {
[super setUp];

[MParticle sharedInstance].kitContainer = [[MPKitContainer alloc] init];
[MParticle sharedInstance].kitContainer = [[MPKitContainer_PRIVATE alloc] init];
_kitContainer = [MParticle sharedInstance].kitContainer;

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

NSSet<id<MPExtensionProtocol>> *registeredKits = [MPKitContainer registeredKits];
NSSet<id<MPExtensionProtocol>> *registeredKits = [MPKitContainer_PRIVATE registeredKits];
if (!registeredKits) {
MPKitRegister *kitRegister = [[MPKitRegister alloc] initWithName:@"KitTest" className:@"MPKitTestClassNoStartImmediately"];
[MPKitContainer registerKit:kitRegister];
[MPKitContainer_PRIVATE registerKit:kitRegister];

NSDictionary *configuration = @{
@"id":@42,
Expand Down
12 changes: 6 additions & 6 deletions UnitTests/MPKitActivityTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
#import "MPStateMachine.h"
#import <XCTest/XCTest.h>
#import "MPBaseTestCase.h"
#import "mParticle.h"
#import "MParticle.h"

@interface MParticle ()

@property (nonatomic, strong) MPStateMachine_PRIVATE *stateMachine;
@property (nonatomic, strong) MPKitContainer *kitContainer;
@property (nonatomic, strong) MPKitContainer_PRIVATE *kitContainer;

@end

#pragma mark - MPKitContainer category for unit tests
@interface MPKitContainer(Tests)
@interface MPKitContainer_PRIVATE(Tests)

- (id<MPKitProtocol>)startKit:(NSNumber *)integrationId configuration:(MPKitConfiguration *)kitConfiguration;
+ (NSMutableSet <id<MPExtensionKitProtocol>> *)kitsRegistry;
Expand All @@ -44,10 +44,10 @@ - (void)setUp {
[MParticle sharedInstance].stateMachine.apiKey = @"unit_test_app_key";
[MParticle sharedInstance].stateMachine.secret = @"unit_test_secret";

[MParticle sharedInstance].kitContainer = [[MPKitContainer alloc] init];
[MParticle sharedInstance].kitContainer = [[MPKitContainer_PRIVATE alloc] init];

MPKitRegister *kitRegister = [[MPKitRegister alloc] initWithName:@"KitTest" className:@"MPKitTestClassNoStartImmediately"];
[MPKitContainer registerKit:kitRegister];
[MPKitContainer_PRIVATE registerKit:kitRegister];
NSDictionary *configuration = @{@"id": @42, @"as": @{@"appId":@"MyAppId"}};
MPKitConfiguration *kitConfiguration = [[MPKitConfiguration alloc] initWithDictionary:configuration];
[[[MParticle sharedInstance].kitContainer startKit:@42 configuration:kitConfiguration] start];
Expand All @@ -57,7 +57,7 @@ - (void)tearDown {
_kitActivity = nil;

// Ensure registeredKits is empty
[MPKitContainer.kitsRegistry removeAllObjects];
[MPKitContainer_PRIVATE.kitsRegistry removeAllObjects];

[super tearDown];
}
Expand Down
Loading

0 comments on commit b337ea9

Please sign in to comment.