Skip to content

Instantly share code, notes, and snippets.

@SURYAKANTSHARMA
Created May 3, 2019 18:08
Show Gist options
  • Save SURYAKANTSHARMA/acc0bd99aa0012c3eedf4ab100dffa42 to your computer and use it in GitHub Desktop.
Save SURYAKANTSHARMA/acc0bd99aa0012c3eedf4ab100dffa42 to your computer and use it in GitHub Desktop.
testCart
func testCart() {
let product = Product(name: "Macbook", price: 100)
var cart = Cart()
cart.products.append(product)
XCTAssertEqual(product.price, cart.totalPrice)
let coupon = Coupon(code: "SPECIAL20", percentage: 20)
cart.apply(coupon)
XCTAssertEqual(cart.totalPrice, 80)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment