-
Notifications
You must be signed in to change notification settings - Fork 5
/
HPFClientConfigTests.m
62 lines (50 loc) · 2.59 KB
/
HPFClientConfigTests.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// HPFClientConfigTests.m
// HiPayFullservice
//
// Created by HiPay on 01/10/2015.
// Copyright © 2015 HiPay. All rights reserved.
//
#import <XCTest/XCTest.h>
@interface HPFClientConfigTests : XCTestCase
@end
@implementation HPFClientConfigTests
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testClientInit
{
XCTAssertNotNil([HPFClientConfig sharedClientConfig]);
XCTAssertTrue([[HPFClientConfig sharedClientConfig] isKindOfClass:[HPFClientConfig class]]);
XCTAssertEqualObjects([HPFClientConfig sharedClientConfig], [HPFClientConfig sharedClientConfig]);
}
- (void)testSettingValues
{
[[HPFClientConfig sharedClientConfig] setEnvironment:HPFEnvironmentProduction username:@"username" password:@"passwd" appURLscheme:@"hipayexample" paymentCardStorageEnabled:true];
XCTAssertEqualObjects([HPFClientConfig sharedClientConfig].username, @"username");
XCTAssertEqualObjects([HPFClientConfig sharedClientConfig].password, @"passwd");
XCTAssertTrue([HPFClientConfig sharedClientConfig].environment == HPFEnvironmentProduction);
XCTAssertEqualObjects([HPFClientConfig sharedClientConfig].appRedirectionURL, [NSURL URLWithString:@"hipayexample://hipay-fullservice"]);
XCTAssertTrue([HPFClientConfig sharedClientConfig].isPaymentCardStorageEnabled);
XCTAssertFalse([[HPFClientConfig sharedClientConfig] isEqual:@""]);
XCTestExpectation *userAgent = [[XCTestExpectation alloc] initWithDescription:@"User Agent"];
XCTWaiterResult waiter = [XCTWaiter waitForExpectations:@[userAgent] timeout:1.0];
if (waiter == XCTWaiterResultTimedOut) {
XCTAssertNotNil([HPFClientConfig sharedClientConfig].userAgent);
}
else {
XCTFail(@"Expectations error: UserAgent == nil");
}
}
- (void)testInitSchemeError
{
XCTAssertThrows([[HPFClientConfig sharedClientConfig] setEnvironment:HPFEnvironmentProduction username:@"username" password:@"passwd" appURLscheme:@"hello-test" paymentCardStorageEnabled:true] );
XCTAssertThrows([[HPFClientConfig sharedClientConfig] setEnvironment:HPFEnvironmentProduction username:@"username" password:@"passwd" appURLscheme:@"test1" paymentCardStorageEnabled:true]);
XCTAssertThrows([[HPFClientConfig sharedClientConfig] setEnvironment:HPFEnvironmentProduction username:@"username" password:@"passwd" appURLscheme:@"donotexist" paymentCardStorageEnabled:true]);
}
@end