//
//  MCPlusTests.swift
//  MCPlusTests
//
//  Created by seo ha on 11/03/2019.
//  Copyright © 2019 KangSH. All rights reserved.
//

import XCTest
@testable import kunkuk

class MCPlusLockScreenTests: XCTestCase {
    
    let screenLockViewController = mockScreenLockViewController()

    override func setUp() {
        // 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.
    }

    func testClickNum1(){
        screenLockViewController.savePasswordOnArray(number: 1)
        XCTAssert(screenLockViewController.arrPassword.contains(1))
    }
    
    func testClickNum2(){
        screenLockViewController.savePasswordOnArray(number: 2)
        XCTAssert(screenLockViewController.arrPassword.contains(2))
    }
    
    func testClickNum3(){
        screenLockViewController.savePasswordOnArray(number: 3)
        XCTAssert(screenLockViewController.arrPassword.contains(3))
    }
    
    func testClickNum4(){
        screenLockViewController.savePasswordOnArray(number: 4)
        XCTAssert(screenLockViewController.arrPassword.contains(4))
    }
    
    func testClickNum5(){
        screenLockViewController.savePasswordOnArray(number: 5)
        XCTAssert(screenLockViewController.arrPassword.contains(5))
    }
    
    func testClickNum6(){
        screenLockViewController.savePasswordOnArray(number: 6)
        XCTAssert(screenLockViewController.arrPassword.contains(6))
    }
    
    func testClickNum7(){
        screenLockViewController.savePasswordOnArray(number: 7)
        XCTAssert(screenLockViewController.arrPassword.contains(7))
    }
    
    func testClickNum8(){
        screenLockViewController.savePasswordOnArray(number: 8)
        XCTAssert(screenLockViewController.arrPassword.contains(8))
    }
    
    func testClickNum9(){
        screenLockViewController.savePasswordOnArray(number: 9)
        XCTAssert(screenLockViewController.arrPassword.contains(9))
    }
    
    func testClickNum0(){
        screenLockViewController.savePasswordOnArray(number: 0)
        XCTAssert(screenLockViewController.arrPassword.contains(0))
    }
    
    func testClickNumBackspace(){
        let count = screenLockViewController.arrPassword.count
        
        if count > 0{
            screenLockViewController.arrPassword.removeLast()
            XCTAssertEqual(count - 1, screenLockViewController.arrPassword.count)
        }else{
            XCTAssertEqual(0, screenLockViewController.arrPassword.count)
        }
    }
    
    func testSavePasswordOnArray(){
        screenLockViewController.savePasswordOnArray(number: 0)
        screenLockViewController.savePasswordOnArray(number: 2)
        screenLockViewController.savePasswordOnArray(number: 1)
        screenLockViewController.savePasswordOnArray(number: 3)
        screenLockViewController.savePasswordOnArray(number: 5)
        screenLockViewController.savePasswordOnArray(number: 4)
        
        screenLockViewController.savePasswordOnArray(number: 0)
        screenLockViewController.savePasswordOnArray(number: 2)
        screenLockViewController.savePasswordOnArray(number: 1)
        screenLockViewController.savePasswordOnArray(number: 3)
        screenLockViewController.savePasswordOnArray(number: 5)
        screenLockViewController.savePasswordOnArray(number: 4)
        
        XCTAssert(screenLockViewController.comparePasswordWithStorage())
        
    }
    
    func testIsContinuedPassword(){
        XCTAssert(screenLockViewController.isValidNumber(pw: "022323"))
    }

    func testIsOlderVersionPassword(){
        XCTAssertFalse(screenLockViewController.isOlderVersionPassword())
    }
}
