Last active
May 4, 2019 19:54
-
-
Save AlicanAkkus/5772cc3e40ccbbe4849a27b8efb855b0 to your computer and use it in GitHub Desktop.
interaction based test
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
package io.happy.customer | |
import spock.lang.Specification | |
class OrderCreateFacadeTest extends Specification { | |
def orderCommissionCalculator = Mock(OrderCommissionCalculator) | |
def orderCreateFacade = new OrderCreateFacade(orderCommissionCalculator) | |
void "should create order and verify interactions"() { | |
given: | |
def userId = 998 | |
def paymentMethod = "CARD" | |
def price = 100 | |
and: | |
1 * orderCommissionCalculator.calculate("CARD", 100) >> 2.3 | |
0 * _._ | |
when: | |
def order = orderCreateFacade.create(userId, paymentMethod, price) | |
then: | |
with(order) { | |
it.userId == 998 | |
it.paymentMethod == "CARD" | |
it.price == 100 | |
it.commissionAmount == 2.3 | |
it.orderCreatedDate.toLocalDate() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment