pEpForiOSTests/MessageModelTests.swift
author Xavier Algarra <xavier@pep-project.org>
Tue, 06 Jun 2017 07:49:23 +0200
changeset 2248 75013a586bfd
parent 2238 7cf70731b53f
child 2382 98acb95752c1
permissions -rw-r--r--
IOS-137 add multiple accounts option with the new login
     1 //
     2 //  MessageModelTests.swift
     3 //  pEpForiOS
     4 //
     5 //  Created by Dirk Zimmermann on 31/10/16.
     6 //  Copyright © 2016 p≡p Security S.A. All rights reserved.
     7 //
     8 
     9 import pEpForiOS
    10 import MessageModel
    11 
    12 import XCTest
    13 
    14 class MessageModelTests: XCTestCase {
    15     let waitTime = TestUtil.modelSaveWaitTime
    16     var persistentSetup: PersistentSetup!
    17 
    18     override func setUp() {
    19         super.setUp()
    20         persistentSetup = PersistentSetup()
    21     }
    22 
    23     override func tearDown() {
    24         persistentSetup = nil
    25         super.tearDown()
    26     }
    27 
    28     func testSaveMessageForSending() {
    29         let testData = TestData()
    30         let account = testData.createWorkingAccount()
    31         account.save()
    32         let sentFolder = Folder.create(name: "Sent", account: account, folderType: .sent)
    33         sentFolder.save()
    34         let msg = sentFolder.createMessage()
    35         msg.shortMessage = "Some subject"
    36         msg.from = account.user
    37         msg.to.append(account.user)
    38         msg.save()
    39 
    40         guard let cdMsg = CdMessage.first() else {
    41             XCTFail()
    42             return
    43         }
    44         XCTAssertEqual(msg.uuid, cdMsg.uuid)
    45 
    46         if let (_, _, _) = EncryptAndSendOperation.retrieveNextMessage(
    47             context: Record.Context.default) {
    48         } else {
    49             XCTFail()
    50         }
    51     }
    52 }