<commit_before>//
//  RestApiManangerTest.swift
//  TFS
//
//  Created by <NAME> on 9/20/15.
//  Updated by <NAME> on 9/30/15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import Foundation
import SwiftyJSON
import SwiftHTTP
import XCTest

class RestApiManagerTest: XCTestCase {
    
    func testGetTeams() {
        
        //Success case
        RestApiManager.sharedInstance.baseURL = "https://almlatam.visualstudio.com"
        RestApiManager.sharedInstance.usr = "fidmor"
        RestApiManager.sharedInstance.pw = "FIDmor12!"
        RestApiManager.sharedInstance.collection = "DefaultCollection"
        
        RestApiManager.sharedInstance.getTeams() { json in
            let count = json["count"].int as Int?
            XCTAssertNotNil(count, "Connected to host")
            XCTAssertGreaterThan(Int(count!), 0, "Returned with some teams")
        }
        
        //Fail case
        RestApiManager.sharedInstance.baseURL = "https://almlata.visualstudio.com"
        RestApiManager.sharedInstance.usr = "fidmor"
        RestApiManager.sharedInstance.pw = "FIDmor12!"
        RestApiManager.sharedInstance.collection = "DefaultCollection"
        
        RestApiManager.sharedInstance.getCollections() { json in
            let count = json["count"].int as Int?
            XCTAssertNil(count, "Could not connect to host")
        }
    }<commit_msg>GetTeams UnitTest Upgraded with Asynchronous wait for api call.<commit_after>//
//  RestApiManangerTest.swift
//  TFS
//
//  Created by <NAME> on 9/20/15.
//  Updated by <NAME> on 9/30/15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import Foundation
import SwiftyJSON
import SwiftHTTP
import XCTest

class RestApiManagerTest: XCTestCase {
    
    func testGetTeams() {
        
        let expectation = expectationWithDescription("GetTeam")
        
        //Success case
        RestApiManager.sharedInstance.baseURL = "https://almlatam.visualstudio.com"
        RestApiManager.sharedInstance.usr = "jlmruiz"
        RestApiManager.sharedInstance.pw = "<PASSWORD>"
        RestApiManager.sharedInstance.collection = "DefaultCollection"
        
        RestApiManager.sharedInstance.getTeams( { (jsObject: JSON) -> () in
            var count: Int = jsObject["count"].int as Int!;
            XCTAssertNotNil(count, "Connected to host")
            XCTAssertGreaterThan(count, 0, "Returned with some teams")
            var jsProjects: JSON = jsObject["value"]
            var projectName = [String]()
            for index in 0...(count-1) {
                projectName.append(jsProjects[index]["name"].string as String!)
            }
            var projects = ["Url2015Project","Glimpse and Application Insights"]
            XCTAssertEqual(projectName, projects, "Correct Projects where found")
            expectation.fulfill()
        })
        
        waitForExpectationsWithTimeout(5.0, handler: { error in
            XCTAssertNil(error, "Request Timed Out")
        })
    }
{'fraction_non_alphanumeric': 0.10455764075067024, 'fraction_numerical': 0.014075067024128687, 'mean_word_length': 2.442906574394464, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 11, 'https://': 3, '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': '123260', 'n_tokens_mistral': 890, 'n_tokens_neox': 851, 'n_words': 194}