Created
March 20, 2021 21:49
-
-
Save mgryszko/6c7c708d001688f1c0eb59c60206890e to your computer and use it in GitHub Desktop.
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
class PriceCartUseCaseTest { | |
val inventory = mockk<Inventory>() | |
val pricingEngine = mockk<PricingEngine>() | |
val useCase = PriceCartUseCase(inventory, pricingEngine) | |
val cartToPrice = Cart(listOf(CartItem("::sku1::", 2), CartItem("::sku2::", 1))) | |
val availableCart = Cart(listOf(CartItem("::sku1::", 1), CartItem("::sku2::", 0))) | |
val unavailableCart = Cart(listOf(CartItem("::sku1::", 0), CartItem("::sku2::", 0))) | |
val pricedCard = PricedCart(emptyList(), 0.toBigDecimal()) | |
@Test | |
fun `some cart items available`() { | |
every { inventory.check(cartToPrice) } returns availableCart | |
every { pricingEngine.price(availableCart) } returns pricedCard | |
expect(useCase.execute(cartToPrice)).toBe(pricedCard) | |
} | |
@Test | |
fun `none of cart items available`() { | |
every { inventory.check(cartToPrice) } returns unavailableCart | |
expect(useCase.execute(cartToPrice)).toBe(null) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment