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.
50 lines
1.3 KiB
Matlab
50 lines
1.3 KiB
Matlab
8 years ago
|
//
|
||
|
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||
|
//
|
||
9 years ago
|
|
||
|
#import "SignalRecipient.h"
|
||
|
#import "TSStorageManager+keyingMaterial.h"
|
||
|
#import "TSStorageManager.h"
|
||
|
#import <XCTest/XCTest.h>
|
||
|
|
||
|
@interface SignalRecipientTest : XCTestCase
|
||
|
|
||
9 years ago
|
@property (nonatomic) NSString *localNumber;
|
||
|
|
||
9 years ago
|
@end
|
||
|
|
||
|
@implementation SignalRecipientTest
|
||
|
|
||
9 years ago
|
- (void)setUp
|
||
|
{
|
||
9 years ago
|
[super setUp];
|
||
9 years ago
|
self.localNumber = @"+13231231234";
|
||
|
[[TSStorageManager sharedManager] storePhoneNumber:self.localNumber];
|
||
9 years ago
|
}
|
||
|
|
||
|
- (void)testSelfRecipientWithExistingRecord
|
||
|
{
|
||
|
// Sanity Check
|
||
9 years ago
|
XCTAssertNotNil(self.localNumber);
|
||
8 years ago
|
[[[SignalRecipient alloc] initWithTextSecureIdentifier:self.localNumber relay:nil] save];
|
||
9 years ago
|
XCTAssertNotNil([SignalRecipient recipientWithTextSecureIdentifier:self.localNumber]);
|
||
9 years ago
|
|
||
|
SignalRecipient *me = [SignalRecipient selfRecipient];
|
||
|
XCTAssert(me);
|
||
9 years ago
|
XCTAssertEqualObjects(self.localNumber, me.uniqueId);
|
||
9 years ago
|
}
|
||
|
|
||
|
- (void)testSelfRecipientWithoutExistingRecord
|
||
|
{
|
||
9 years ago
|
XCTAssertNotNil(self.localNumber);
|
||
|
[[SignalRecipient fetchObjectWithUniqueID:self.localNumber] remove];
|
||
9 years ago
|
// Sanity Check that there's no existing user.
|
||
9 years ago
|
XCTAssertNil([SignalRecipient recipientWithTextSecureIdentifier:self.localNumber]);
|
||
9 years ago
|
|
||
|
SignalRecipient *me = [SignalRecipient selfRecipient];
|
||
|
XCTAssert(me);
|
||
9 years ago
|
XCTAssertEqualObjects(self.localNumber, me.uniqueId);
|
||
9 years ago
|
}
|
||
|
|
||
|
@end
|