Skip to content

Commit

Permalink
code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
jayahariv committed Feb 14, 2021
1 parent 107e408 commit 8e0a194
Showing 1 changed file with 28 additions and 32 deletions.
60 changes: 28 additions & 32 deletions Objective-C/Tests/ReplicatorTest+Main.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#import "CBLReplicator+Internal.h"
#import "CBLWebSocket.h"

#define kDummyTarget [[CBLURLEndpoint alloc] initWithURL: [NSURL URLWithString: @"ws://foo.cbl.com/db"]]

@interface ReplicatorTest_Main : ReplicatorTest
@end

Expand Down Expand Up @@ -1829,11 +1831,12 @@ - (void) testReplicationConfigSetterMethods {
AssertEqual(config.heartbeat, 300);
}

#pragma mark - HeartBeat

- (void) testHeartbeatWithInvalidValue {
id target = [[CBLURLEndpoint alloc] initWithURL: [NSURL URLWithString: @"ws://foo.cbl.com/db"]];
CBLReplicatorConfiguration* config = [self configWithTarget: target
type: kCBLReplicatorTypePush
continuous: YES];
CBLReplicatorConfiguration* config = [self configWithTarget: kDummyTarget
type: kCBLReplicatorTypePush
continuous: YES];

[self expectException: @"NSInvalidArgumentException" in:^{
config.heartbeat = 0;
Expand All @@ -1848,10 +1851,9 @@ - (void) testHeartbeatWithInvalidValue {
}

- (void) testCustomHeartbeat {
id target = [[CBLURLEndpoint alloc] initWithURL: [NSURL URLWithString: @"ws://foo.cbl.com/db"]];
CBLReplicatorConfiguration* config = [self configWithTarget: target
type: kCBLReplicatorTypePush
continuous: YES];
CBLReplicatorConfiguration* config = [self configWithTarget: kDummyTarget
type: kCBLReplicatorTypePush
continuous: YES];

config.heartbeat = 60;
repl = [[CBLReplicator alloc] initWithConfig: config];
Expand All @@ -1866,54 +1868,48 @@ - (void) testCustomHeartbeat {
#pragma mark - Max Retry Count

- (void) testMaxRetryCountForContinuous {
id target = [[CBLURLEndpoint alloc] initWithURL: [NSURL URLWithString: @"ws://foo.cbl.com/db"]];
CBLReplicatorConfiguration* config = [self configWithTarget: target
type: kCBLReplicatorTypePush
continuous: YES];
CBLReplicatorConfiguration* config = [self configWithTarget: kDummyTarget
type: kCBLReplicatorTypePush
continuous: YES];
AssertEqual(config.maxRetries, NSIntegerMax);
}

- (void) testCustomMaxRetryCountForContinuous {
id target = [[CBLURLEndpoint alloc] initWithURL: [NSURL URLWithString: @"ws://foo.cbl.com/db"]];
CBLReplicatorConfiguration* config = [self configWithTarget: target
type: kCBLReplicatorTypePush
continuous: YES];
CBLReplicatorConfiguration* config = [self configWithTarget: kDummyTarget
type: kCBLReplicatorTypePush
continuous: YES];
config.maxRetries = 22;
AssertEqual(config.maxRetries, 22);
}

- (void) testMaxRetryCountForSingleShot {
id target = [[CBLURLEndpoint alloc] initWithURL: [NSURL URLWithString: @"ws://foo.cbl.com/db"]];
CBLReplicatorConfiguration* config = [self configWithTarget: target
type: kCBLReplicatorTypePush
continuous: NO];
CBLReplicatorConfiguration* config = [self configWithTarget: kDummyTarget
type: kCBLReplicatorTypePush
continuous: NO];
AssertEqual(config.maxRetries, 9);
}

- (void) testCustomMaxRetryCountForSingleShot {
id target = [[CBLURLEndpoint alloc] initWithURL: [NSURL URLWithString: @"ws://foo.cbl.com/db"]];
CBLReplicatorConfiguration* config = [self configWithTarget: target
type: kCBLReplicatorTypePush
continuous: NO];
CBLReplicatorConfiguration* config = [self configWithTarget: kDummyTarget
type: kCBLReplicatorTypePush
continuous: NO];
config.maxRetries = 22;
AssertEqual(config.maxRetries, 22);
}

#pragma mark - Max Retry Wait Time

- (void) testMaxRetryWaitTime {
id target = [[CBLURLEndpoint alloc] initWithURL: [NSURL URLWithString: @"ws://foo.cbl.com/db"]];
CBLReplicatorConfiguration* config = [self configWithTarget: target
type: kCBLReplicatorTypePush
continuous: NO];
CBLReplicatorConfiguration* config = [self configWithTarget: kDummyTarget
type: kCBLReplicatorTypePush
continuous: NO];
AssertEqual(config.maxRetryWaitTime, 300);
}

- (void) testCustomMaxRetryWaitTime {
id target = [[CBLURLEndpoint alloc] initWithURL: [NSURL URLWithString: @"ws://foo.cbl.com/db"]];
CBLReplicatorConfiguration* config = [self configWithTarget: target
type: kCBLReplicatorTypePush
continuous: NO];
CBLReplicatorConfiguration* config = [self configWithTarget: kDummyTarget
type: kCBLReplicatorTypePush
continuous: NO];
config.maxRetryWaitTime = 444;
AssertEqual(config.maxRetryWaitTime, 444);
}
Expand Down

0 comments on commit 8e0a194

Please sign in to comment.