Skip to content

Commit

Permalink
Feat: add CollectionBinderDataSource tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Oni-zerone committed May 22, 2019
1 parent cd1488c commit 3529fe9
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Example/PowerTools.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
9750D0A92293EAF600E08571 /* GridSectionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9750D0A82293EAF600E08571 /* GridSectionTests.swift */; };
9750D0AB22947ECF00E08571 /* SectionViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9750D0AA22947ECF00E08571 /* SectionViewModelTests.swift */; };
9750D0AF22948A4900E08571 /* Operators.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9750D0AE22948A4900E08571 /* Operators.swift */; };
9750D0B32294C09600E08571 /* GridDataSourceInteractionDelegateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9750D0B22294C09600E08571 /* GridDataSourceInteractionDelegateTests.swift */; };
9750D0B62295C3A300E08571 /* CollectionBinderDataSourceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9750D0B52295C3A300E08571 /* CollectionBinderDataSourceTests.swift */; };
97607D0022099BC20071AB8D /* ArrayTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97607CFF22099BC20071AB8D /* ArrayTests.swift */; };
977F82AC21D4D91B0044074A /* SublinePipeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 977F82AA21D4D8BC0044074A /* SublinePipeTests.swift */; };
97A34E512195812700E7F401 /* ColorViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97A34E502195812700E7F401 /* ColorViewModel.swift */; };
Expand Down Expand Up @@ -79,6 +81,8 @@
9750D0A82293EAF600E08571 /* GridSectionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GridSectionTests.swift; sourceTree = "<group>"; };
9750D0AA22947ECF00E08571 /* SectionViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SectionViewModelTests.swift; sourceTree = "<group>"; };
9750D0AE22948A4900E08571 /* Operators.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Operators.swift; sourceTree = "<group>"; };
9750D0B22294C09600E08571 /* GridDataSourceInteractionDelegateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GridDataSourceInteractionDelegateTests.swift; sourceTree = "<group>"; };
9750D0B52295C3A300E08571 /* CollectionBinderDataSourceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionBinderDataSourceTests.swift; sourceTree = "<group>"; };
97607CFF22099BC20071AB8D /* ArrayTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArrayTests.swift; sourceTree = "<group>"; };
977F82AA21D4D8BC0044074A /* SublinePipeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SublinePipeTests.swift; sourceTree = "<group>"; };
97A34E502195812700E7F401 /* ColorViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorViewModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -173,7 +177,7 @@
9717B2BD21BB40C700C66EE0 /* BaseModels */,
9717B2DE21BD30E600C66EE0 /* Pipeline */,
9717B2C221BB480200C66EE0 /* ModelUpdateTests */,
9750D09D2292F7B300E08571 /* GridDataSource */,
9750D0B42295C37900E08571 /* BinderDataSource */,
607FACE91AFB9204008FA782 /* Supporting Files */,
);
path = Tests;
Expand Down Expand Up @@ -243,10 +247,20 @@
9750D09E2292F7D600E08571 /* GridModuleTests.swift */,
9750D0A422935F4A00E08571 /* GridItemTests.swift */,
9750D0A82293EAF600E08571 /* GridSectionTests.swift */,
9750D0B22294C09600E08571 /* GridDataSourceInteractionDelegateTests.swift */,
);
path = GridDataSource;
sourceTree = "<group>";
};
9750D0B42295C37900E08571 /* BinderDataSource */ = {
isa = PBXGroup;
children = (
9750D09D2292F7B300E08571 /* GridDataSource */,
9750D0B52295C3A300E08571 /* CollectionBinderDataSourceTests.swift */,
);
path = BinderDataSource;
sourceTree = "<group>";
};
97607CFE22099B950071AB8D /* Base */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -528,6 +542,7 @@
9717B2CD21BC08CE00C66EE0 /* StringCell.swift in Sources */,
9750D0A3229336AF00E08571 /* ViewTests.swift in Sources */,
9717B2E321BD315C00C66EE0 /* AssertPipe.swift in Sources */,
9750D0B62295C3A300E08571 /* CollectionBinderDataSourceTests.swift in Sources */,
9750D0AB22947ECF00E08571 /* SectionViewModelTests.swift in Sources */,
9717B2BF21BB410500C66EE0 /* StringViewModel.swift in Sources */,
977F82AC21D4D91B0044074A /* SublinePipeTests.swift in Sources */,
Expand All @@ -537,6 +552,7 @@
9717B2E021BD30FE00C66EE0 /* PipelineTests.swift in Sources */,
9717B2CA21BC06F300C66EE0 /* DataSourceUpdateTests.swift in Sources */,
9750D0A92293EAF600E08571 /* GridSectionTests.swift in Sources */,
9750D0B32294C09600E08571 /* GridDataSourceInteractionDelegateTests.swift in Sources */,
9750D0AF22948A4900E08571 /* Operators.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// CollectionDataSourceTests.swift
// PowerTools_Tests
//
// Created by Andrea Altea on 22/05/2019.
// Copyright © 2019 CocoaPods. All rights reserved.
//

import XCTest
import PowerTools

class CollectionBinderDataSourceTests: XCTestCase {

var collection: UICollectionView!
var dataSource: CollectionBinderDataSource!

override func setUp() {
collection = UICollectionView(frame: CGRect(origin: .zero, size: CGSize(width: 320, height: 640)),
collectionViewLayout: UICollectionViewLayout())
dataSource = CollectionBinderDataSource(view: collection, model: [])
}

override func tearDown() {
dataSource = nil
collection = nil
}

func testDataSourceSetup() {
XCTAssert(dataSource == collection.dataSource as? CollectionBinderDataSource)
let newCollection = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewLayout())
dataSource.view = newCollection
XCTAssert(dataSource == newCollection.dataSource as? CollectionBinderDataSource)
XCTAssert(collection.dataSource == nil)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// GridDataSourceInteractionDelegate.swift
// PowerTools_Tests
//
// Created by Andrea Altea on 22/05/2019.
// Copyright © 2019 CocoaPods. All rights reserved.
//

import XCTest

class GridDataSourceInteractionDelegate: XCTestCase {

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 testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}

func testPerformanceExample() {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ open class CollectionBinderDataSource: BinderDataSource<UICollectionView>, UICol

override public var view: UICollectionView? {
didSet {
oldValue?.dataSource = nil
self.view?.dataSource = self
}
}
Expand Down

0 comments on commit 3529fe9

Please sign in to comment.