Skip to content

Commit

Permalink
added a unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-plevako-badoo committed Sep 6, 2020
1 parent 0e108f2 commit 306e5a3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 1 addition & 2 deletions Server/CBXCUITestServer.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ - (instancetype)init_private {

[_server setTXTRecordDictionary:capabilities];
[self registerRoutes];
[self setServerPort];
}
return self;
}
Expand Down Expand Up @@ -93,8 +94,6 @@ - (void)start {
NSError *error;
BOOL serverStarted = NO;

[self setServerPort];

DDLogDebug(@"Attempting to start the DeviceAgent server");
serverStarted = [self attemptToStartWithError:&error];

Expand Down
13 changes: 13 additions & 0 deletions TestApp/DeviceAgentUnitTests/CBXUITestServerTest.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

#import "CBXServerUnitTestUmbrellaHeader.h"
#import "CBXCUITestServer.h"
#import "CBXConstants.h"
#import <OCMock/OCMock.h>
#import "RoutingHTTPServer.h"

@interface CBXCUITestServer (CBXTEST)
Expand Down Expand Up @@ -43,4 +45,15 @@ - (void)testInitPrivateSetsServerAndRegistersRoutes {
expect(self.testServer.isFinishedTesting).to.equal(NO);
}

-(void)testInitSetsDefaultPort {
expect(self.testServer.server.port).equal(CBX_DEFAULT_SERVER_PORT);
}

-(void)testPassingPortFromEnvironment {
id processInfoMock = OCMClassMock([NSProcessInfo class]);
OCMStub([[processInfoMock environment] objectForKey: @"CbxServerPort"]).andReturn("41799");

expect(self.testServer.server.port).equal(41799);
}

@end

0 comments on commit 306e5a3

Please sign in to comment.