<commit_before>//
//  AutoLayoutHelperTests.swift
//  AutoLayoutHelperTests
//
//  Created by <NAME> on 26/10/2014.
//  Copyright (c) 2014 madhikarma. All rights reserved.
//

import UIKit
import XCTest


class UIViewAutoLayoutHelperTests: XCTestCase {
    
    private var mockView: UIView!
    private var mockSuperview: UIView!

    
    // MARK: - Setup / Teardown
    
    override func setUp() {

        super.setUp()
        
        // Given
        
        self.mockSuperview = UIView(frame: CGRectZero)
        self.mockView = UIView(frame: CGRectZero)
        self.mockView.translatesAutoresizingMaskIntoConstraints = false
        self.mockSuperview.addSubview(mockView)
    }
    
    override func tearDown() {
        
        super.tearDown()
        
        self.mockView.removeFromSuperview()
        self.mockView = nil
        self.mockSuperview = nil
    }

    
    // MARK: - Fill
    
    func testFillSuperview_ReturnsCorrectNumberOfConstraints() {
        
        // When
        let constraints: [NSLayoutConstraint] = self.mockView.fillSuperView(UIEdgeInsetsZero)
        
        // Then
        let actualResult = constraints.count
        let expectedResult = 4
        
        XCTAssertEqual(expectedResult, actualResult, "Error: expected constraints count to be \(expectedResult) constraints but instead it is \(expectedResult)")
    }

    func testFillSuperview_AddsConstraints() {
        
        // When
        let constraints: [NSLayoutConstraint] = self.mockView.fillSuperView(UIEdgeInsetsZero)
        
        // Then
        let expectedResult = self.mockSuperview.constraints
        let actualResult: [NSLayoutConstraint] = constraints
        
        XCTAssertEqual(expectedResult, actualResult, "Error: expected constraints to be \(expectedResult) constraints but instead it is \(expectedResult)")
    }

    func testFillSuperview_CreatesTopConstraint() {
        
        // When

        let constraints: [NSLayoutConstraint] = self.mockView.fillSuperView(UIEdgeInsetsMake(10.0, 0.0, 0.0, 0.0))
        
        // Then

        let constraint = constraints[0]

        self.verify(constraint, firstView: self.mockView, firstAttribute: .Top, secondView: self.mockSuperview, secondAttribute: .Top, relation: .Equal, constant: 10.0)
    }
    
    func testFillSuperview_CreatesLeftConstraint() {
        
        // When

        let constraints: [NSLayoutConstraint] = self.mockView.fillSuperView(UIEdgeInsetsMake(0.0, 10.0, 0.0, 0.0))

        // Then

        let constraint = constraints[1]

        self.verify(constraint, firstView: self.mockView, firstAttribute: .Left, secondView: self.mockSuperview, secondAttribute: .Left, relation: .Equal, constant: 10.0)
    }
    
    func testFillSuperview_CreatesBottomConstraint() {
        
        // When

        let constraints: [NSLayoutConstraint] = self.mockView.fillSuperView(UIEdgeInsetsMake(0.0, 0.0, 10.0, 0.0))
        
        // Then
        
        let constraint = constraints[2]

        self.verify(constraint, firstView: self.mockView, firstAttribute: .Bottom, secondView: self.mockSuperview, secondAttribute: .Bottom, relation: .Equal, constant: -10.0)


    }

    func testFillSuperview_CreatesRightConstraint() {
        
        // When

        let constraints: [NSLayoutConstraint] = self.mockView.fillSuperView(UIEdgeInsetsMake(0.0, 0.0, 0.0, 10.0))

        // Then

        let constraint = constraints[3]

        self.verify(constraint, firstView: self.mockView, firstAttribute: .Right, secondView: self.mockSuperview, secondAttribute: .Right, relation: .Equal, constant: -10.0)<commit_msg>Fix for failing unit test<commit_after>//
//  AutoLayoutHelperTests.swift
//  AutoLayoutHelperTests
//
//  Created by <NAME> on 26/10/2014.
//  Copyright (c) 2014 madhikarma. All rights reserved.
//

import UIKit
import XCTest


class UIViewAutoLayoutHelperTests: XCTestCase {
    
    private var mockView: UIView!
    private var mockSuperview: UIView!

    
    // MARK: - Setup / Teardown
    
    override func setUp() {

        super.setUp()
        
        // Given
        
        self.mockSuperview = UIView(frame: CGRectZero)
        self.mockView = UIView(frame: CGRectZero)
        self.mockView.translatesAutoresizingMaskIntoConstraints = false
        self.mockSuperview.addSubview(mockView)
    }
    
    override func tearDown() {
        
        super.tearDown()
        
        self.mockView.removeFromSuperview()
        self.mockView = nil
        self.mockSuperview = nil
    }

    
    // MARK: - Fill
    
    func testFillSuperview_ReturnsCorrectNumberOfConstraints() {
        
        // When
        let constraints: [NSLayoutConstraint] = self.mockView.fillSuperView(UIEdgeInsetsZero)
        
        // Then
        let actualResult = constraints.count
        let expectedResult = 4
        
        XCTAssertEqual(expectedResult, actualResult, "Error: expected constraints count to be \(expectedResult) constraints but instead it is \(expectedResult)")
    }

    func testFillSuperview_AddsConstraints() {
        
        // When
        let constraints: [NSLayoutConstraint] = self.mockView.fillSuperView(UIEdgeInsetsZero)
        
        // Then
        let expectedResult = self.mockSuperview.constraints
        let actualResult: [NSLayoutConstraint] = constraints
        
        XCTAssertEqual(expectedResult, actualResult, "Error: expected constraints to be \(expectedResult) constraints but instead it is \(expectedResult)")
    }

    func testFillSuperview_CreatesTopConstraint() {
        
        // When

        let constraints: [NSLayoutConstraint] = self.mockView.fillSuperView(UIEdgeInsetsMake(10.0, 0.0, 0.0, 0.0))
        
        // Then

        let constraint = constraints[0]

        self.verify(constraint, firstView: self.mockView, firstAttribute: .Top, secondView: self.mockSuperview, secondAttribute: .Top, relation: .Equal, constant: 10.0)
    }
    
    func testFillSuperview_CreatesLeadingConstraint() {
        
        // When

        let constraints: [NSLayoutConstraint] = self.mockView.fillSuperView(UIEdgeInsetsMake(0.0, 10.0, 0.0, 0.0))

        // Then

        let constraint = constraints[1]

        self.verify(constraint, firstView: self.mockView, firstAttribute: .Leading, secondView: self.mockSuperview, secondAttribute: .Leading, relation: .Equal, constant: 10.0)
    }
    
    func testFillSuperview_CreatesBottomConstraint() {
        
        // When

        let constraints: [NSLayoutConstraint] = self.mockView.fillSuperView(UIEdgeInsetsMake(0.0, 0.0, 10.0, 0.0))
        
        // Then
        
        let constraint = constraints[2]

        self.verify(constraint, firstView: self.mockView, firstAttribute: .Bottom, secondView: self.mockSuperview, secondAttribute: .Bottom, relation: .Equal, constant: -10.0)


    }

    func testFillSuperview_CreatesTrailingConstraint() {
        
        // When

        let constraints: [NSLayoutConstraint] = self.mockView.fillSuperView(UIEdgeInsetsMake(0.0, 0.0, 0.0, 10.0))

        // Then

        let constraint = constraints[3]

        self.verify(constraint, firstView: self.mockView, firstAttribute: .Trailing, secondView: self.mockSuperview, secondAttribute: .Trailing, relation: .Equal, constant: -10.0)
{'fraction_non_alphanumeric': 0.09549945115257959, 'fraction_numerical': 0.01783754116355653, 'mean_word_length': 2.479236276849642, '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': '3868252', 'n_tokens_mistral': 2173, 'n_tokens_neox': 2047, 'n_words': 451}