<commit_before>//
//  TestManagedObjectContext.swift
//  THCCoreData
//
//  Created by <NAME> on 06.04.15.
//  Copyright (c) 2015 Thinc. All rights reserved.
//

import UIKit
import XCTest
import CoreData
import THCCoreData

class TestManagedObjectContextExtension: CoreDataTestCase {
    
    func testFetchRequest() {
        let context = self.manager.mainContext
        let fetchRequest = context.fetchRequest(Stub)
        XCTAssertEqual(Stub.entityName(), fetchRequest.entityName!)
    }
    
    func testCreateObject() {
        let context = self.manager.mainContext
        let stub: Stub = context.createObject(Stub)
        XCTAssertNotNil(stub)
    }
    
    func testRequestSet() {
        let context = self.manager.mainContext
        let requestSet = context.requestSet(Stub)
        XCTAssertNotNil(requestSet)
    }
    
    func testPersist() {
        let context = self.manager.mainContext
        let obj = context.createObject(Stub)
        obj.name = "test"
        let expectation = self.expectationWithDescription("Called success")
        context.persist({(success:Bool, error:NSError?) -> Void in
            XCTAssertTrue(success)
            expectation.fulfill()
        })
        self.waitForExpectationsWithTimeout(0.1, handler: nil)
        XCTAssertEqual(1, self.manager.mainContext.parentContext!.countForFetchRequest(context.fetchRequest(Stub), error: nil))
    }
}<commit_msg>speed up persist test<commit_after>//
//  TestManagedObjectContext.swift
//  THCCoreData
//
//  Created by <NAME> on 06.04.15.
//  Copyright (c) 2015 Thinc. All rights reserved.
//

import UIKit
import XCTest
import CoreData
import THCCoreData

class TestManagedObjectContextExtension: CoreDataTestCase {
    
    func testFetchRequest() {
        let context = self.manager.mainContext
        let fetchRequest = context.fetchRequest(Stub)
        XCTAssertEqual(Stub.entityName(), fetchRequest.entityName!)
    }
    
    func testCreateObject() {
        let context = self.manager.mainContext
        let stub: Stub = context.createObject(Stub)
        XCTAssertNotNil(stub)
    }
    
    func testRequestSet() {
        let context = self.manager.mainContext
        let requestSet = context.requestSet(Stub)
        XCTAssertNotNil(requestSet)
    }
    
    func testPersist() {
        let context = self.manager.mainContext
        let obj = context.createObject(Stub)
        obj.name = "test"
        let expectation = self.expectationWithDescription("Called success")
        context.persist({(success:Bool, error:NSError?) -> Void in
            XCTAssertTrue(success)
            expectation.fulfill()
        })
        self.waitForExpectationsWithTimeout(0.01, handler: nil)
        XCTAssertEqual(1, self.manager.mainContext.parentContext!.countForFetchRequest(context.fetchRequest(Stub), error: nil))
    }
}
{'fraction_non_alphanumeric': 0.09560632688927943, 'fraction_numerical': 0.009490333919156414, 'mean_word_length': 2.7946666666666666, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6719840', 'n_tokens_mistral': 830, 'n_tokens_neox': 820, 'n_words': 167}