-
Notifications
You must be signed in to change notification settings - Fork 1
/
CommunesUnitTests.swift
67 lines (45 loc) · 1.55 KB
/
CommunesUnitTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
// CommunesUnitTests.swift
// APIRestDemoTests
//
// Created by Adrian Iraizos Mendoza on 22/1/24.
//
import XCTest
@testable import APIRestDemo
final class CommunesUnitTests: XCTestCase {
var sut: CommunesModeLogic!
override func setUpWithError() throws {
let mock = CommunesNetworkMock()
sut = CommunesModeLogic(persistence: mock)
}
override func tearDownWithError() throws {
sut = nil
}
func testFetchRegions_shouldBe5() {
XCTAssertEqual(sut.getRegionsCount(), 0)
sut.fetchRegions()
XCTAssertEqual(sut.getRegionsCount(),5)
}
func test_getRegionRow_ShouldBeRegion1Code1() {
let region = Region(nom: "Region 1", code: "1")
sut.fetchRegions()
let indexPath = IndexPath(row: 1, section: 1)
let row = sut.getRegionRow(indexPath: indexPath)
XCTAssertEqual(row, region)
}
func test_deleteRegion() {
sut.fetchRegions()
let indexPath = IndexPath(row: 1, section: 1)
sut.deleteRegion(indexPath: indexPath)
XCTAssertEqual(sut.getRegionsCount(),4)
}
func test_moveRegion() {
sut.fetchRegions()
let from = IndexPath(row: 1, section: 1)
let to = IndexPath(row: 4, section: 1)
let row = sut.getRegionRow(indexPath: from)
sut.moveRegion(indexPath: from, to: to)
let new = sut.getRegionRow(indexPath: to)
XCTAssertEqual(row, new)
}
}