<commit_before>////////////////////////////////////////////////////////////////////////////////
//
//  APPSQUICKLY
//  Copyright 2015 AppsQuickly Pty Ltd
//  All Rights Reserved.
//
//  NOTICE: Prepared by AppsQuick.ly on behalf of AppsQuickly. This software
//  is proprietary information. Unauthorized use is prohibited.
//
////////////////////////////////////////////////////////////////////////////////


import Foundation
import XCTest

class EnvFileTests: XCTestCase {

    func test_throws_exception_instantiated_with_new_envFilePath_and_empty_plistFilePath() {
        _ = EnvFile(envFilePath: "EnvFile.plist", infoPlistPath: nil, projectName: nil)
    }

    func test_loads_env_from_disk() {
        let currentPath = NSFileManager.defaultManager().currentDirectoryPath;
        let envFilePath = currentPath + "/tests.xctest/Contents/Resources/EnvFile.plist"

        _ = EnvFile(envFilePath: envFilePath)
    }

    func test_allows_adding_an_env() {
        let currentPath = NSFileManager.defaultManager().currentDirectoryPath;
        let envFilePath = currentPath + "/tests.xctest/Contents/Resources/EnvFile.plist"

        let envFile = EnvFile(envFilePath: envFilePath)

        let newEnvironment = Environment(name: "Hacking")
        newEnvironment.setConfig("Foo", forKey: "Bar")

        envFile.add(newEnvironment)

        XCTAssertEqual(envFile.environments().count, 4)
    }

    func test_lists_environments() {
        let currentPath = NSFileManager.defaultManager().currentDirectoryPath;
        let envFilePath = currentPath + "/tests.xctest/Contents/Resources/EnvFile.plist"

        let envFile = EnvFile(envFilePath: envFilePath)
        _ = envFile.environments()
<commit_msg>Add error for invalid env file.<commit_after>////////////////////////////////////////////////////////////////////////////////
//
//  APPSQUICKLY
//  Copyright 2015 AppsQuickly Pty Ltd
//  All Rights Reserved.
//
//  NOTICE: Prepared by AppsQuick.ly on behalf of AppsQuickly. This software
//  is proprietary information. Unauthorized use is prohibited.
//
////////////////////////////////////////////////////////////////////////////////


import Foundation
import XCTest

class EnvFileTests: XCTestCase {


    func test_loads_env_from_disk() {
        let currentPath = NSFileManager.defaultManager().currentDirectoryPath;
        let envFilePath = currentPath + "/tests.xctest/Contents/Resources/EnvFile.plist"

        _ = EnvFile(envFilePath: envFilePath)
    }

    func test_allows_adding_an_env() {
        let currentPath = NSFileManager.defaultManager().currentDirectoryPath;
        let envFilePath = currentPath + "/tests.xctest/Contents/Resources/EnvFile.plist"

        let envFile = EnvFile(envFilePath: envFilePath)

        let newEnvironment = Environment(name: "Hacking")
        newEnvironment.setConfig("Foo", forKey: "Bar")

        envFile.add(newEnvironment)

        XCTAssertEqual(envFile.environments().count, 4)
    }

    func test_lists_environments() {
        let currentPath = NSFileManager.defaultManager().currentDirectoryPath;
        let envFilePath = currentPath + "/tests.xctest/Contents/Resources/EnvFile.plist"

        let envFile = EnvFile(envFilePath: envFilePath)
        _ = envFile.environments()

{'fraction_non_alphanumeric': 0.18125960061443933, 'fraction_numerical': 0.0030721966205837174, 'mean_word_length': 2.315682281059063, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2066837', 'n_tokens_mistral': 877, 'n_tokens_neox': 825, 'n_words': 177}