<commit_before>//
//  CollectionViewDataSourceTests.swift
//  TraktTopTen
//
//  Created by <NAME> on 05/04/2015.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import UIKit
import XCTest

class CollectionViewDataSourceTests: XCTestCase {
    
    var dataSource: CollectionViewDataSource!
    var collectionView: UICollectionView?
    
    override func setUp() {
        super.setUp()
        
        let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
        let size = CGRect(x: 0, y: 0, width: 100, height: 100)
        collectionView = UICollectionView(frame: size, collectionViewLayout: layout)
        
        
        let movieA = Movie(title: "Title", year: 1980, slug: "", banner: "")
        let movieB = Movie(title: "", year: 1980, slug: "", banner: "")
        let items = [movieA, movieB]
        dataSource = CollectionViewDataSource(collectionView: collectionView!)
        dataSource.updateData(items)
    }
    
    func testNumberOfSectionsInCollectionView() {
        let sections = dataSource.numberOfSectionsInCollectionView(collectionView!)
        XCTAssert(sections == 1, "Data source should return 1 section")
    }
    
    func testNumberOfItemsInSection() {
        let items = dataSource.collectionView(collectionView!, numberOfItemsInSection: 0)
        XCTAssert(items == 2, "Data source should return 2 items")
    }
    
    // This crashes when attempting to dequeue a cell. It's as if the collection
    // view never registers the class properly
    func DISABLED_testDataSourceReturnsACell() {
        let indexPath = NSIndexPath(forItem: 0, inSection: 0)
        
        collectionView!.registerClass(MediaItemCell.self, forCellWithReuseIdentifier: "Cell")
        let cell = dataSource.collectionView(collectionView!, cellForItemAtIndexPath: indexPath) as MediaItemCell
        XCTAssert(cell.textLabel.text == "The Shawshank Redemption", "Data source should set cell text")
        
    }

}<commit_msg>Fix broken data source test<commit_after>//
//  CollectionViewDataSourceTests.swift
//  TraktTopTen
//
//  Created by <NAME> on 05/04/2015.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import UIKit
import XCTest

class CollectionViewDataSourceTests: XCTestCase {
    
    var dataSource: CollectionViewDataSource!
    var collectionView: UICollectionView?
    
    override func setUp() {
        super.setUp()
        
        let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
        let size = CGRect(x: 0, y: 0, width: 100, height: 100)
        collectionView = UICollectionView(frame: size, collectionViewLayout: layout)
        
        
        let movieA = Movie(title: "Title", year: 1980, slug: "", banner: "")
        let movieB = Movie(title: "", year: 1980, slug: "", banner: "")
        let items = [movieA, movieB]
        dataSource = CollectionViewDataSource(collectionView: collectionView!)
        dataSource.updateData(items)
    }
    
    func testNumberOfSectionsInCollectionView() {
        let sections = dataSource.numberOfSectionsInCollectionView(collectionView!)
        XCTAssert(sections == 1, "Data source should return 1 section")
    }
    
    func testNumberOfItemsInSection() {
        let items = dataSource.collectionView(collectionView!, numberOfItemsInSection: 0)
        XCTAssert(items == 2, "Data source should return 2 items")
    }
    
    func testDataSourceReturnsACell() {
        let indexPath = NSIndexPath(forItem: 0, inSection: 0)
        collectionView!.dataSource = dataSource
        collectionView!.registerClass(MediaItemCell.self, forCellWithReuseIdentifier: "Cell")
        
        collectionView!.registerClass(MediaItemCell.self, forCellWithReuseIdentifier: "Cell")
        let cell = dataSource.collectionView(collectionView!, cellForItemAtIndexPath: indexPath) as MediaItemCell
        XCTAssert(cell.textLabel.text == "The Shawshank Redemption", "Data source should set cell text")
        
    }

}
{'fraction_non_alphanumeric': 0.09413541404480241, 'fraction_numerical': 0.017618927762396173, 'mean_word_length': 3.1569037656903767, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '135237', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1093, 'n_words': 288}