78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni/*
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni * The contents of this file are subject to the terms of the Common Development and
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni * Distribution License (the License). You may not use this file except in compliance with the
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni * License.
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni *
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni * specific language governing permission and limitations under the License.
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni *
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni * When distributing Covered Software, include this CDDL Header Notice in each file and include
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni * Header, with the fields enclosed by brackets [] replaced by your own identifying
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni * information: "Portions copyright [year] [name of copyright owner]".
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni *
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni * Copyright 2016 ForgeRock AS.
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni */
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni#import <OCMock/OCMock.h>
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni#import <UIKit/UIKit.h>
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni#import <XCTest/XCTest.h>
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni#import "FRAAccountsTableViewController.h"
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni#import "FRAAccountTableViewCell.h"
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni#import "FRAApplicationAssembly.h"
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni#import "FRAHotpOathMechanism.h"
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni#import "FRAIdentityModel.h"
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni#import "FRAIdentity.h"
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni#import "FRAModelsFromDatabase.h"
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni#import "FRAModelUtils.h"
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni#import "FRANotification.h"
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni#import "FRAPushMechanism.h"
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni#import "FRATotpOathMechanism.h"
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni@interface FRAAccountsTableViewControllerTests : XCTestCase
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni@end
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni@implementation FRAAccountsTableViewControllerTests {
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni FRAAccountsTableViewController *accountsController;
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni id mockIdentityModel;
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni id mockModelsFromDatabase;
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni FRAModelUtils *modelUtils;
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni}
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni- (void)setUp {
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni [super setUp];
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni mockModelsFromDatabase = OCMClassMock([FRAModelsFromDatabase class]);
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni OCMStub([mockModelsFromDatabase allIdentitiesWithDatabase:[OCMArg any] identityDatabase:[OCMArg any] identityModel:[OCMArg any] error:[OCMArg anyObjectRef]]).andReturn(@[]);
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni // create a mock instance of the identity database
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni mockIdentityModel = OCMClassMock([FRAIdentityModel class]);
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni // patch Typhoon assembly to mock account controller database dependency
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni FRAApplicationAssembly *assembly = (FRAApplicationAssembly *) [TyphoonComponentFactory defaultFactory];
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni TyphoonPatcher *patcher = [[TyphoonPatcher alloc] init];
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni [patcher patchDefinitionWithSelector:@selector(identityModel) withObject:^id{
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni return mockIdentityModel;
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni }];
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni [assembly attachDefinitionPostProcessor:patcher];
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni // load accounts controller from storyboard
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni accountsController = [storyboard instantiateViewControllerWithIdentifier:@"AccountsTableViewController"];
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni [self simulateLoadingOfView];
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni modelUtils = [[FRAModelUtils alloc] init];
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni}
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni- (void)tearDown {
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni [self simulateUnloadingOfView];
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni [mockIdentityModel stopMocking];
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni [mockModelsFromDatabase stopMocking];
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni [super tearDown];
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni}
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni- (void)simulateLoadingOfView {
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_8_4) {
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni [accountsController view]; // force IBOutlets etc to be initialized
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni } else {
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni [accountsController loadViewIfNeeded]; // force IBOutlets etc to be initialized
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni }
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni XCTAssertNotNil(accountsController.view);
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni}
a4c96a094a3d715ef793b60cfabfdb2ee088b319Diego Colantoni
a4c96a094a3d715ef793b60cfabfdb2ee088b319Diego Colantoni- (void)simulateUnloadingOfView {
a4c96a094a3d715ef793b60cfabfdb2ee088b319Diego Colantoni [accountsController viewWillDisappear:YES];
a4c96a094a3d715ef793b60cfabfdb2ee088b319Diego Colantoni}
a4c96a094a3d715ef793b60cfabfdb2ee088b319Diego Colantoni
a4c96a094a3d715ef793b60cfabfdb2ee088b319Diego Colantoni- (void)testHasNoCellsWhenDatabaseIsEmpty {
a4c96a094a3d715ef793b60cfabfdb2ee088b319Diego Colantoni // Given
a4c96a094a3d715ef793b60cfabfdb2ee088b319Diego Colantoni OCMStub([mockIdentityModel identities]).andReturn(@[]);
a4c96a094a3d715ef793b60cfabfdb2ee088b319Diego Colantoni
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni // When
a4c96a094a3d715ef793b60cfabfdb2ee088b319Diego Colantoni NSInteger sections = [accountsController numberOfSectionsInTableView:accountsController.tableView];
a4c96a094a3d715ef793b60cfabfdb2ee088b319Diego Colantoni NSInteger rows = [accountsController tableView:accountsController.tableView numberOfRowsInSection:0];
a4c96a094a3d715ef793b60cfabfdb2ee088b319Diego Colantoni
a4c96a094a3d715ef793b60cfabfdb2ee088b319Diego Colantoni // Then
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni XCTAssertEqual(sections, 1);
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni XCTAssertEqual(rows, 0);
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni}
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni- (void)testHasOneCellPerDatabaseIdentitySortedByIssuerThenAccountName {
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni // Given
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni FRAIdentity *firstIdentity = [FRAIdentity identityWithDatabase:nil identityModel:mockIdentityModel accountName:@"Alice" issuer:@"Issuer_1" image:nil backgroundColor:nil];
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni FRAIdentity *secondIdentity = [FRAIdentity identityWithDatabase:nil identityModel:mockIdentityModel accountName:@"Bob" issuer:@"Issuer_1" image:nil backgroundColor:nil];
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni FRAIdentity *thirdIdentity = [FRAIdentity identityWithDatabase:nil identityModel:mockIdentityModel accountName:@"Alice" issuer:@"Issuer_2" image:nil backgroundColor:nil];
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni NSArray *identities = @[secondIdentity, thirdIdentity, firstIdentity]; // NB. Identities aren't sorted
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni OCMStub([mockIdentityModel identities]).andReturn(identities);
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni // When
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni NSInteger sections = [accountsController numberOfSectionsInTableView:accountsController.tableView];
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni NSInteger rows = [accountsController tableView:accountsController.tableView numberOfRowsInSection:0];
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni // Then
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni XCTAssertEqual(sections, 1);
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni XCTAssertEqual(rows, 3);
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni [self assertCellForRow:0 isShowingIdentity:firstIdentity];
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni [self assertCellForRow:1 isShowingIdentity:secondIdentity];
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni [self assertCellForRow:2 isShowingIdentity:thirdIdentity];
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni}
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni- (void)testShowsNotificationIconWithBadgeForPushMechanism {
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni // Given
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni FRAIdentity *identity = [FRAIdentity identityWithDatabase:nil identityModel:nil accountName:@"Alice" issuer:@"Issuer" image:nil backgroundColor:nil];
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni FRAPushMechanism *pushMechanism = [[FRAPushMechanism alloc] initWithDatabase:nil identityModel:nil ];
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni [pushMechanism addNotification:[self dummyNotification] error:nil];
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni [pushMechanism addNotification:[self dummyNotification] error:nil];
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni [identity addMechanism:pushMechanism error:nil];
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni XCTAssertNotNil([identity mechanismOfClass:[FRAPushMechanism class]]);
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni NSArray* identities = @[identity];
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni OCMStub([mockIdentityModel identities]).andReturn(identities);
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni // When
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni FRAAccountTableViewCell *cell = [self cellForRow:0];
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni // Then
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni XCTAssertFalse(cell.firstMechanismIcon.hidden);
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni XCTAssertTrue(cell.secondMechanismIcon.hidden);
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni XCTAssertEqualObjects(cell.notificationsBadge.text, @"2");
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni}
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni- (void)testShowsTokenIconWithoutBadgeForOathMechanism {
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni // Given
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni FRAIdentity *identity = [FRAIdentity identityWithDatabase:nil
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni identityModel:nil
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni accountName:@"Alice"
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni issuer:@"Issuer"
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni image:nil
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni backgroundColor:nil];
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni FRAHotpOathMechanism *mechanism = [modelUtils demoOathMechanism];
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni [identity addMechanism:mechanism error:nil];
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni XCTAssertNotNil([identity mechanismOfClass:[FRAHotpOathMechanism class]]);
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni NSArray* identities = @[identity];
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni OCMStub([mockIdentityModel identities]).andReturn(identities);
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni // When
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni FRAAccountTableViewCell *cell = [self cellForRow:0];
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni // Then
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni XCTAssertFalse(cell.firstMechanismIcon.hidden);
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni XCTAssertTrue(cell.secondMechanismIcon.hidden);
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni XCTAssertEqualObjects(cell.notificationsBadge.text, @"0");
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni XCTAssertTrue(cell.notificationsBadge.hidesWhenZero);
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni}
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni- (void)testCanShowOathMechanismAndPushMechanism {
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni // Given
5d37db6a3aca50ba14cba8909d3ae44f7d43e407Ken Stubbings FRAIdentity *identity = [FRAIdentity identityWithDatabase:nil
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni identityModel:nil
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni accountName:@"Alice"
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni issuer:@"Issuer"
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni image:nil
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni backgroundColor:nil];
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni FRAHotpOathMechanism *mechanism = [modelUtils demoOathMechanism];
7c51d54f23c5581d2cf894f9eafb9798e3febd22Diego Colantoni [identity addMechanism:mechanism error:nil];
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni FRAPushMechanism *pushMechanism = [[FRAPushMechanism alloc] initWithDatabase:nil identityModel:nil ];
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni [pushMechanism addNotification:[self pendingNotification] error:nil];
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni [identity addMechanism:pushMechanism error:nil];
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni XCTAssertNotNil([identity mechanismOfClass:[FRAHotpOathMechanism class]]);
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni XCTAssertNotNil([identity mechanismOfClass:[FRAPushMechanism class]]);
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni NSArray* identities = @[identity];
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni OCMStub([mockIdentityModel identities]).andReturn(identities);
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni // When
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni FRAAccountTableViewCell *cell = [self cellForRow:0];
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni // Then
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni XCTAssertFalse(cell.firstMechanismIcon.hidden);
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni XCTAssertFalse(cell.secondMechanismIcon.hidden);
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni XCTAssertEqualObjects(cell.notificationsBadge.text, @"1");
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni XCTAssertTrue(cell.notificationsBadge.hidesWhenZero);
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni}
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni- (FRANotification *)dummyNotification {
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni return [FRANotification notificationWithDatabase:nil
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni identityModel:nil
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni messageId:nil
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni challenge:nil
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni timeReceived:nil
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni timeToLive:120.0
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni loadBalancerCookieData:nil];
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni}
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni- (FRANotification *)pendingNotification {
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni return [FRANotification notificationWithDatabase:nil
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni identityModel:nil
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni messageId:@"dummy"
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni challenge:@"dummy"
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni timeReceived:[NSDate date]
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni timeToLive:120.0
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni loadBalancerCookieData:nil];
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni}
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni- (FRAAccountTableViewCell *)cellForRow:(NSInteger)row {
33f578498e5bdaf445a4f509ac419f0a23148f61Diego Colantoni NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:0];
2708b42676edf3d2e8f85b3c22b9e3be3cf43eb8Diego Colantoni return (FRAAccountTableViewCell*) [accountsController tableView:accountsController.tableView cellForRowAtIndexPath:indexPath];
2708b42676edf3d2e8f85b3c22b9e3be3cf43eb8Diego Colantoni}
2708b42676edf3d2e8f85b3c22b9e3be3cf43eb8Diego Colantoni
2708b42676edf3d2e8f85b3c22b9e3be3cf43eb8Diego Colantoni- (void)assertCellForRow:(NSInteger)row isShowingIdentity:(FRAIdentity*)identity {
2708b42676edf3d2e8f85b3c22b9e3be3cf43eb8Diego Colantoni FRAAccountTableViewCell *cell = [self cellForRow:row];
2708b42676edf3d2e8f85b3c22b9e3be3cf43eb8Diego Colantoni XCTAssertEqualObjects(identity.issuer, cell.issuer.text);
2708b42676edf3d2e8f85b3c22b9e3be3cf43eb8Diego Colantoni XCTAssertEqualObjects(identity.accountName, cell.accountName.text);
2708b42676edf3d2e8f85b3c22b9e3be3cf43eb8Diego Colantoni}
2708b42676edf3d2e8f85b3c22b9e3be3cf43eb8Diego Colantoni
2708b42676edf3d2e8f85b3c22b9e3be3cf43eb8Diego Colantoni@end
2708b42676edf3d2e8f85b3c22b9e3be3cf43eb8Diego Colantoni