<commit_before>//
//  EmotionTest.swift
//  ios_swift_practice
//
//  Created by 安田洋介 on 10/14/15.
//  Copyright © 2015 安田洋介. All rights reserved.
//

import XCTest
import CoreData
@testable import ios_swift_practice

class EmotionTest: XCTestCase {
    
    var objectContext: NSManagedObjectContext! = nil
    
    override func setUp() {
        super.setUp()
        // Put setup code here. This method is called before the invocation of each test method in the class.
        //objectContext = setUpInMemoryManagedObjectContext()
        objectContext = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext
    }
    func testAddEmotion(){
        EmotionTest.createEmotion("insert_test", objectContext: objectContext)
    }
    static func createEmotion(nameValue:String, objectContext: NSManagedObjectContext) -> Emotion{
        let emotion = try! Emotion.createData(objectContext, name: nameValue)
        try! objectContext.save()
        return emotion!
    }
}<commit_msg>add fetchTest<commit_after>//
//  EmotionTest.swift
//  ios_swift_practice
//
//  Created by 安田洋介 on 10/14/15.
//  Copyright © 2015 安田洋介. All rights reserved.
//

import XCTest
import CoreData
@testable import ios_swift_practice

class EmotionTest: XCTestCase {
    
    var objectContext: NSManagedObjectContext! = nil
    
    override func setUp() {
        super.setUp()
        // Put setup code here. This method is called before the invocation of each test method in the class.
        //objectContext = setUpInMemoryManagedObjectContext()
        objectContext = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext
    }
    func testCreateEmotion(){
        EmotionTest.createEmotion("insert_test", objectContext: objectContext)
    }
    func testFetchData(){
        let name = "fetchTest"
        EmotionTest.createEmotion(name, objectContext: objectContext)
        let fetchedData = try! Emotion.fetchData(objectContext, name: name)
        XCTAssertEqual(fetchedData!.count, 1)
    }
    static func createEmotion(nameValue:String, objectContext: NSManagedObjectContext) -> Emotion{
        let emotion = try! Emotion.createData(objectContext, name: nameValue)
        try! objectContext.save()
        return emotion!
    }
}
{'fraction_non_alphanumeric': 0.08756567425569177, 'fraction_numerical': 0.009194395796847636, 'mean_word_length': 3.2472118959107807, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5514006', 'n_tokens_mistral': 682, 'n_tokens_neox': 655, 'n_words': 173}