<commit_before>//
//  SingleItemConverterTests.swift
//
//  Created by <NAME> on 27/09/2016.
//  Copyright © 2016 <NAME>
//  Released under an MIT license: http://opensource.org/licenses/MIT
//

import XCTest

@testable import LocalizationConverter

class SingleItemConverterTests: XCTestCase {

    func test_execute() throws {
        // GIVEN: some mock provider and store objects
        let provider = LocalizationProviderMock()
        let store = LocalizationStoreMock()
        // GIVEN: a converter using these objects
        let converter = SingleItemConverter(provider: provider, store: store)

        // WHEN: we execute the converter routine
        try converter.execute()

        // THEN: provider and store objects were called
        XCTAssertTrue(provider.wasCalled)
        XCTAssertTrue(store.wasCalled)
        // THEN: the localization is of the expected type
        XCTAssertEqual(LocalizationType.android, store.localization?.type)
        // THEN: the localization has the expected content
        XCTAssertEqual(0, store.localization?.count)
    }

    private class LocalizationProviderMock: LocalizationProvider {
        var wasCalled = false

        func localization() throws -> LocalizationMap {
            wasCalled = true
            return LocalizationMap(type: .android)
        }
    }

    private class LocalizationStoreMock: LocalizationStore {
        var wasCalled = false
        var localization: LocalizationMap?

        func store(localization: LocalizationMap) throws {
            wasCalled = true
            self.localization = localization
        }
    }
}
<commit_msg>Make explicit what is used in LocalizationProviderMock<commit_after>//
//  SingleItemConverterTests.swift
//
//  Created by <NAME> on 27/09/2016.
//  Copyright © 2016 <NAME>
//  Released under an MIT license: http://opensource.org/licenses/MIT
//

import XCTest

@testable import LocalizationConverter

class SingleItemConverterTests: XCTestCase {

    func test_execute() throws {
        // GIVEN: some mock provider and store objects
        let provider = LocalizationProviderMock(type: .android, dictionary: [:])
        let store = LocalizationStoreMock()
        // GIVEN: a converter using these objects
        let converter = SingleItemConverter(provider: provider, store: store)

        // WHEN: we execute the converter routine
        try converter.execute()

        // THEN: provider and store objects were called
        XCTAssertTrue(provider.wasCalled)
        XCTAssertTrue(store.wasCalled)
        // THEN: the localization is of the expected type
        XCTAssertEqual(LocalizationType.android, store.localization?.type)
        // THEN: the localization has the expected content
        XCTAssertEqual(0, store.localization?.count)
    }

    private class LocalizationProviderMock: LocalizationProvider {
        var wasCalled = false
        let type: LocalizationType
        let dictionary: [String:String]

        init(type: LocalizationType, dictionary: [String:String]) {
            self.type = type
            self.dictionary = dictionary
        }

        func localization() throws -> LocalizationMap {
            wasCalled = true
            return LocalizationMap(type: type, dictionary: dictionary)
        }
    }

    private class LocalizationStoreMock: LocalizationStore {
        var wasCalled = false
        var localization: LocalizationMap?

        func store(localization: LocalizationMap) throws {
            wasCalled = true
            self.localization = localization
        }
    }
}

{'fraction_non_alphanumeric': 0.07586786114221725, 'fraction_numerical': 0.007278835386338186, 'mean_word_length': 2.5694305694305695, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '1090920', 'n_tokens_mistral': 940, 'n_tokens_neox': 887, 'n_words': 270}