IOS-1495 test server now handles message query IOS-1495
authorXavier Algarra <xavier@pep-project.org>
Fri, 15 Mar 2019 17:40:43 +0100
branchIOS-1495
changeset 80090f924009779b
parent 8008 45889d606f5f
child 8010 3621302b5624
IOS-1495 test server now handles message query
pEpForiOSTests/Models/EmailListViewModelTest.swift
     1.1 --- a/pEpForiOSTests/Models/EmailListViewModelTest.swift	Thu Mar 14 16:45:17 2019 +0100
     1.2 +++ b/pEpForiOSTests/Models/EmailListViewModelTest.swift	Fri Mar 15 17:40:43 2019 +0100
     1.3 @@ -564,13 +564,7 @@
     1.4  }
     1.5  
     1.6  class TestMasterViewController: EmailListViewModelDelegate {
     1.7 -    func willReceiveUpdates(viewModel: EmailListViewModel) {
     1.8 -        <#code#>
     1.9 -    }
    1.10  
    1.11 -    func allUpdatesReceived(viewModel: EmailListViewModel) {
    1.12 -        <#code#>
    1.13 -    }
    1.14  
    1.15      var expectationUpdateViewCalled: XCTestExpectation?
    1.16      var excpectationDidInsertDataAtCalled: XCTestExpectation?
    1.17 @@ -588,6 +582,14 @@
    1.18          self.expectationDidRemoveDataAtCalled = expectationDidRemoveDataAt
    1.19      }
    1.20  
    1.21 +    func willReceiveUpdates(viewModel: EmailListViewModel) {
    1.22 +        //not yet defined
    1.23 +    }
    1.24 +
    1.25 +    func allUpdatesReceived(viewModel: EmailListViewModel) {
    1.26 +        //not yet defined
    1.27 +    }
    1.28 +
    1.29      func emailListViewModel(viewModel: EmailListViewModel,
    1.30                              didInsertDataAt indexPaths: [IndexPath]) {
    1.31          if let excpectationDidInsertDataAtCalled = excpectationDidInsertDataAtCalled {
    1.32 @@ -653,20 +655,27 @@
    1.33  }
    1.34  
    1.35  class TestServer {
    1.36 -    var messageFolderDelegate : MessageFolderDelegate
    1.37 -    init(messageFolderDelegate: MessageFolderDelegate) {
    1.38 +    var messageFolderDelegate : MessageQueryResults
    1.39 +    var results: [Message] = [Message]()
    1.40 +    init(messageFolderDelegate: MessageQueryResults) {
    1.41          self.messageFolderDelegate = messageFolderDelegate
    1.42      }
    1.43      func insertData(message: Message) {
    1.44 -        self.messageFolderDelegate.didCreate(messageFolder: message)
    1.45 +        results.append(message)
    1.46 +        let ip = IndexPath(row: results.firstIndex(of: message)!, section: 0)
    1.47 +        self.messageFolderDelegate.delegate?.didInsert(indexPath: ip)
    1.48      }
    1.49  
    1.50      func updateData(message: Message) {
    1.51 -        self.messageFolderDelegate.didUpdate(messageFolder: message)
    1.52 +        let ip = IndexPath(row: results.firstIndex(of: message)!, section: 0)
    1.53 +        self.messageFolderDelegate.delegate?.didUpdate(indexPath: ip)
    1.54      }
    1.55  
    1.56      func deleteData(message: Message) {
    1.57 -        self.messageFolderDelegate.didDelete(messageFolder: message)
    1.58 +        let index = results.firstIndex(of: message)
    1.59 +        results.remove(at: index!)
    1.60 +        let ip = IndexPath(row: index!, section: 0)
    1.61 +        self.messageFolderDelegate.delegate?.didDelete(indexPath: ip)
    1.62      }
    1.63  }
    1.64