<commit_before>//
//  UIReactionsTestCase.swift
//  DTModelStorage
//
//  Created by <NAME> on 29.11.15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import UIKit
import XCTest
import DTModelStorage
import Nimble

class UIReactionsTestCase: XCTestCase {
    
    var reactions : [EventReaction]!
    
    override func setUp() {
        super.setUp()
        reactions = []
    }
    
    func testReactionTypeEquatable() {
        expect(EventType.cell) == EventType.cell
    }
    
    func testReactionTypeSupplementaryEquatable() {
        expect(EventType.supplementary(kind: "foo")) == EventType.supplementary(kind: "foo")
        expect(EventType.supplementary(kind: "foo")) != EventType.supplementary(kind: "bar")
    }
    
    func testReactionsAreSearchable() {
        let reaction = EventReaction(signature: "foo")
        reaction.makeCellReaction(block: makeCellBlock(block: {  } , cell: TableCell(), returnValue: 5))
        reactions.append(reaction)
        
        let foundReaction = reactions.reactionOfType(.cell, signature: "foo", forModel: 5)
        expect(foundReaction).toNot(beNil())
    }
    
    func testReactionsForOptionalModelsAreSearchable() {
        let reaction = EventReaction(signature: "foo")
        reaction.makeCellReaction(block: makeCellBlock(block: {  } , cell: TableCell(), returnValue: 5))
        reactions.append(reaction)
        
        let nilModel: Int? = 5
        
        let foundReaction = reactions.reactionOfType(.cell, signature: "foo", forModel: nilModel)
        expect(foundReaction).toNot(beNil())
    }
    
    func makeCellBlock<T,U where T: ModelTransfer>(block: (Void)->Void, cell: T, returnValue: U) -> (T?, T.ModelType, IndexPath) -> U {
        return { one,two,three in
            block()
            return returnValue
        }
    }
    
    func makeSupplementaryBlock<T,U where T: ModelTransfer>(block: (Void)->Void, cell: T, returnValue: U) -> (T?, T.ModelType, Int) -> U {
        return { one,two,three in
            block()
            return returnValue
        }
    }
    
    func testCellReactionIsExecutable() {
        let reaction = EventReaction(signature: "foo")
        let exp = expectation(description: "executeCell")
        reaction.makeCellReaction(block: makeCellBlock(block: {
            exp.fulfill()
            }, cell: TableCell(), returnValue: 3))
        let result = reaction.performWithArguments(arguments: (TableCell(),5,indexPath(0, 0)))
        waitForExpectations(timeout: 1, handler: nil)
        expect(result as? Int) == 3
    }
    
    func testSupplementaryReactionIsExecutable() {
        let reaction = EventReaction(signature: "foo")
        let exp = expectation(description: "executeCell")
        reaction.makeSupplementaryReaction(forKind: "bar", block: makeSupplementaryBlock(block: {
            exp.fulfill()
            }, cell: TableCell(), returnValue: 3))
        let result = reaction.performWithArguments(arguments: (TableCell(),5,6))
        waitForExpectations(timeout: 1, handler: nil)
        expect(result as? Int) == 3
    }
    
    func testReactionOfTypeIsPerformable() {
        let reaction = EventReaction(signature: "foo")
        let exp = expectation(description: "executeCell")
        reaction.makeCellReaction(block: makeCellBlock(block: {
            exp.fulfill()
            }, cell: TableCell(), returnValue: 3))
        reactions.append(reaction)
        let result = reactions.performReaction(ofType: .cell, signature: "foo", view: TableCell(), model: 5, location: indexPath(0,0))
        waitForExpectations(timeout: 1, handler: nil)
        expect(result as? Int) == 3
    }<commit_msg>fix unit tests<commit_after>//
//  UIReactionsTestCase.swift
//  DTModelStorage
//
//  Created by <NAME> on 29.11.15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import UIKit
import XCTest
import DTModelStorage
import Nimble

class UIReactionsTestCase: XCTestCase {
    
    var reactions : [EventReaction]!
    
    override func setUp() {
        super.setUp()
        reactions = []
    }
    
    func testReactionTypeEquatable() {
        expect(EventType.cell) == EventType.cell
    }
    
    func testReactionTypeSupplementaryEquatable() {
        expect(EventType.supplementary(kind: "foo")) == EventType.supplementary(kind: "foo")
        expect(EventType.supplementary(kind: "foo")) != EventType.supplementary(kind: "bar")
    }
    
    func testReactionsAreSearchable() {
        let reaction = EventReaction(signature: "foo")
        reaction.makeCellReaction(block: makeCellBlock(block: {  } , cell: TableCell(), returnValue: 5))
        reactions.append(reaction)
        
        let foundReaction = reactions.reactionOfType(.cell, signature: "foo", forModel: 5)
        expect(foundReaction).toNot(beNil())
    }
    
    func testReactionsForOptionalModelsAreSearchable() {
        let reaction = EventReaction(signature: "foo")
        reaction.makeCellReaction(block: makeCellBlock(block: {  } , cell: TableCell(), returnValue: 5))
        reactions.append(reaction)
        
        let nilModel: Int? = 5
        
        let foundReaction = reactions.reactionOfType(.cell, signature: "foo", forModel: nilModel)
        expect(foundReaction).toNot(beNil())
    }
    
    func makeCellBlock<T,U where T: ModelTransfer>(block: (Void)->Void, cell: T, returnValue: U) -> (T?, T.ModelType, IndexPath) -> U {
        return { one,two,three in
            block()
            return returnValue
        }
    }
    
    func makeSupplementaryBlock<T,U where T: ModelTransfer>(block: (Void)->Void, cell: T, returnValue: U) -> (T?, T.ModelType, IndexPath) -> U {
        return { one,two,three in
            block()
            return returnValue
        }
    }
    
    func testCellReactionIsExecutable() {
        let reaction = EventReaction(signature: "foo")
        let exp = expectation(description: "executeCell")
        reaction.makeCellReaction(block: makeCellBlock(block: {
            exp.fulfill()
            }, cell: TableCell(), returnValue: 3))
        let result = reaction.performWithArguments(arguments: (TableCell(),5,indexPath(0, 0)))
        waitForExpectations(timeout: 1, handler: nil)
        expect(result as? Int) == 3
    }
    
    func testSupplementaryReactionIsExecutable() {
        let reaction = EventReaction(signature: "foo")
        let exp = expectation(description: "executeCell")
        reaction.makeSupplementaryReaction(forKind: "bar", block: makeSupplementaryBlock(block: {
            exp.fulfill()
            }, cell: TableCell(), returnValue: 3))
        let result = reaction.performWithArguments(arguments: (TableCell(),5,indexPath(0, 5)))
        waitForExpectations(timeout: 1, handler: nil)
        expect(result as? Int) == 3
    }
    
    func testReactionOfTypeIsPerformable() {
        let reaction = EventReaction(signature: "foo")
        let exp = expectation(description: "executeCell")
        reaction.makeCellReaction(block: makeCellBlock(block: {
            exp.fulfill()
            }, cell: TableCell(), returnValue: 3))
        reactions.append(reaction)
        let result = reactions.performReaction(ofType: .cell, signature: "foo", view: TableCell(), model: 5, location: indexPath(0,0))
        waitForExpectations(timeout: 1, handler: nil)
        expect(result as? Int) == 3
    }
{'fraction_non_alphanumeric': 0.11906381820655872, 'fraction_numerical': 0.008572594910872228, 'mean_word_length': 2.8043478260869565, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, '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': '7643144', 'n_tokens_mistral': 2176, 'n_tokens_neox': 2089, 'n_words': 469}