<commit_before>//
//  DataManagerTests.swift
//  Artikolo
//
//  Created by <NAME> on 4/30/17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import XCTest
@testable import Artikolo
import RxSwift

class DataManagerTests: XCTestCase {
    
    let dataManager = DataManager(backend: ArrayBackend())
    var disposeBag: DisposeBag!
    
    override func setUp() {
        super.setUp()
        disposeBag = DisposeBag()
        
        try! dataManager.reset()
        // Put setup code here. This method is called before the invocation of each test method in the class.
    }
    
    override func tearDown() {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
        super.tearDown()
    }
    
    func testURLCanBeSaved() {
        let article = Article(url: URL(string: "http://zeldathon.net/")!)
        
        var articles: [Article] = []
        
        dataManager.articles.subscribe(onNext: {
            articles = $0
        })
        .addDisposableTo(disposeBag)
        
        dataManager.save(article: article)
        
        XCTAssertEqual(articles, [article])
    }
    
    func testDataManagerIsReset() {
        let article = Article(url: URL(string: "http://zeldathon.net/")!)
        
        var articles: [Article] = []
        
        dataManager.articles.subscribe(onNext: {
            articles = $0
        })
        .addDisposableTo(disposeBag)
        
        dataManager.save(article: article)
        try! dataManager.reset()
        
        XCTAssertEqual(articles, [])
    }
    
}

class ArrayBackend: DataManagerBackend {
    
    private let articlesVariable = Variable<[Article]>([])
    let articles: Observable<[Article]>
    
    init() {
        articles = articlesVariable.asObservable()
    }
    
    func save(article: Article) {
        var mutableArticles = articlesVariable.value
        mutableArticles.append(article)
        articlesVariable.value = mutableArticles
    }
    
    func reset() {
        articlesVariable.value = []
    }
    
}
<commit_msg>Fix tests so they compile again.<commit_after>//
//  DataManagerTests.swift
//  Artikolo
//
//  Created by <NAME>ler on 4/30/17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import XCTest
@testable import Artikolo
import RxSwift

class DataManagerTests: XCTestCase {
    
    let dataManager = DataManager(backend: ArrayBackend())
    var disposeBag: DisposeBag!
    
    override func setUp() {
        super.setUp()
        disposeBag = DisposeBag()
        
        try! dataManager.reset()
        // Put setup code here. This method is called before the invocation of each test method in the class.
    }
    
    override func tearDown() {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
        super.tearDown()
    }
    
    func testURLCanBeSaved() {
        let article = Article(url: URL(string: "http://zeldathon.net/")!, addedOn: Date(), createdOn: Date())
        
        var articles: [Article] = []
        
        dataManager.articles.subscribe(onNext: {
            articles = $0
        })
        .addDisposableTo(disposeBag)
        
        dataManager.save(article: article)
        
        XCTAssertEqual(articles, [article])
    }
    
    func testDataManagerIsReset() {
        let article = Article(url: URL(string: "http://zeldathon.net/")!, addedOn: Date(), createdOn: Date())
        
        var articles: [Article] = []
        
        dataManager.articles.subscribe(onNext: {
            articles = $0
        })
        .addDisposableTo(disposeBag)
        
        dataManager.save(article: article)
        try! dataManager.reset()
        
        XCTAssertEqual(articles, [])
    }
    
}

class ArrayBackend: DataManagerBackend {
    
    private let articlesVariable = Variable<[Article]>([])
    let articles: Observable<[Article]>
    
    init() {
        articles = articlesVariable.asObservable()
    }
    
    func save(article: Article) {
        var mutableArticles = articlesVariable.value
        mutableArticles.append(article)
        articlesVariable.value = mutableArticles
    }
    
    func reset() {
        articlesVariable.value = []
    }
    
}

{'fraction_non_alphanumeric': 0.10210280373831776, 'fraction_numerical': 0.0051401869158878505, 'mean_word_length': 2.0732232591529076, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '6870298', 'n_tokens_mistral': 1263, 'n_tokens_neox': 1216, 'n_words': 297}