title: Inserting items to collection view fail with XCTestCase
body: <h3>TL;DR</h3>
  
  <p>I've made example project to show error. You can clone or download it from:</p>
  
  <p><a href="https://github.com/JakubMazur/SO45820305" rel="nofollow noreferrer">https://github.com/JakubMazur/SO45820305</a></p>
  
  <p>And try to run tests on scheme SO45820305Testing. It will crash</p>
  
  <hr>
  
  <h3>Question:</h3>
  
  <p>I have code that is responsible for paginated list in my app. Whenever new data comes and it's parsed it append data to model in my VC and inserting in into <code>UICollectionView</code>:</p>
  
  <pre><code>func appendNewData(_ dataSet: [ExampleData]) {
      let currentItemsCount = self.collectionViewDataSet.count
      self.collectionViewDataSet.append(contentsOf: dataSet)
      var paths: [IndexPath] = [IndexPath]()
      for i in currentItemsCount...(currentItemsCount+dataSet.count-1) {
          paths.append(IndexPath(row: i, section: 0))
      }
      self.collectionView.performBatchUpdates({
          self.collectionView.insertItems(at: paths) /* crash on this line */
      }) { _ in
          //print("done")
      }
  }
  </code></pre>
  
  <p>And this works great when the app launch normally. So I would like to have this method tested. So I wrote a simple test:</p>
  
  <pre><code>func testAppendNewData() {
      self.viewController.collectionViewDataSet = [ExampleData]()
      self.viewController.collectionView.reloadData()
      let newDataSet = [ExampleData(), ExampleData()]
      self.viewController.appendNewData(newDataSet)
      ...
  }
  </code></pre>
  
  <p>So going step by step by this test is:</p>
  
  <ol>
  <li>I have none data in my <code>collectionViewDataSet</code>. Object is initialized but counter should be 0</li>
  <li>Then I create two example objects and try to append it to my model.</li>
  <li>Then there is some more in this test (assert to check sucessfully added things to model). But it's crashed here with error:</li>
  </ol>
  
  <blockquote>
    <p>error: -[Project.TestClass testAppendNewData]
    : failed: caught "NSInternalInconsistencyException", "Invalid update:
    invalid number of items in section 0.  The number of items contained
    in an existing section after the update (2) must be equal to the
    number of items contained in that section before the update (2), plus
    or minus the number of items inserted or deleted from that section (2
    inserted, 0 deleted) and plus or minus the number of items moved into
    or out of that section (0 moved in, 0 moved out)."</p>
  </blockquote>
  
  <p>So error say that my calculation was wrong for items, but actually <code>must be equal to the number of items contained in that section before the update (2),</code> bother me. How this two items end up BEFORE update? And the funny thing is. How does it work in production app and does not work in test framework?</p>
  
  <p>EDIT:
  @fishinear point out correctly, I should not change a content without reloading data so i update my code. Now it's like above <strong>but still causing the same issue</strong>.</p>