Navigation Menu

Skip to content

Commit

Permalink
Move the test
Browse files Browse the repository at this point in the history
  • Loading branch information
Anna Kocheshkova committed Aug 12, 2020
1 parent b79b27b commit 6e53b5d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 32 deletions.
2 changes: 0 additions & 2 deletions AppCenter/AppCenter/Internals/Channel/MSChannelGroupDefault.m
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#import <libkern/OSAtomic.h>

#import "MSChannelGroupDefault.h"
#import "AppCenter+Internal.h"
#import "MSAppCenterIngestion.h"
Expand Down
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

#import "MSChannelUnitDefault.h"
#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
28 changes: 0 additions & 28 deletions AppCenter/AppCenterTests/MSChannelGroupDefaultTests.m
Expand Up @@ -66,34 +66,6 @@ - (void)tearDown {
[super tearDown];
}

#if !TARGET_OS_OSX
- (void)testAppIsKilled {

// If
[self.sut setEnabled:YES andDeleteDataOnDisabled:YES];
id sut = OCMPartialMock(self.sut);

// When
[[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationWillTerminateNotification object:sut];

// Then
OCMVerify([sut applicationWillTerminate:OCMOCK_ANY]);
XCTAssertNotNil(self.sut.logsDispatchQueue);

// If
[self.sut setEnabled:NO andDeleteDataOnDisabled:YES];
OCMReject([sut applicationWillTerminate:OCMOCK_ANY]);

// When
[[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationWillTerminateNotification object:sut];

// Then
self.sut.logsDispatchQueue = nil;
OCMVerifyAll(sut);
[sut stopMocking];
}
#endif

#pragma mark - Tests

- (void)testNewInstanceWasInitialisedCorrectly {
Expand Down
39 changes: 37 additions & 2 deletions AppCenter/AppCenterTests/MSChannelUnitDefaultTests.m
Expand Up @@ -64,8 +64,6 @@ - (void)setUp {
self.ingestionMock = OCMProtocolMock(@protocol(MSIngestionProtocol));
OCMStub([self.ingestionMock isReadyToSend]).andReturn(YES);
self.settingsMock = [MSMockUserDefaults new];
self.channelGroupMock = OCMClassMock([MSChannelGroupDefault class]);
OCMStub(ClassMethod([self.channelGroupMock hasEnteredApplicationWillTerminate])).andReturn(NO);
}

- (void)tearDown {
Expand All @@ -88,6 +86,43 @@ - (void)tearDown {

#pragma mark - Tests

#if !TARGET_OS_OSX
- (void)testAppIsKilled {

MSChannelUnitDefault *channel = [self createChannelUnitDefault];

// Configure channel with custom interval.
channel.configuration = [[MSChannelUnitConfiguration alloc] initWithGroupId:kMSTestGroupId
priority:MSPriorityDefault
flushInterval:60
batchSizeLimit:50
pendingBatchesLimit:3];

// If
[channel setEnabled:YES andDeleteDataOnDisabled:YES];
id sut = OCMPartialMock(channel);

// When
[[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationWillTerminateNotification object:sut];

// Then
OCMVerify([sut applicationWillTerminate:OCMOCK_ANY]);
XCTAssertNotNil(channel.logsDispatchQueue);

// If
[channel setEnabled:NO andDeleteDataOnDisabled:YES];
OCMReject([sut applicationWillTerminate:OCMOCK_ANY]);

// When
[[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationWillTerminateNotification object:sut];

// Then
channel.logsDispatchQueue = nil;
OCMVerifyAll(sut);
[sut stopMocking];
}
#endif

- (void)testPendingLogsStoresStartTimeWhenPaused {

// If
Expand Down

0 comments on commit 6e53b5d

Please sign in to comment.