Skip to content

Commit 619fb3a

Browse files
committed
test manager settings are correctly propogated to client and optimizely core
1 parent 2cdbc60 commit 619fb3a

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

OptimizelySDKCore/OptimizelySDKCore/OptimizelySDKCore.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#import "Optimizely.h"
1818
#import "OPTLYBucketer.h"
1919
#import "OPTLYBuilder.h"
20+
#import "OPTLYDatafileManager.h"
2021
#import "OPTLYErrorHandler.h"
2122
#import "OPTLYErrorHandlerMessages.h"
2223
#import "OPTLYEventBuilder.h"

OptimizelySDKShared/OptimizelySDKSharedTests/OPTLYManagerTest.m

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
#import <XCTest/XCTest.h>
1818
#import <OHHTTPStubs/OHHTTPStubs.h>
19-
#import <OptimizelySDKCore/OPTLYDatafileManager.h>
19+
20+
#import <OptimizelySDKCore/OptimizelySDKCore.h>
2021
#import <OptimizelySDKCore/OPTLYNetworkService.h>
2122
#import <OptimizelySDKCore/OPTLYProjectConfig.h>
2223
#import "OPTLYClient.h"
@@ -49,6 +50,39 @@ - (void)tearDown {
4950
self.alternateDatafile = nil;
5051
}
5152

53+
- (void)testInitializationSettingsGetPropogatedToClientAndCore {
54+
// initialize manager settings
55+
id<OPTLYDatafileManager> datafileManager = [[OPTLYDatafileManagerNoOp alloc] init];
56+
id<OPTLYErrorHandler> errorHandler = [[OPTLYErrorHandlerNoOp alloc] init];
57+
id<OPTLYEventDispatcher> eventDispatcher = [[OPTLYEventDispatcherDefault alloc] init];
58+
id<OPTLYLogger> logger = [[OPTLYLoggerDefault alloc] initWithLogLevel:OptimizelyLogLevelOff];
59+
id<OPTLYUserProfile> userProfile = [[OPTLYUserProfileNoOp alloc] init];
60+
61+
// initialize Manager
62+
OPTLYManager *manager = [OPTLYManager initWithBuilderBlock:^(OPTLYManagerBuilder * _Nullable builder) {
63+
builder.datafile = self.defaultDatafile;
64+
builder.datafileManager = datafileManager;
65+
builder.errorHandler = errorHandler;
66+
builder.eventDispatcher = eventDispatcher;
67+
builder.logger = logger;
68+
builder.projectId = kProjectId;
69+
builder.userProfile = userProfile;
70+
}];
71+
XCTAssertEqual(manager.datafileManager, datafileManager);
72+
73+
// get the client
74+
OPTLYClient *client = [manager initializeClient];
75+
XCTAssertEqual(client.logger, logger);
76+
77+
// check optimizely core has been initialized correclty
78+
Optimizely *optimizely = client.optimizely;
79+
XCTAssertNotNil(optimizely);
80+
XCTAssertEqual(optimizely.errorHandler, errorHandler);
81+
XCTAssertEqual(optimizely.eventDispatcher, eventDispatcher);
82+
XCTAssertEqual(optimizely.logger, logger);
83+
XCTAssertEqual(optimizely.userProfile, userProfile);
84+
}
85+
5286
- (void)testInitializeClientWithoutDatafileReturnsDummy {
5387
// initialize manager without datafile
5488
OPTLYManager *manager = [OPTLYManager initWithBuilderBlock:^(OPTLYManagerBuilder * _Nullable builder) {

0 commit comments

Comments
 (0)