|
16 | 16 |
|
17 | 17 | #import <XCTest/XCTest.h>
|
18 | 18 | #import <OHHTTPStubs/OHHTTPStubs.h>
|
19 |
| -#import <OptimizelySDKCore/OPTLYDatafileManager.h> |
| 19 | + |
| 20 | +#import <OptimizelySDKCore/OptimizelySDKCore.h> |
20 | 21 | #import <OptimizelySDKCore/OPTLYNetworkService.h>
|
21 | 22 | #import <OptimizelySDKCore/OPTLYProjectConfig.h>
|
22 | 23 | #import "OPTLYClient.h"
|
@@ -49,6 +50,39 @@ - (void)tearDown {
|
49 | 50 | self.alternateDatafile = nil;
|
50 | 51 | }
|
51 | 52 |
|
| 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 | + |
52 | 86 | - (void)testInitializeClientWithoutDatafileReturnsDummy {
|
53 | 87 | // initialize manager without datafile
|
54 | 88 | OPTLYManager *manager = [OPTLYManager initWithBuilderBlock:^(OPTLYManagerBuilder * _Nullable builder) {
|
|
0 commit comments