IOS-1495 add initial messages to test server IOS-1495
authorXavier Algarra <xavier@pep-project.org>
Fri, 15 Mar 2019 17:47:17 +0100
branchIOS-1495
changeset 80103621302b5624
parent 8009 0f924009779b
child 8011 da69019044e1
IOS-1495 add initial messages to test server
pEpForiOS/UI/EmailDisplayList/EmailListViewModel.swift
pEpForiOSTests/Models/EmailListViewModelTest.swift
     1.1 --- a/pEpForiOS/UI/EmailDisplayList/EmailListViewModel.swift	Fri Mar 15 17:40:43 2019 +0100
     1.2 +++ b/pEpForiOS/UI/EmailDisplayList/EmailListViewModel.swift	Fri Mar 15 17:47:17 2019 +0100
     1.3 @@ -99,6 +99,7 @@
     1.4  
     1.5      func startMonitoring() {
     1.6          do {
     1.7 +            self.messageQueryResults.delegate = self
     1.8              try messageQueryResults.startMonitoring()
     1.9          } catch {
    1.10              Logger.frontendLogger.errorAndCrash("MessageQueryResult crash")
     2.1 --- a/pEpForiOSTests/Models/EmailListViewModelTest.swift	Fri Mar 15 17:40:43 2019 +0100
     2.2 +++ b/pEpForiOSTests/Models/EmailListViewModelTest.swift	Fri Mar 15 17:47:17 2019 +0100
     2.3 @@ -45,7 +45,7 @@
     2.4      }
     2.5  
     2.6      func test10MessagesInInitialSetup() {
     2.7 -        TestUtil.createMessages(number: 10, engineProccesed: true, inFolder: folder, setUids: true)
     2.8 +        let msg = TestUtil.createMessages(number: 10, engineProccesed: true, inFolder: folder, setUids: true)
     2.9          setupViewModel()
    2.10          XCTAssertEqual(emailListVM.rowCount, 10)
    2.11      }
    2.12 @@ -655,27 +655,31 @@
    2.13  }
    2.14  
    2.15  class TestServer {
    2.16 -    var messageFolderDelegate : MessageQueryResults
    2.17 +    var messageQueryResults : MessageQueryResults
    2.18      var results: [Message] = [Message]()
    2.19 -    init(messageFolderDelegate: MessageQueryResults) {
    2.20 -        self.messageFolderDelegate = messageFolderDelegate
    2.21 +    init(messageQueryResults: MessageQueryResults) {
    2.22 +        self.messageQueryResults = messageQueryResults
    2.23      }
    2.24      func insertData(message: Message) {
    2.25          results.append(message)
    2.26          let ip = IndexPath(row: results.firstIndex(of: message)!, section: 0)
    2.27 -        self.messageFolderDelegate.delegate?.didInsert(indexPath: ip)
    2.28 +        self.messageQueryResults.delegate?.didInsert(indexPath: ip)
    2.29      }
    2.30  
    2.31      func updateData(message: Message) {
    2.32          let ip = IndexPath(row: results.firstIndex(of: message)!, section: 0)
    2.33 -        self.messageFolderDelegate.delegate?.didUpdate(indexPath: ip)
    2.34 +        self.messageQueryResults.delegate?.didUpdate(indexPath: ip)
    2.35      }
    2.36  
    2.37      func deleteData(message: Message) {
    2.38          let index = results.firstIndex(of: message)
    2.39          results.remove(at: index!)
    2.40          let ip = IndexPath(row: index!, section: 0)
    2.41 -        self.messageFolderDelegate.delegate?.didDelete(indexPath: ip)
    2.42 +        self.messageQueryResults.delegate?.didDelete(indexPath: ip)
    2.43 +    }
    2.44 +
    2.45 +    func insertMessagesWithoutDelegate(messages: [Message]) {
    2.46 +        results.append(contentsOf: messages)
    2.47      }
    2.48  }
    2.49