/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2016 ForgeRock AS.
*/
#import <OCMock/OCMock.h>
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "FRAAccountsTableViewController.h"
#import "FRAAccountTableViewCell.h"
#import "FRAApplicationAssembly.h"
#import "FRAHotpOathMechanism.h"
#import "FRAIdentityModel.h"
#import "FRAIdentity.h"
#import "FRAModelsFromDatabase.h"
#import "FRAModelUtils.h"
#import "FRANotification.h"
#import "FRAPushMechanism.h"
#import "FRATotpOathMechanism.h"
@interface FRAAccountsTableViewControllerTests : XCTestCase
@end
}
- (void)setUp {
[super setUp];
OCMStub([mockModelsFromDatabase allIdentitiesWithDatabase:[OCMArg any] identityDatabase:[OCMArg any] identityModel:[OCMArg any] error:[OCMArg anyObjectRef]]).andReturn(@[]);
// create a mock instance of the identity database
// patch Typhoon assembly to mock account controller database dependency
FRAApplicationAssembly *assembly = (FRAApplicationAssembly *) [TyphoonComponentFactory defaultFactory];
return mockIdentityModel;
}];
// load accounts controller from storyboard
accountsController = [storyboard instantiateViewControllerWithIdentifier:@"AccountsTableViewController"];
}
- (void)tearDown {
[super tearDown];
}
- (void)simulateLoadingOfView {
} else {
}
}
- (void)simulateUnloadingOfView {
}
- (void)testHasNoCellsWhenDatabaseIsEmpty {
// Given
// When
NSInteger rows = [accountsController tableView:accountsController.tableView numberOfRowsInSection:0];
// Then
}
// Given
FRAIdentity *firstIdentity = [FRAIdentity identityWithDatabase:nil identityModel:mockIdentityModel accountName:@"Alice" issuer:@"Issuer_1" image:nil backgroundColor:nil];
FRAIdentity *secondIdentity = [FRAIdentity identityWithDatabase:nil identityModel:mockIdentityModel accountName:@"Bob" issuer:@"Issuer_1" image:nil backgroundColor:nil];
FRAIdentity *thirdIdentity = [FRAIdentity identityWithDatabase:nil identityModel:mockIdentityModel accountName:@"Alice" issuer:@"Issuer_2" image:nil backgroundColor:nil];
NSArray *identities = @[secondIdentity, thirdIdentity, firstIdentity]; // NB. Identities aren't sorted
// When
NSInteger rows = [accountsController tableView:accountsController.tableView numberOfRowsInSection:0];
// Then
}
// Given
FRAIdentity *identity = [FRAIdentity identityWithDatabase:nil identityModel:nil accountName:@"Alice" issuer:@"Issuer" image:nil backgroundColor:nil];
FRAPushMechanism *pushMechanism = [[FRAPushMechanism alloc] initWithDatabase:nil identityModel:nil ];
// When
// Then
}
// Given
accountName:@"Alice"
issuer:@"Issuer"
// When
// Then
}
- (void)testCanShowOathMechanismAndPushMechanism {
// Given
accountName:@"Alice"
issuer:@"Issuer"
FRAPushMechanism *pushMechanism = [[FRAPushMechanism alloc] initWithDatabase:nil identityModel:nil ];
// When
// Then
}
- (FRANotification *)dummyNotification {
timeToLive:120.0
}
messageId:@"dummy"
challenge:@"dummy"
timeToLive:120.0
}
return (FRAAccountTableViewCell*) [accountsController tableView:accountsController.tableView cellForRowAtIndexPath:indexPath];
}
}
@end