FRAIdentityTests.m revision 91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5b
0N/A/*
1472N/A * The contents of this file are subject to the terms of the Common Development and
0N/A * Distribution License (the License). You may not use this file except in compliance with the
0N/A * License.
0N/A *
0N/A * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
0N/A * specific language governing permission and limitations under the License.
0N/A *
0N/A * When distributing Covered Software, include this CDDL Header Notice in each file and include
0N/A * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
0N/A * Header, with the fields enclosed by brackets [] replaced by your own identifying
0N/A * information: "Portions copyright [year] [name of copyright owner]".
0N/A *
0N/A * Copyright 2016 ForgeRock AS.
0N/A */
0N/A
0N/A#import <XCTest/XCTest.h>
0N/A#import "FRAIdentity.h"
1472N/A#import "FRAMechanism.h"
1472N/A
1472N/A@interface FRAIdentityTests : XCTestCase
0N/A
0N/A@end
0N/A
0N/A@implementation FRAIdentityTests {
0N/A FRAIdentity* identity;
0N/A}
0N/A
0N/A- (void)setUp {
0N/A [super setUp];
0N/A identity = [[FRAIdentity alloc] initWithAccountName:@"badger" issuedBy:@"forrest"
0N/A withImage:[[NSURL alloc] initWithString:@"http://animalia-life.com/data_images/badger/badger1.jpg"]];
0N/A}
0N/A
0N/A- (void)tearDown {
0N/A [super tearDown];
0N/A}
0N/A
0N/A- (void)testIdentityWithLabelIssuerImage {
0N/A // Given
0N/A NSString* issuer = @"ForgeRock";
0N/A NSString* accountName = @"joe.bloggs";
0N/A NSURL* image = [NSURL URLWithString:@"https://forgerock.org/ico/favicon-32x32.png"];
0N/A
0N/A // When
0N/A FRAIdentity* test = [FRAIdentity identityWithAccountName:accountName issuedBy:issuer withImage:image];
0N/A
0N/A // Then
0N/A XCTAssertEqualObjects([test issuer], issuer);
0N/A XCTAssertEqualObjects([test accountName], accountName);
0N/A XCTAssertEqualObjects([[test image] absoluteString], [image description]);
0N/A}
0N/A
0N/A- (void) testCanAddMechanism {
0N/A // Given
0N/A FRAMechanism* mechansim = [[FRAMechanism alloc] init];
0N/A
0N/A // When
0N/A [identity addMechanism:mechansim];
0N/A
0N/A // Then
XCTAssertEqual([[identity mechanisms]count], 1);
}
- (void) testCanRemoveMechanism {
// Given
FRAMechanism* mechansim = [[FRAMechanism alloc] init];
[identity addMechanism:mechansim];
// When
[identity removeMechanism:mechansim];
// Then
XCTAssertEqual([[identity mechanisms]count], 0);
}
@end