This commit is contained in:
Benjamin Scholtysik (Reimold) 2017-02-09 13:47:25 -08:00
Родитель e67290b039
Коммит 651f669ffa
19 изменённых файлов: 278 добавлений и 278 удалений

Просмотреть файл

@ -55,10 +55,9 @@
- (BOOL)canBeUsed {
BOOL canBeUsed = [MSMobileCenter sharedInstance].sdkConfigured && self.started;
if (!canBeUsed) {
MSLogError([MSMobileCenter logTag],
@"%@ service hasn't been started. You need to call "
@"[MSMobileCenter start:YOUR_APP_SECRET withServices:LIST_OF_SERVICES] first.",
MS_CLASS_NAME_WITHOUT_PREFIX);
MSLogError([MSMobileCenter logTag], @"%@ service hasn't been started. You need to call "
@"[MSMobileCenter start:YOUR_APP_SECRET withServices:LIST_OF_SERVICES] first.",
MS_CLASS_NAME_WITHOUT_PREFIX);
}
return canBeUsed;
}
@ -69,7 +68,7 @@
#pragma mark : - MSService
- (void)startWithLogManager:(id <MSLogManager>)logManager appSecret:(NSString *)appSecret {
- (void)startWithLogManager:(id<MSLogManager>)logManager appSecret:(NSString *)appSecret {
self.started = YES;
self.logManager = logManager;
self.appSecret = appSecret;
@ -81,12 +80,12 @@
}
+ (void)setEnabled:(BOOL)isEnabled {
@synchronized ([self sharedInstance]) {
@synchronized([self sharedInstance]) {
if ([[self sharedInstance] canBeUsed]) {
if (![MSMobileCenter isEnabled] && ![MSMobileCenter sharedInstance].enabledStateUpdating) {
MSLogError([MSMobileCenter logTag], @"The SDK is disabled. Re-enable the whole SDK from MobileCenter "
@"first before enabling %@ service.",
MS_CLASS_NAME_WITHOUT_PREFIX);
@"first before enabling %@ service.",
MS_CLASS_NAME_WITHOUT_PREFIX);
} else {
[[self sharedInstance] setEnabled:isEnabled];
}
@ -95,7 +94,7 @@
}
+ (BOOL)isEnabled {
@synchronized ([self sharedInstance]) {
@synchronized([self sharedInstance]) {
if ([[self sharedInstance] canBeUsed]) {
return [[self sharedInstance] isEnabled];
} else {

Просмотреть файл

@ -13,41 +13,41 @@ typedef NS_ENUM(NSUInteger, MSLogLevel) {
/**
* Logging will be very chatty
*/
MSLogLevelVerbose = 2,
MSLogLevelVerbose = 2,
/**
* Debug information will be logged
*/
MSLogLevelDebug = 3,
MSLogLevelDebug = 3,
/**
* Information will be logged
*/
MSLogLevelInfo = 4,
MSLogLevelInfo = 4,
/**
* Errors and warnings will be logged
*/
MSLogLevelWarning = 5,
MSLogLevelWarning = 5,
/**
* Errors will be logged
*/
MSLogLevelError = 6,
MSLogLevelError = 6,
/**
* Only critical errors will be logged
*/
MSLogLevelAssert = 7,
MSLogLevelAssert = 7,
/**
* Logging is disabled
*/
MSLogLevelNone = 99,
MSLogLevelNone = 99,
};
typedef NSString *(^MSLogMessageProvider)(void);
typedef NSString * (^MSLogMessageProvider)(void);
typedef void (^MSLogHandler)(MSLogMessageProvider messageProvider, MSLogLevel logLevel, NSString *tag, const char *file,
const char *function, uint line);
const char *function, uint line);
#endif

Просмотреть файл

@ -80,9 +80,8 @@ static NSString *const kMSAppNamespace = @"app_namespace";
}
- (BOOL)isValid {
return self.sdkName && self.sdkVersion && self.model && self.oemName &&
self.osName && self.osBuild && self.osVersion && self.locale && self.timeZoneOffset &&
self.screenSize && self.appVersion && self.appBuild;
return self.sdkName && self.sdkVersion && self.model && self.oemName && self.osName && self.osBuild &&
self.osVersion && self.locale && self.timeZoneOffset && self.screenSize && self.appVersion && self.appBuild;
}
- (BOOL)isEqual:(MSDevice *)device {
@ -91,23 +90,23 @@ static NSString *const kMSAppNamespace = @"app_namespace";
return NO;
return ((!self.sdkName && !device.sdkName) || [self.sdkName isEqualToString:device.sdkName]) &&
((!self.sdkVersion && !device.sdkVersion) || [self.sdkVersion isEqualToString:device.sdkVersion]) &&
((!self.model && !device.model) || [self.model isEqualToString:device.model]) &&
((!self.oemName && !device.oemName) || [self.oemName isEqualToString:device.oemName]) &&
((!self.osName && !device.osName) || [self.osName isEqualToString:device.osName]) &&
((!self.osVersion && !device.osVersion) || [self.osVersion isEqualToString:device.osVersion]) &&
((!self.osBuild && !device.osBuild) || [self.osBuild isEqualToString:device.osBuild]) &&
((!self.osApiLevel && !device.osApiLevel) || [self.osApiLevel isEqualToNumber:device.osApiLevel]) &&
((!self.locale && !device.locale) || [self.locale isEqualToString:device.locale]) &&
((!self.timeZoneOffset && !device.timeZoneOffset) ||
((!self.sdkVersion && !device.sdkVersion) || [self.sdkVersion isEqualToString:device.sdkVersion]) &&
((!self.model && !device.model) || [self.model isEqualToString:device.model]) &&
((!self.oemName && !device.oemName) || [self.oemName isEqualToString:device.oemName]) &&
((!self.osName && !device.osName) || [self.osName isEqualToString:device.osName]) &&
((!self.osVersion && !device.osVersion) || [self.osVersion isEqualToString:device.osVersion]) &&
((!self.osBuild && !device.osBuild) || [self.osBuild isEqualToString:device.osBuild]) &&
((!self.osApiLevel && !device.osApiLevel) || [self.osApiLevel isEqualToNumber:device.osApiLevel]) &&
((!self.locale && !device.locale) || [self.locale isEqualToString:device.locale]) &&
((!self.timeZoneOffset && !device.timeZoneOffset) ||
[self.timeZoneOffset isEqualToNumber:device.timeZoneOffset]) &&
((!self.screenSize && !device.screenSize) || [self.screenSize isEqualToString:device.screenSize]) &&
((!self.appVersion && !device.appVersion) || [self.appVersion isEqualToString:device.appVersion]) &&
((!self.carrierName && !device.carrierName) || [self.carrierName isEqualToString:device.carrierName]) &&
((!self.carrierCountry && !device.carrierCountry) ||
((!self.screenSize && !device.screenSize) || [self.screenSize isEqualToString:device.screenSize]) &&
((!self.appVersion && !device.appVersion) || [self.appVersion isEqualToString:device.appVersion]) &&
((!self.carrierName && !device.carrierName) || [self.carrierName isEqualToString:device.carrierName]) &&
((!self.carrierCountry && !device.carrierCountry) ||
[self.carrierCountry isEqualToString:device.carrierCountry]) &&
((!self.appBuild && !device.appBuild) || [self.appBuild isEqualToString:device.appBuild]) &&
((!self.appNamespace && !device.appNamespace) || [self.appNamespace isEqualToString:device.appNamespace]);
((!self.appBuild && !device.appBuild) || [self.appBuild isEqualToString:device.appBuild]) &&
((!self.appNamespace && !device.appNamespace) || [self.appNamespace isEqualToString:device.appNamespace]);
}
#pragma mark - NSCoding

Просмотреть файл

@ -20,9 +20,9 @@ static NSString *const kMSDefaultBaseUrl = @"https://in.mobile.azure.com";
+ (instancetype)sharedInstance {
dispatch_once(&onceToken, ^{
if (sharedInstance == nil) {
sharedInstance = [[self alloc] init];
}
if (sharedInstance == nil) {
sharedInstance = [[self alloc] init];
}
});
return sharedInstance;
}
@ -50,7 +50,7 @@ static NSString *const kMSDefaultBaseUrl = @"https://in.mobile.azure.com";
}
+ (void)setEnabled:(BOOL)isEnabled {
@synchronized ([self sharedInstance]) {
@synchronized([self sharedInstance]) {
if ([[self sharedInstance] canBeUsed]) {
[[self sharedInstance] setEnabled:isEnabled];
}
@ -58,7 +58,7 @@ static NSString *const kMSDefaultBaseUrl = @"https://in.mobile.azure.com";
}
+ (BOOL)isEnabled {
@synchronized ([self sharedInstance]) {
@synchronized([self sharedInstance]) {
if ([[self sharedInstance] canBeUsed]) {
return [[self sharedInstance] isEnabled];
}
@ -100,22 +100,22 @@ static NSString *const kMSDefaultBaseUrl = @"https://in.mobile.azure.com";
static dispatch_once_t debuggerPredicate;
dispatch_once(&debuggerPredicate, ^{
struct kinfo_proc info;
size_t info_size = sizeof(info);
int name[4];
struct kinfo_proc info;
size_t info_size = sizeof(info);
int name[4];
name[0] = CTL_KERN;
name[1] = KERN_PROC;
name[2] = KERN_PROC_PID;
name[3] = getpid();
name[0] = CTL_KERN;
name[1] = KERN_PROC;
name[2] = KERN_PROC_PID;
name[3] = getpid();
if (sysctl(name, 4, &info, &info_size, NULL, 0) == -1) {
NSLog(@"[MSCrashes] ERROR: Checking for a running debugger via sysctl() failed.");
debuggerIsAttached = false;
}
if (sysctl(name, 4, &info, &info_size, NULL, 0) == -1) {
NSLog(@"[MSCrashes] ERROR: Checking for a running debugger via sysctl() failed.");
debuggerIsAttached = false;
}
if (!debuggerIsAttached && (info.kp_proc.p_flag & P_TRACED) != 0)
debuggerIsAttached = true;
if (!debuggerIsAttached && (info.kp_proc.p_flag & P_TRACED) != 0)
debuggerIsAttached = true;
});
return debuggerIsAttached;
@ -142,7 +142,7 @@ static NSString *const kMSDefaultBaseUrl = @"https://in.mobile.azure.com";
MSLogAssert([MSMobileCenter logTag], @"Mobile Center SDK has already been configured.");
}
// Validate and set the app secret.
// Validate and set the app secret.
else if ([appSecret length] == 0) {
MSLogAssert([MSMobileCenter logTag], @"AppSecret is invalid.");
} else {
@ -169,7 +169,7 @@ static NSString *const kMSDefaultBaseUrl = @"https://in.mobile.azure.com";
success = true;
}
MSLogAssert([MSMobileCenter logTag], @"Mobile Center SDK %@",
(success) ? @"configured successfully." : @"configuration failed.");
(success) ? @"configured successfully." : @"configuration failed.");
return success;
}
@ -183,7 +183,7 @@ static NSString *const kMSDefaultBaseUrl = @"https://in.mobile.azure.com";
}
- (void)startService:(Class)clazz {
id <MSServiceInternal> service = [clazz sharedInstance];
id<MSServiceInternal> service = [clazz sharedInstance];
// Set mobileCenterDelegate.
[self.services addObject:service];
@ -193,7 +193,7 @@ static NSString *const kMSDefaultBaseUrl = @"https://in.mobile.azure.com";
}
- (void)setServerUrl:(NSString *)serverUrl {
@synchronized (self) {
@synchronized(self) {
_serverUrl = serverUrl;
}
}
@ -210,7 +210,7 @@ static NSString *const kMSDefaultBaseUrl = @"https://in.mobile.azure.com";
}
// Propagate enable/disable on all services.
for (id <MSServiceInternal> service in self.services) {
for (id<MSServiceInternal> service in self.services) {
[[service class] setEnabled:isEnabled];
}
self.enabledStateUpdating = NO;
@ -253,7 +253,8 @@ static NSString *const kMSDefaultBaseUrl = @"https://in.mobile.azure.com";
- (void)initializeLogManager {
// Construct log manager.
_logManager = [[MSLogManagerDefault alloc] initWithAppSecret:self.appSecret installId:self.installId serverUrl:self.serverUrl];
_logManager =
[[MSLogManagerDefault alloc] initWithAppSecret:self.appSecret installId:self.installId serverUrl:self.serverUrl];
}
- (NSString *)appSecret {
@ -265,7 +266,7 @@ static NSString *const kMSDefaultBaseUrl = @"https://in.mobile.azure.com";
}
- (NSUUID *)installId {
@synchronized (self) {
@synchronized(self) {
if (!_installId) {
// Check if install Id has already been persisted.
@ -289,9 +290,8 @@ static NSString *const kMSDefaultBaseUrl = @"https://in.mobile.azure.com";
- (BOOL)canBeUsed {
BOOL canBeUsed = self.sdkConfigured;
if (!canBeUsed) {
MSLogError([MSMobileCenter logTag],
@"Mobile Center SDK hasn't been configured. You need to call [MSMobileCenter "
@"start:YOUR_APP_SECRET withServices:LIST_OF_SERVICES] first.");
MSLogError([MSMobileCenter logTag], @"Mobile Center SDK hasn't been configured. You need to call [MSMobileCenter "
@"start:YOUR_APP_SECRET withServices:LIST_OF_SERVICES] first.");
}
return canBeUsed;
}

Просмотреть файл

@ -1,6 +1,6 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
*/
* Copyright (c) Microsoft Corporation. All rights reserved.
*/
#import <Foundation/Foundation.h>
@ -16,7 +16,7 @@
/*
* Name of the wrapper SDK (examples: Xamarin, Cordova). [optional]
*/
@property(nonatomic,copy, readonly) NSString *wrapperSdkName;
@property(nonatomic, copy, readonly) NSString *wrapperSdkName;
/*
* Label that is used to identify application code 'version' released via Live Update beacon running on device
@ -24,7 +24,8 @@
@property(nonatomic, copy, readonly) NSString *liveUpdateReleaseLabel;
/*
* Identifier of environment that current application release belongs to, deployment key then maps to environment like Production, Staging.
* Identifier of environment that current application release belongs to, deployment key then maps to environment like
* Production, Staging.
*/
@property(nonatomic, copy, readonly) NSString *liveUpdateDeploymentKey;
@ -43,10 +44,11 @@
*/
- (BOOL)isEqual:(MSWrapperSdk *)wrapperSdk;
- (instancetype) initWithWrapperSdkVersion:(NSString *)wrapperSdkVersion
wrapperSdkName:(NSString *)wrapperSdkName
liveUpdateReleaseLabel:(NSString *)liveUpdateReleaseLabel
liveUpdateDeploymentKey:(NSString *)liveUpdateDeploymentKey
liveUpdatePackageHash:(NSString *)liveUpdatePackageHash;
- (instancetype)initWithWrapperSdkVersion:(NSString *)wrapperSdkVersion
wrapperSdkName:(NSString *)wrapperSdkName
liveUpdateReleaseLabel:(NSString *)liveUpdateReleaseLabel
liveUpdateDeploymentKey:(NSString *)liveUpdateDeploymentKey
liveUpdatePackageHash:(NSString *)liveUpdatePackageHash;
@end

Просмотреть файл

@ -13,13 +13,13 @@ static NSString *const kMSLiveUpdatePackageHash = @"live_update_package_hash";
@implementation MSWrapperSdk
- (instancetype) initWithWrapperSdkVersion:(NSString *)wrapperSdkVersion
wrapperSdkName:(NSString *)wrapperSdkName
liveUpdateReleaseLabel:(NSString *)liveUpdateReleaseLabel
liveUpdateDeploymentKey:(NSString *)liveUpdateDeploymentKey
liveUpdatePackageHash:(NSString *)liveUpdatePackageHash {
- (instancetype)initWithWrapperSdkVersion:(NSString *)wrapperSdkVersion
wrapperSdkName:(NSString *)wrapperSdkName
liveUpdateReleaseLabel:(NSString *)liveUpdateReleaseLabel
liveUpdateDeploymentKey:(NSString *)liveUpdateDeploymentKey
liveUpdatePackageHash:(NSString *)liveUpdatePackageHash {
self = [super init];
if(self) {
if (self) {
_wrapperSdkVersion = wrapperSdkVersion;
_wrapperSdkName = wrapperSdkName;
_liveUpdateReleaseLabel = liveUpdateReleaseLabel;
@ -29,7 +29,6 @@ static NSString *const kMSLiveUpdatePackageHash = @"live_update_package_hash";
return self;
}
- (NSMutableDictionary *)serializeToDictionary {
NSMutableDictionary *dict = [NSMutableDictionary new];
@ -57,15 +56,15 @@ static NSString *const kMSLiveUpdatePackageHash = @"live_update_package_hash";
return NO;
return ((!self.wrapperSdkVersion && !wrapperSdk.wrapperSdkVersion) ||
[self.wrapperSdkVersion isEqualToString:wrapperSdk.wrapperSdkVersion]) &&
((!self.wrapperSdkName && !wrapperSdk.wrapperSdkName) ||
[self.wrapperSdkVersion isEqualToString:wrapperSdk.wrapperSdkVersion]) &&
((!self.wrapperSdkName && !wrapperSdk.wrapperSdkName) ||
[self.wrapperSdkName isEqualToString:wrapperSdk.wrapperSdkName]) &&
((!self.liveUpdateReleaseLabel && !wrapperSdk.liveUpdateReleaseLabel)
|| [self.liveUpdateReleaseLabel isEqualToString:wrapperSdk.liveUpdateReleaseLabel]) &&
((!self.liveUpdateDeploymentKey && !wrapperSdk.liveUpdateDeploymentKey)
|| [self.liveUpdateDeploymentKey isEqualToString:wrapperSdk.liveUpdateDeploymentKey]) &&
((!self.liveUpdatePackageHash && !wrapperSdk.liveUpdatePackageHash)
|| [self.liveUpdatePackageHash isEqualToString:wrapperSdk.liveUpdatePackageHash]);
((!self.liveUpdateReleaseLabel && !wrapperSdk.liveUpdateReleaseLabel) ||
[self.liveUpdateReleaseLabel isEqualToString:wrapperSdk.liveUpdateReleaseLabel]) &&
((!self.liveUpdateDeploymentKey && !wrapperSdk.liveUpdateDeploymentKey) ||
[self.liveUpdateDeploymentKey isEqualToString:wrapperSdk.liveUpdateDeploymentKey]) &&
((!self.liveUpdatePackageHash && !wrapperSdk.liveUpdatePackageHash) ||
[self.liveUpdatePackageHash isEqualToString:wrapperSdk.liveUpdatePackageHash]);
}
#pragma mark - NSCoding

Просмотреть файл

@ -12,4 +12,3 @@
#import "MSWrapperSdk.h"
#import "MSMobileCenterErrors.h"

Просмотреть файл

@ -22,9 +22,9 @@
// When
MSChannelConfiguration *sut = [[MSChannelConfiguration alloc] initWithPriorityName:name
flushInterval:flushInterval
batchSizeLimit:batchSizeLimit
pendingBatchesLimit:pendingBatchesLimit];
flushInterval:flushInterval
batchSizeLimit:batchSizeLimit
pendingBatchesLimit:pendingBatchesLimit];
// Then
assertThat(sut, notNilValue());

Просмотреть файл

@ -206,7 +206,7 @@ static NSString *const kMSDeviceManufacturerTest = @"Apple";
// If
NSString *expected = @"7.8.9";
NSDictionary<NSString *, id> *plist = @{@"CFBundleShortVersionString": expected};
NSDictionary<NSString *, id> *plist = @{ @"CFBundleShortVersionString" : expected };
NSBundle *bundleMock = OCMClassMock([NSBundle class]);
OCMStub([bundleMock infoDictionary]).andReturn(plist);
@ -221,7 +221,7 @@ static NSString *const kMSDeviceManufacturerTest = @"Apple";
// If
NSString *expected = @"42";
NSDictionary<NSString *, id> *plist = @{@"CFBundleVersion": expected};
NSDictionary<NSString *, id> *plist = @{ @"CFBundleVersion" : expected };
NSBundle *bundleMock = OCMClassMock([NSBundle class]);
OCMStub([bundleMock infoDictionary]).andReturn(plist);

Просмотреть файл

@ -79,10 +79,10 @@
NSString *storageKey = @"TestDirectory";
MSAbstractLog *log = [MSAbstractLog new];
MSFile *expected = [MSStorageTestUtil createFileWithId:@"test123"
data:[NSData new]
extension:@"ms"
storageKey:storageKey
creationDate:[NSDate date]];
data:[NSData new]
extension:@"ms"
storageKey:storageKey
creationDate:[NSDate date]];
assertThat(self.sut.buckets[storageKey], nilValue());
// When

Просмотреть файл

@ -92,25 +92,25 @@
NSString *subDirectory = @"testDirectory";
NSString *extension = @"ms";
MSFile *file1 = [MSStorageTestUtil createFileWithId:@"1"
data:[NSData new]
extension:extension
storageKey:subDirectory
creationDate:[NSDate date]];
data:[NSData new]
extension:extension
storageKey:subDirectory
creationDate:[NSDate date]];
MSFile *file2 = [MSStorageTestUtil createFileWithId:@"2"
data:[NSData new]
extension:extension
storageKey:subDirectory
creationDate:[NSDate date]];
data:[NSData new]
extension:extension
storageKey:subDirectory
creationDate:[NSDate date]];
// Create files with searched extension
NSArray<MSFile *> *expected = [NSArray arrayWithObjects:file1, file2, nil];
// Create files with different extension
[MSStorageTestUtil createFileWithId:@"3"
data:[NSData new]
extension:@"foo"
storageKey:subDirectory
creationDate:[NSDate date]];
data:[NSData new]
extension:@"foo"
storageKey:subDirectory
creationDate:[NSDate date]];
// When
NSString *directory = [MSStorageTestUtil storageDirForStorageKey:subDirectory];
@ -143,10 +143,10 @@
// If
MSFile *file = [MSStorageTestUtil createFileWithId:@"0"
data:[NSData new]
extension:@"ms"
storageKey:@"testDirectory"
creationDate:[NSDate date]];
data:[NSData new]
extension:@"ms"
storageKey:@"testDirectory"
creationDate:[NSDate date]];
// When
BOOL success = [MSFileUtil deleteFile:file];
@ -176,14 +176,14 @@
// If
id fileManagerMock = OCMClassMock([NSFileManager class]);
MSFile *file = [MSStorageTestUtil createFileWithId:@"0"
data:[NSData new]
extension:@"ms"
storageKey:@"testDirectory"
creationDate:[NSDate date]];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnonnull"
data:[NSData new]
extension:@"ms"
storageKey:@"testDirectory"
creationDate:[NSDate date]];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnonnull"
file.filePath = nil;
#pragma clang diagnostic pop
#pragma clang diagnostic pop
// When
BOOL success = [MSFileUtil deleteFile:file];
@ -198,10 +198,10 @@
// If
NSData *expected = [@"0" dataUsingEncoding:NSUTF8StringEncoding];
MSFile *file = [MSStorageTestUtil createFileWithId:@"0"
data:expected
extension:@"ms"
storageKey:@"testDirectory"
creationDate:[NSDate date]];
data:expected
extension:@"ms"
storageKey:@"testDirectory"
creationDate:[NSDate date]];
// When
NSData *actual = [MSFileUtil dataForFile:file];
@ -244,8 +244,7 @@
// If
NSString *fileName = @"0";
NSString *filePath =
[MSStorageTestUtil filePathForLogWithId:fileName extension:@"ms" storageKey:@"testDirectory"];
NSString *filePath = [MSStorageTestUtil filePathForLogWithId:fileName extension:@"ms" storageKey:@"testDirectory"];
NSData *expected = [@"123456789" dataUsingEncoding:NSUTF8StringEncoding];
MSFile *file = [[MSFile alloc] initWithPath:filePath fileId:fileName creationDate:[NSDate date]];

Просмотреть файл

@ -35,19 +35,19 @@ static NSString *const kMSAppSecret = @"mockAppSecret";
[super setUp];
NSDictionary *headers = @{
@"Content-Type": @"application/json",
@"App-Secret": @"myUnitTestAppSecret",
@"Install-ID": MS_UUID_STRING
@"Content-Type" : @"application/json",
@"App-Secret" : @"myUnitTestAppSecret",
@"Install-ID" : MS_UUID_STRING
};
NSDictionary *queryStrings = @{@"api_version": @"1.0.0-preview20160914"};
NSDictionary *queryStrings = @{ @"api_version" : @"1.0.0-preview20160914" };
// Mock reachability.
self.reachabilityMock = OCMClassMock([MS_Reachability class]);
self.currentNetworkStatus = ReachableViaWiFi;
OCMStub([self.reachabilityMock currentReachabilityStatus]).andDo(^(NSInvocation *invocation) {
NetworkStatus test = self.currentNetworkStatus;
[invocation setReturnValue:&test];
NetworkStatus test = self.currentNetworkStatus;
[invocation setReturnValue:&test];
});
// sut: System under test
@ -56,7 +56,7 @@ static NSString *const kMSAppSecret = @"mockAppSecret";
headers:headers
queryStrings:queryStrings
reachability:self.reachabilityMock
retryIntervals:@[@(0.5), @(1), @(1.5)]];
retryIntervals:@[ @(0.5), @(1), @(1.5) ]];
}
- (void)tearDown {
@ -74,20 +74,20 @@ static NSString *const kMSAppSecret = @"mockAppSecret";
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"HTTP Response 200"];
[self.sut sendAsync:container
completionHandler:^(NSString *batchId, NSError *error, NSUInteger statusCode) {
completionHandler:^(NSString *batchId, NSError *error, NSUInteger statusCode) {
XCTAssertNil(error);
XCTAssertEqual(containerId, batchId);
XCTAssertEqual(statusCode, MSHTTPCodesNo200OK);
[expectation fulfill];
}];
}];
[self waitForExpectationsWithTimeout:kMSTestTimeout
handler:^(NSError *_Nullable error) {
if (error) {
XCTFail(@"Expectation Failed with error: %@", error);
}
if (error) {
XCTFail(@"Expectation Failed with error: %@", error);
}
}];
}
@ -100,7 +100,7 @@ static NSString *const kMSAppSecret = @"mockAppSecret";
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"HTTP Response 200"];
[self.sut sendAsync:container
completionHandler:^(NSString *batchId, NSError *error, NSUInteger statusCode) {
completionHandler:^(NSString *batchId, NSError *error, NSUInteger statusCode) {
XCTAssertEqual(containerId, batchId);
XCTAssertEqual(statusCode, MSHTTPCodesNo404NotFound);
@ -109,13 +109,13 @@ static NSString *const kMSAppSecret = @"mockAppSecret";
XCTAssertEqual(error.localizedDescription, kMSMCConnectionHttpErrorDesc);
XCTAssertTrue([error.userInfo[kMSMCConnectionHttpCodeErrorKey] isEqual:@(MSHTTPCodesNo404NotFound)]);
[expectation fulfill];
}];
}];
[self waitForExpectationsWithTimeout:kMSTestTimeout
handler:^(NSError *_Nullable error) {
if (error) {
XCTFail(@"Expectation Failed with error: %@", error);
}
if (error) {
XCTFail(@"Expectation Failed with error: %@", error);
}
}];
}
@ -129,30 +129,30 @@ static NSString *const kMSAppSecret = @"mockAppSecret";
// Set a delegate for suspending event.
id delegateMock = OCMProtocolMock(@protocol(MSSenderDelegate));
OCMStub([delegateMock senderDidSuspend:self.sut]).andDo(^(NSInvocation *invocation) {
[requestCompletedExcpectation fulfill];
[requestCompletedExcpectation fulfill];
});
[self.sut addDelegate:delegateMock];
// When
[self.sut sendAsync:container
completionHandler:^(NSString *batchId, NSError *error, NSUInteger statusCode) {
completionHandler:^(NSString *batchId, NSError *error, NSUInteger statusCode) {
// This should not be happening.
XCTFail(@"Completion handler should'nt be called on recoverable errors.");
}];
}];
// Then
[self waitForExpectationsWithTimeout:kMSTestTimeout
handler:^(NSError *error) {
// The call must still be in the pending calls, intended to be retried later.
assertThatUnsignedLong(self.sut.pendingCalls.count, equalToInt(1));
// The call must still be in the pending calls, intended to be retried later.
assertThatUnsignedLong(self.sut.pendingCalls.count, equalToInt(1));
// Sender must be suspended when network is down.
assertThatBool(self.sut.suspended, isTrue());
if (error) {
XCTFail(@"Expectation Failed with error: %@", error);
}
// Sender must be suspended when network is down.
assertThatBool(self.sut.suspended, isTrue());
if (error) {
XCTFail(@"Expectation Failed with error: %@", error);
}
}];
}
@ -170,17 +170,17 @@ static NSString *const kMSAppSecret = @"mockAppSecret";
[self.sut addDelegate:delegateMock];
OCMStub([delegateMock senderDidSuspend:self.sut]).andDo(^(NSInvocation *invocation) {
// Send one batch now that the sender is suspended.
[self.sut sendAsync:container
// Send one batch now that the sender is suspended.
[self.sut sendAsync:container
completionHandler:^(NSString *batchId, NSError *error, NSUInteger statusCode) {
forwardedStatus = statusCode;
forwardedError = error;
[requestCompletedExcpectation fulfill];
forwardedStatus = statusCode;
forwardedError = error;
[requestCompletedExcpectation fulfill];
}];
// When
// Simulate network up again.
[self simulateReachabilityChangedNotification:ReachableViaWiFi];
// When
// Simulate network up again.
[self simulateReachabilityChangedNotification:ReachableViaWiFi];
});
// Simulate network is down.
@ -190,19 +190,19 @@ static NSString *const kMSAppSecret = @"mockAppSecret";
[self waitForExpectationsWithTimeout:kMSTestTimeout
handler:^(NSError *error) {
// The sender got resumed.
OCMVerify([delegateMock senderDidResume:self.sut]);
assertThatBool(self.sut.suspended, isFalse());
// The sender got resumed.
OCMVerify([delegateMock senderDidResume:self.sut]);
assertThatBool(self.sut.suspended, isFalse());
// The call as been removed.
assertThatUnsignedLong(self.sut.pendingCalls.count, equalToInt(0));
// The call as been removed.
assertThatUnsignedLong(self.sut.pendingCalls.count, equalToInt(0));
// Status codes and error must be the same.
assertThatLong(MSHTTPCodesNo200OK, equalToLong(forwardedStatus));
assertThat(forwardedError, nilValue());
if (error) {
XCTFail(@"Expectation Failed with error: %@", error);
}
// Status codes and error must be the same.
assertThatLong(MSHTTPCodesNo200OK, equalToLong(forwardedStatus));
assertThat(forwardedError, nilValue());
if (error) {
XCTFail(@"Expectation Failed with error: %@", error);
}
}];
}
@ -217,45 +217,45 @@ static NSString *const kMSAppSecret = @"mockAppSecret";
// Send logs
[self.sut sendAsync:container1
completionHandler:^(NSString *batchId, NSError *error, NSUInteger statusCode) {
completionHandler:^(NSString *batchId, NSError *error, NSUInteger statusCode) {
XCTFail(@"Completion handler shouldn't be called as test will finish before the response timeout.");
}];
}];
[self.sut sendAsync:container2
completionHandler:^(NSString *batchId, NSError *error, NSUInteger statusCode) {
completionHandler:^(NSString *batchId, NSError *error, NSUInteger statusCode) {
XCTFail(@"Completion handler shouldn't be called as test will finish before the response timeout.");
}];
}];
// When
[self.sut suspend];
[self.sut.session getTasksWithCompletionHandler:^(NSArray<NSURLSessionDataTask *> *_Nonnull dataTasks,
NSArray<NSURLSessionUploadTask *> *_Nonnull uploadTasks,
NSArray<NSURLSessionDownloadTask *> *_Nonnull downloadTasks) {
tasks = dataTasks;
[tasksListedExpectation fulfill];
NSArray<NSURLSessionUploadTask *> *_Nonnull uploadTasks,
NSArray<NSURLSessionDownloadTask *> *_Nonnull downloadTasks) {
tasks = dataTasks;
[tasksListedExpectation fulfill];
}];
// Then
[self waitForExpectationsWithTimeout:kMSTestTimeout
handler:^(NSError *error) {
// Must be only two tasks
assertThatInteger(tasks.count, equalToInteger(2));
// Must be only two tasks
assertThatInteger(tasks.count, equalToInteger(2));
// Tasks must be suspended.
[tasks enumerateObjectsUsingBlock:^(__kindof NSURLSessionTask *_Nonnull task,
NSUInteger idx, BOOL *_Nonnull stop) {
assertThatInteger(task.state, equalToInteger(NSURLSessionTaskStateSuspended));
}];
// Tasks must be suspended.
[tasks enumerateObjectsUsingBlock:^(__kindof NSURLSessionTask *_Nonnull task,
NSUInteger idx, BOOL *_Nonnull stop) {
assertThatInteger(task.state, equalToInteger(NSURLSessionTaskStateSuspended));
}];
// Sender must be suspended.
assertThatBool(self.sut.suspended, isTrue());
// Sender must be suspended.
assertThatBool(self.sut.suspended, isTrue());
// Calls must still be in the pending calls, intended to be resumed later.
assertThatUnsignedLong(self.sut.pendingCalls.count, equalToInt(2));
// Calls must still be in the pending calls, intended to be resumed later.
assertThatUnsignedLong(self.sut.pendingCalls.count, equalToInt(2));
if (error) {
XCTFail(@"Expectation Failed with error: %@", error);
}
if (error) {
XCTFail(@"Expectation Failed with error: %@", error);
}
}];
}
@ -270,47 +270,47 @@ static NSString *const kMSAppSecret = @"mockAppSecret";
// Send logs
[self.sut sendAsync:container1
completionHandler:^(NSString *batchId, NSError *error, NSUInteger statusCode) {
completionHandler:^(NSString *batchId, NSError *error, NSUInteger statusCode) {
XCTFail(@"Completion handler shouldn't be called as test will finish before the response timeout.");
}];
}];
[self.sut sendAsync:container2
completionHandler:^(NSString *batchId, NSError *error, NSUInteger statusCode) {
completionHandler:^(NSString *batchId, NSError *error, NSUInteger statusCode) {
XCTFail(@"Completion handler shouldn't be called as test will finish before the response timeout.");
}];
}];
[self.sut suspend];
// When
[self.sut resume];
[self.sut.session getTasksWithCompletionHandler:^(NSArray<NSURLSessionDataTask *> *_Nonnull dataTasks,
NSArray<NSURLSessionUploadTask *> *_Nonnull uploadTasks,
NSArray<NSURLSessionDownloadTask *> *_Nonnull downloadTasks) {
// Capture tasks state.
tasks = dataTasks;
[tasksListedExpectation fulfill];
NSArray<NSURLSessionUploadTask *> *_Nonnull uploadTasks,
NSArray<NSURLSessionDownloadTask *> *_Nonnull downloadTasks) {
// Capture tasks state.
tasks = dataTasks;
[tasksListedExpectation fulfill];
}];
// Then
[self waitForExpectationsWithTimeout:kMSTestTimeout
handler:^(NSError *error) {
// Must be only two tasks
assertThatInteger(tasks.count, equalToInteger(2));
// Must be only two tasks
assertThatInteger(tasks.count, equalToInteger(2));
// Tasks must have been resumed.
[tasks enumerateObjectsUsingBlock:^(__kindof NSURLSessionDataTask *_Nonnull task,
NSUInteger idx, BOOL *_Nonnull stop) {
assertThatInteger(task.state, equalToInteger(NSURLSessionTaskStateRunning));
}];
// Tasks must have been resumed.
[tasks enumerateObjectsUsingBlock:^(__kindof NSURLSessionDataTask *_Nonnull task,
NSUInteger idx, BOOL *_Nonnull stop) {
assertThatInteger(task.state, equalToInteger(NSURLSessionTaskStateRunning));
}];
// Sender must be suspended.
assertThatBool(self.sut.suspended, isFalse());
// Sender must be suspended.
assertThatBool(self.sut.suspended, isFalse());
// Calls must still be in the pending calls, not yet timed out.
assertThatUnsignedLong(self.sut.pendingCalls.count, equalToInt(2));
// Calls must still be in the pending calls, not yet timed out.
assertThatUnsignedLong(self.sut.pendingCalls.count, equalToInt(2));
if (error) {
XCTFail(@"Expectation Failed with error: %@", error);
}
if (error) {
XCTFail(@"Expectation Failed with error: %@", error);
}
}];
}
@ -322,15 +322,15 @@ static NSString *const kMSAppSecret = @"mockAppSecret";
MSLogContainer *container = [self createLogContainerWithId:containerId];
// Mock the call to intercept the retry.
MSRetriableCall *mockedCall = OCMPartialMock([[MSRetriableCall alloc] initWithRetryIntervals:@[@(UINT_MAX)]]);
MSRetriableCall *mockedCall = OCMPartialMock([[MSRetriableCall alloc] initWithRetryIntervals:@[ @(UINT_MAX) ]]);
mockedCall.delegate = self.sut;
mockedCall.logContainer = container;
mockedCall.completionHandler = nil;
OCMStub([mockedCall sender:self.sut callCompletedWithStatus:MSHTTPCodesNo500InternalServerError error:[OCMArg any]])
.andForwardToRealObject()
.andDo(^(NSInvocation *invocation) {
[responseReceivedExcpectation fulfill];
});
.andForwardToRealObject()
.andDo(^(NSInvocation *invocation) {
[responseReceivedExcpectation fulfill];
});
self.sut.pendingCalls[containerId] = mockedCall;
// Respond with a retryable error.
@ -341,25 +341,25 @@ static NSString *const kMSAppSecret = @"mockAppSecret";
[self waitForExpectationsWithTimeout:kMSTestTimeout
handler:^(NSError *error) {
/**
* When
*/
/**
* When
*/
// Suspend now that the call is retrying.
[self.sut suspend];
// Suspend now that the call is retrying.
[self.sut suspend];
/**
* Then
*/
/**
* Then
*/
// Retry must be stopped.
assertThat(((MSRetriableCall *) self.sut.pendingCalls[@"1"]).timerSource, nilValue());
// Retry must be stopped.
assertThat(((MSRetriableCall *)self.sut.pendingCalls[@"1"]).timerSource, nilValue());
// No call submitted to the session.
assertThatBool(self.sut.pendingCalls[@"1"].submitted, isFalse());
if (error) {
XCTFail(@"Expectation Failed with error: %@", error);
}
// No call submitted to the session.
assertThatBool(self.sut.pendingCalls[@"1"].submitted, isFalse());
if (error) {
XCTFail(@"Expectation Failed with error: %@", error);
}
}];
}
@ -370,14 +370,14 @@ static NSString *const kMSAppSecret = @"mockAppSecret";
log1.toffset = [NSNumber numberWithLongLong:[MSUtil nowInMilliseconds]];
// Log does not have device info, therefore, it's an invalid log
MSLogContainer *container = [[MSLogContainer alloc] initWithBatchId:@"1" andLogs:(NSArray <MSLog> *) @[log1]];
MSLogContainer *container = [[MSLogContainer alloc] initWithBatchId:@"1" andLogs:(NSArray<MSLog> *)@[ log1 ]];
[self.sut sendAsync:container
completionHandler:^(NSString *batchId, NSError *error, NSUInteger statusCode) {
completionHandler:^(NSString *batchId, NSError *error, NSUInteger statusCode) {
XCTAssertEqual(error.domain, kMSMCErrorDomain);
XCTAssertEqual(error.code, kMSMCLogInvalidContainerErrorCode);
}];
}];
XCTAssertEqual([self.sut.pendingCalls count], 0);
}
@ -388,18 +388,18 @@ static NSString *const kMSAppSecret = @"mockAppSecret";
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"HTTP Network Down"];
[self.sut sendAsync:container
completionHandler:^(NSString *batchId, NSError *error, NSUInteger statusCode) {
completionHandler:^(NSString *batchId, NSError *error, NSUInteger statusCode) {
XCTAssertNotNil(error);
[expectation fulfill];
}];
}];
[self waitForExpectationsWithTimeout:kMSTestTimeout
handler:^(NSError *_Nullable error) {
if (error) {
XCTFail(@"Expectation Failed with error: %@", error);
}
if (error) {
XCTFail(@"Expectation Failed with error: %@", error);
}
}];
}
@ -538,7 +538,7 @@ static NSString *const kMSAppSecret = @"mockAppSecret";
// Then.
NSString *fullyHiddenSecret =
[@"" stringByPaddingToLength:hiddenSecret.length withString:kMSHidingStringForAppSecret startingAtIndex:0];
[@"" stringByPaddingToLength:hiddenSecret.length withString:kMSHidingStringForAppSecret startingAtIndex:0];
NSString *appSecretHiddenPart = [hiddenSecret commonPrefixWithString:fullyHiddenSecret options:0];
NSString *appSecretVisiblePart = [hiddenSecret substringFromIndex:appSecretHiddenPart.length];
assertThatInteger(secret.length - appSecretHiddenPart.length, equalToShort(kMSMaxCharactersDisplayedForAppSecret));
@ -558,7 +558,7 @@ static NSString *const kMSAppSecret = @"mockAppSecret";
// Then.
NSString *fullyHiddenSecret =
[@"" stringByPaddingToLength:hiddenSecret.length withString:kMSHidingStringForAppSecret startingAtIndex:0];
[@"" stringByPaddingToLength:hiddenSecret.length withString:kMSHidingStringForAppSecret startingAtIndex:0];
assertThatInteger(hiddenSecret.length, equalToInteger(secret.length));
assertThat(hiddenSecret, is(fullyHiddenSecret));
}
@ -587,7 +587,7 @@ static NSString *const kMSAppSecret = @"mockAppSecret";
log2.device = device;
MSLogContainer *logContainer =
[[MSLogContainer alloc] initWithBatchId:batchId andLogs:(NSArray <MSLog> *) @[log1, log2]];
[[MSLogContainer alloc] initWithBatchId:batchId andLogs:(NSArray<MSLog> *)@[ log1, log2 ]];
return logContainer;
}

Просмотреть файл

@ -60,7 +60,6 @@
id mockDelegate = OCMProtocolMock(@protocol(MSLogManagerDelegate));
[sut addDelegate:mockDelegate];
MSAbstractLog *log = [MSAbstractLog new];
// When

Просмотреть файл

@ -31,7 +31,7 @@
- (void)testSerializingDeviceToDictionaryWorks {
// If
NSDictionary *properties = @{@"key1": @"value1", @"key2": @"value"};
NSDictionary *properties = @{ @"key1" : @"value1", @"key2" : @"value" };
self.sut.properties = properties;
// When
@ -45,7 +45,7 @@
- (void)testNSCodingSerializationAndDeserializationWorks {
// If
NSDictionary *properties = @{@"key1": @"value1", @"key2": @"value"};
NSDictionary *properties = @{ @"key1" : @"value1", @"key2" : @"value" };
self.sut.properties = properties;
// When
@ -62,7 +62,7 @@
- (void)testIsEqual {
// If
NSDictionary *properties = @{@"key1": @"value1", @"key2": @"value"};
NSDictionary *properties = @{ @"key1" : @"value1", @"key2" : @"value" };
self.sut.properties = properties;
// When

Просмотреть файл

@ -1,3 +1,4 @@
#import "MSMobileCenter.h"
#import "MSMobileCenterInternal.h"
#import "MSMobileCenterPrivate.h"
@ -139,3 +140,4 @@ static NSString *const kSMNullifiedInstallIdString = @"00000000-0000-0000-0000-0
XCTAssertTrue([MSMobileCenter isConfigured]);
}
@end
d

Просмотреть файл

@ -20,12 +20,12 @@
static id sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[self alloc] init];
sharedInstance = [[self alloc] init];
});
return sharedInstance;
}
- (void)startWithLogManager:(id <MSLogManager>)logManager appSecret:(NSString *)appSecret {
- (void)startWithLogManager:(id<MSLogManager>)logManager appSecret:(NSString *)appSecret {
[super startWithLogManager:logManager appSecret:appSecret];
}
@ -66,8 +66,8 @@
self.abstractService = [[MSServiceAbstractImplementation alloc] initWithStorage:self.settingsMock];
// Clean storage.
[(MSUserDefaults *) self.settingsMock removeObjectForKey:self.abstractService.isEnabledKey];
[(MSUserDefaults *) self.settingsMock removeObjectForKey:kMSMobileCenterIsEnabledKey];
[(MSUserDefaults *)self.settingsMock removeObjectForKey:self.abstractService.isEnabledKey];
[(MSUserDefaults *)self.settingsMock removeObjectForKey:kMSMobileCenterIsEnabledKey];
}
- (void)tearDown {
@ -144,7 +144,7 @@
// Mock MSSettings and swizzle its setObject:forKey: method to check what's sent by the sut to the persistence.
OCMStub([self.settingsMock objectForKey:[OCMArg any]]).andReturn([NSNumber numberWithBool:YES]);
OCMStub([self.settingsMock setObject:[OCMArg any] forKey:[OCMArg any]]).andDo(^(NSInvocation *invocation) {
[invocation getArgument:&isEnabled atIndex:2];
[invocation getArgument:&isEnabled atIndex:2];
});
/**
@ -188,7 +188,7 @@
assertThatBool([[MSServiceAbstractImplementation sharedInstance] canBeUsed], isFalse());
[MSMobileCenter start:MS_UUID_STRING withServices:@[[MSServiceAbstractImplementation class]]];
[MSMobileCenter start:MS_UUID_STRING withServices:@[ [MSServiceAbstractImplementation class] ]];
assertThatBool([[MSServiceAbstractImplementation sharedInstance] canBeUsed], isTrue());
}
@ -199,7 +199,7 @@
[MSMobileCenter resetSharedInstance];
[self.settingsMock setObject:[NSNumber numberWithBool:NO] forKey:kMSMobileCenterIsEnabledKey];
[self.settingsMock setObject:[NSNumber numberWithBool:NO] forKey:self.abstractService.isEnabledKey];
[MSMobileCenter start:MS_UUID_STRING withServices:@[[MSServiceAbstractImplementation class]]];
[MSMobileCenter start:MS_UUID_STRING withServices:@[ [MSServiceAbstractImplementation class] ]];
// When
[[MSServiceAbstractImplementation class] setEnabled:YES];
@ -214,7 +214,7 @@
[MSMobileCenter resetSharedInstance];
[self.settingsMock setObject:[NSNumber numberWithBool:YES] forKey:kMSMobileCenterIsEnabledKey];
[self.settingsMock setObject:[NSNumber numberWithBool:YES] forKey:self.abstractService.isEnabledKey];
[MSMobileCenter start:MS_UUID_STRING withServices:@[[MSServiceAbstractImplementation class]]];
[MSMobileCenter start:MS_UUID_STRING withServices:@[ [MSServiceAbstractImplementation class] ]];
// When
[[MSServiceAbstractImplementation class] setEnabled:NO];
@ -229,7 +229,7 @@
[MSMobileCenter resetSharedInstance];
[self.settingsMock setObject:[NSNumber numberWithBool:YES] forKey:kMSMobileCenterIsEnabledKey];
[self.settingsMock setObject:[NSNumber numberWithBool:NO] forKey:self.abstractService.isEnabledKey];
[MSMobileCenter start:MS_UUID_STRING withServices:@[[MSServiceAbstractImplementation class]]];
[MSMobileCenter start:MS_UUID_STRING withServices:@[ [MSServiceAbstractImplementation class] ]];
// When
[[MSServiceAbstractImplementation class] setEnabled:YES];
@ -243,7 +243,7 @@
// If
[self.settingsMock setObject:[NSNumber numberWithBool:YES] forKey:kMSMobileCenterIsEnabledKey];
[self.settingsMock setObject:[NSNumber numberWithBool:NO] forKey:self.abstractService.isEnabledKey];
[MSMobileCenter start:MS_UUID_STRING withServices:@[[MSServiceAbstractImplementation class]]];
[MSMobileCenter start:MS_UUID_STRING withServices:@[ [MSServiceAbstractImplementation class] ]];
// When
[MSMobileCenter setEnabled:YES];
@ -257,7 +257,7 @@
// If
[self.settingsMock setObject:[NSNumber numberWithBool:YES] forKey:kMSMobileCenterIsEnabledKey];
[self.settingsMock setObject:[NSNumber numberWithBool:YES] forKey:self.abstractService.isEnabledKey];
[MSMobileCenter start:MS_UUID_STRING withServices:@[[MSServiceAbstractImplementation class]]];
[MSMobileCenter start:MS_UUID_STRING withServices:@[ [MSServiceAbstractImplementation class] ]];
// When
[MSMobileCenter setEnabled:YES];
@ -274,13 +274,13 @@
__block MSPriority priority;
__block BOOL deleteLogs;
__block BOOL forwardedEnabled;
id <MSLogManager> logManagerMock = OCMClassMock([MSLogManagerDefault class]);
id<MSLogManager> logManagerMock = OCMClassMock([MSLogManagerDefault class]);
OCMStub([logManagerMock setEnabled:NO andDeleteDataOnDisabled:YES forPriority:self.abstractService.priority])
.andDo(^(NSInvocation *invocation) {
[invocation getArgument:&priority atIndex:4];
[invocation getArgument:&deleteLogs atIndex:3];
[invocation getArgument:&forwardedEnabled atIndex:2];
});
.andDo(^(NSInvocation *invocation) {
[invocation getArgument:&priority atIndex:4];
[invocation getArgument:&deleteLogs atIndex:3];
[invocation getArgument:&forwardedEnabled atIndex:2];
});
self.abstractService.logManager = logManagerMock;
[self.settingsMock setObject:[NSNumber numberWithBool:YES] forKey:self.abstractService.isEnabledKey];
@ -309,7 +309,7 @@
- (void)testEnableLogManagerOnstartWithLogManager {
// If
id <MSLogManager> logManagerMock = OCMClassMock([MSLogManagerDefault class]);
id<MSLogManager> logManagerMock = OCMClassMock([MSLogManagerDefault class]);
self.abstractService.logManager = logManagerMock;
// When

Просмотреть файл

@ -91,18 +91,18 @@
}
- (void)testNowInMilliseconds {
/**
* When
*/
long long actual = [MSUtil nowInMilliseconds] / 10;
long long expected = [[NSDate date] timeIntervalSince1970] * 100;
/**
* Then
*/
XCTAssertEqual(actual, expected);
// Negative in case of cast issue.
XCTAssertGreaterThan(actual, 0);
}

Просмотреть файл

@ -7,10 +7,10 @@
+ (NSString *)storageDirForStorageKey:(NSString *)storageKey;
+ (NSString *)filePathForLogWithId:(NSString *)logsId extension:(NSString *)extension storageKey:(NSString *)storageKey;
+ (MSFile *)createFileWithId:(NSString *)logsId
data:(NSData *)data
extension:(NSString *)extension
storageKey:(NSString *)storageKey
creationDate:(NSDate *)creationDate;
data:(NSData *)data
extension:(NSString *)extension
storageKey:(NSString *)storageKey
creationDate:(NSDate *)creationDate;
+ (void)createDirectoryAtPath:(NSString *)directoryPath;
+ (void)resetLogsDirectory;

Просмотреть файл

@ -54,3 +54,5 @@
}
@end
d