Created
May 3, 2020 17:39
-
-
Save anuragajwani/6339ce437db24a9026a809471e348fb8 to your computer and use it in GitHub Desktop.
iOS Dependecy Injection Swinject Ricardo respose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// use this in unit test target | |
class StubOrderValidator: OrderValidator { | |
var stubResponse: Bool! | |
func hasMinimumSpend(order: Order) -> Bool { | |
return self.stubResponse | |
} | |
} | |
class OrderViewModelTest { | |
func testButtonEnabledWhenOrderOverMinimumSpend() { | |
let stubValidator = StubOrderValidator() | |
let viewModel = OrderViewModel(validator: stubValidator) | |
stubValidator.stubResponse = true | |
let isPayButtonEnabled = viewModel.isPayButtonEnabled | |
assert(isPayButtonEnabled) | |
} | |
func testButtonDisabledWhenOrderUnderMinimumSpend() { | |
let stubValidator = StubOrderValidator() | |
let viewModel = OrderViewModel(validator: stubValidator) | |
stubValidator.stubResponse = false | |
let isPayButtonEnabled = viewModel.isPayButtonEnabled | |
assert(isPayButtonEnabled == false) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment