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
		
	
	
	
		
			Objective-C
		
	
			
		
		
	
	
			50 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Objective-C
		
	
| //
 | |
| //  Copyright (c) 2017 Open Whisper Systems. All rights reserved.
 | |
| //
 | |
| 
 | |
| #import "SignalRecipient.h"
 | |
| #import "TSStorageManager+keyingMaterial.h"
 | |
| #import "TSStorageManager.h"
 | |
| #import <XCTest/XCTest.h>
 | |
| 
 | |
| @interface SignalRecipientTest : XCTestCase
 | |
| 
 | |
| @property (nonatomic) NSString *localNumber;
 | |
| 
 | |
| @end
 | |
| 
 | |
| @implementation SignalRecipientTest
 | |
| 
 | |
| - (void)setUp
 | |
| {
 | |
|     [super setUp];
 | |
|     self.localNumber = @"+13231231234";
 | |
|     [[TSStorageManager sharedManager] storePhoneNumber: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
 |