mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.4 KiB
Objective-C
56 lines
1.4 KiB
Objective-C
//
|
|
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
|
//
|
|
|
|
#import "SignalRecipient.h"
|
|
#import "TSAccountManager.h"
|
|
#import "TSStorageManager+keyingMaterial.h"
|
|
#import <XCTest/XCTest.h>
|
|
|
|
@interface TSAccountManager (Testing)
|
|
|
|
- (void)storeLocalNumber:(NSString *)localNumber;
|
|
|
|
@end
|
|
|
|
@interface SignalRecipientTest : XCTestCase
|
|
|
|
@property (nonatomic) NSString *localNumber;
|
|
|
|
@end
|
|
|
|
@implementation SignalRecipientTest
|
|
|
|
- (void)setUp
|
|
{
|
|
[super setUp];
|
|
self.localNumber = @"+13231231234";
|
|
[[TSAccountManager sharedInstance] storeLocalNumber:self.localNumber];
|
|
}
|
|
|
|
- (void)testSelfRecipientWithExistingRecord
|
|
{
|
|
// Sanity Check
|
|
XCTAssertNotNil(self.localNumber);
|
|
[[[SignalRecipient alloc] initWithTextSecureIdentifier:self.localNumber relay:nil] save];
|
|
XCTAssertNotNil([SignalRecipient recipientWithTextSecureIdentifier:self.localNumber]);
|
|
|
|
SignalRecipient *me = [SignalRecipient selfRecipient];
|
|
XCTAssert(me);
|
|
XCTAssertEqualObjects(self.localNumber, me.uniqueId);
|
|
}
|
|
|
|
- (void)testSelfRecipientWithoutExistingRecord
|
|
{
|
|
XCTAssertNotNil(self.localNumber);
|
|
[[SignalRecipient fetchObjectWithUniqueID:self.localNumber] remove];
|
|
// Sanity Check that there's no existing user.
|
|
XCTAssertNil([SignalRecipient recipientWithTextSecureIdentifier:self.localNumber]);
|
|
|
|
SignalRecipient *me = [SignalRecipient selfRecipient];
|
|
XCTAssert(me);
|
|
XCTAssertEqualObjects(self.localNumber, me.uniqueId);
|
|
}
|
|
|
|
@end
|