<commit_before>//
//  NetworkManagerTests.swift
//  MasKitTests
//
//  Created by <NAME> on 1/5/19.
//  Copyright © 2019 mas-cli. All rights reserved.
//

@testable import MasKit
import XCTest

class NetworkManagerTests: XCTestCase {
    func testSuccessfulAsyncResponse() {
        // Setup our objects
        let session = NetworkSessionMock()
        let manager = NetworkManager(session: session)

        // Create data and tell the session to always return it
        let data = Data(bytes: [0, 1, 0, 1])
        session.data = data

        // Create a URL (using the file path API to avoid optionals)
        let url = URL(fileURLWithPath: "url")

        // Perform the request and verify the result
        var result: NetworkResult!
        manager.loadData(from: url) { result = $0 }
        XCTAssertEqual(result, NetworkResult.success(data))
    }

    func testSuccessfulSyncResponse() {
        // Setup our objects
        let session = NetworkSessionMock()
        let manager = NetworkManager(session: session)

        // Create data and tell the session to always return it
        let data = Data(bytes: [0, 1, 0, 1])
        session.data = data

        // Create a URL (using the file path API to avoid optionals)
        let url = URL(fileURLWithPath: "url")

        // Perform the request and verify the result
        let result = manager.loadDataSync(from: url)
        XCTAssertEqual(result, NetworkResult.success(data))
    }

    func testFailureAsyncResponse() {
        // Setup our objects
        let session = NetworkSessionMock()
        let manager = NetworkManager(session: session)

        session.error = NetworkManager.NetworkError.timeout

        // Create a URL (using the file path API to avoid optionals)
        let url = URL(fileURLWithPath: "url")<commit_msg>👽 Update Data deprecated init usager<commit_after>//
//  NetworkManagerTests.swift
//  MasKitTests
//
//  Created by <NAME> on 1/5/19.
//  Copyright © 2019 mas-cli. All rights reserved.
//

@testable import MasKit
import XCTest

class NetworkManagerTests: XCTestCase {
    func testSuccessfulAsyncResponse() {
        // Setup our objects
        let session = NetworkSessionMock()
        let manager = NetworkManager(session: session)

        // Create data and tell the session to always return it
        let data = Data([0, 1, 0, 1])
        session.data = data

        // Create a URL (using the file path API to avoid optionals)
        let url = URL(fileURLWithPath: "url")

        // Perform the request and verify the result
        var result: NetworkResult!
        manager.loadData(from: url) { result = $0 }
        XCTAssertEqual(result, NetworkResult.success(data))
    }

    func testSuccessfulSyncResponse() {
        // Setup our objects
        let session = NetworkSessionMock()
        let manager = NetworkManager(session: session)

        // Create data and tell the session to always return it
        let data = Data([0, 1, 0, 1])
        session.data = data

        // Create a URL (using the file path API to avoid optionals)
        let url = URL(fileURLWithPath: "url")

        // Perform the request and verify the result
        let result = manager.loadDataSync(from: url)
        XCTAssertEqual(result, NetworkResult.success(data))
    }

    func testFailureAsyncResponse() {
        // Setup our objects
        let session = NetworkSessionMock()
        let manager = NetworkManager(session: session)

        session.error = NetworkManager.NetworkError.timeout

        // Create a URL (using the file path API to avoid optionals)
        let url = URL(fileURLWithPath: "url")
{'fraction_non_alphanumeric': 0.08725571153316818, 'fraction_numerical': 0.009358656757500689, 'mean_word_length': 2.4154135338345863, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6879030', 'n_tokens_mistral': 1003, 'n_tokens_neox': 954, 'n_words': 348}