forked from pjwelcome/CakePatternWithSwinject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SwinjectExampleTests.swift
41 lines (33 loc) · 1.2 KB
/
SwinjectExampleTests.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
//
// SwinjectExampleTests.swift
// SwinjectExampleTests
//
// Created by pjapple on 2018/04/14.
// Copyright © 2018 Multimeleon. All rights reserved.
//
import XCTest
@testable import SwinjectExample
class SwinjectExampleTests: XCTestCase {
override func setUp() {
super.setUp()
Resolver.reset()
DepedencyContainer.instance.register(depedency: ProductsRepository.self, implemenation: {
TestProductsRepositoryImplementation()
})
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testGivenAProductTheProductsPriceWillBeFiveHundred() {
let expectedPrice = 1500.0
let viewModel = ProductViewModel()
XCTAssertTrue(viewModel.products.fetchProducts().first?.price == expectedPrice)
}
}
// TestProductsRepositoryImplementation is DI for test-cases
struct TestProductsRepositoryImplementation : ProductsRepository {
func fetchProducts() -> [Product] {
return [Product(name: "Adidas Sneakers", price: 1500.0), Product(name: "Nike Sneakers", price: 1000.0)]
}
}