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.
		
		
		
		
		
			
		
			
				
	
	
		
			65 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Objective-C
		
	
			
		
		
	
	
			65 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Objective-C
		
	
//
 | 
						|
//  Copyright (c) 2018 Open Whisper Systems. All rights reserved.
 | 
						|
//
 | 
						|
 | 
						|
#import "MockSSKEnvironment.h"
 | 
						|
#import "OWSPrimaryStorage.h"
 | 
						|
#import "SSKBaseTestObjC.h"
 | 
						|
#import "SignalRecipient.h"
 | 
						|
#import "TSAccountManager.h"
 | 
						|
#import "TestAppContext.h"
 | 
						|
#import <SessionServiceKit/SessionServiceKit-Swift.h>
 | 
						|
 | 
						|
@interface TSAccountManager (Testing)
 | 
						|
 | 
						|
- (void)storeLocalNumber:(NSString *)localNumber;
 | 
						|
 | 
						|
@end
 | 
						|
 | 
						|
@interface SignalRecipientTest : SSKBaseTestObjC
 | 
						|
 | 
						|
@property (nonatomic) NSString *localNumber;
 | 
						|
 | 
						|
@end
 | 
						|
 | 
						|
@implementation SignalRecipientTest
 | 
						|
 | 
						|
- (void)setUp
 | 
						|
{
 | 
						|
    [super setUp];
 | 
						|
 | 
						|
    self.localNumber = @"+13231231234";
 | 
						|
    [[TSAccountManager sharedInstance] storeLocalNumber:self.localNumber];
 | 
						|
}
 | 
						|
 | 
						|
- (void)tearDown
 | 
						|
{
 | 
						|
    [super tearDown];
 | 
						|
}
 | 
						|
 | 
						|
- (void)testSelfRecipientWithExistingRecord
 | 
						|
{
 | 
						|
    // Sanity Check
 | 
						|
    XCTAssertNotNil(self.localNumber);
 | 
						|
 | 
						|
    [self readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
 | 
						|
        [SignalRecipient markRecipientAsRegisteredAndGet:self.localNumber transaction:transaction];
 | 
						|
 | 
						|
        XCTAssertTrue([SignalRecipient isRegisteredRecipient:self.localNumber transaction:transaction]);
 | 
						|
    }];
 | 
						|
}
 | 
						|
 | 
						|
- (void)testRecipientWithExistingRecord
 | 
						|
{
 | 
						|
    // Sanity Check
 | 
						|
    XCTAssertNotNil(self.localNumber);
 | 
						|
    NSString *recipientId = @"+15551231234";
 | 
						|
    [self readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
 | 
						|
        [SignalRecipient markRecipientAsRegisteredAndGet:recipientId transaction:transaction];
 | 
						|
        
 | 
						|
        XCTAssertTrue([SignalRecipient isRegisteredRecipient:recipientId transaction:transaction]);
 | 
						|
    }];
 | 
						|
}
 | 
						|
 | 
						|
@end
 |