This file contains hidden or 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
| // A view to represent the cards in a hand | |
| struct HandView: View { | |
| @ObservedObject var hand: Hand | |
| let namespace: Namespace.ID | |
| let onCardTap: (Card) -> Void | |
| var body: some View { | |
| HStack { | |
| ForEach(hand.cards) { card in |
This file contains hidden or 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
| struct DeckView: View { | |
| @ObservedObject var deck: Hand | |
| let namespace: Namespace.ID | |
| var body: some View { | |
| ZStack { | |
| // Just need to draw the last two so that the transition of card | |
| // from the hand back to the deck results in the old top card being | |
| // rendered as the new top card animates in |
This file contains hidden or 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
| struct ContentView: View { | |
| private var gameState = GameState() | |
| @Namespace private var animation | |
| var body: some View { | |
| VStack { | |
| // Some simple instructions | |
| Text(""" | |
| Tap a + button to add a card from the deck to the relevant hand. |
This file contains hidden or 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
| // | |
| // Created by Chris Mash on 10/02/2022. | |
| // | |
| import UIKit | |
| import ProvisioningProfile | |
| import FirebaseDatabase | |
| // NOTE: this gist uses some personal extensions I've written which aren't shared here but you should be able to swap out easily enough: | |
| // Bundle.main.appVersion |
This file contains hidden or 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
| delegate = ADelegate() | |
| sut = UnitBeingTested(delegate) | |
| sut.aFunctionCall() | |
| verify(delegate) | |
| .callMadeTo(functionOnDelegate) | |
| .withParameter(anything()) |
This file contains hidden or 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
| delegate = ADelegate() | |
| sut = UnitBeingTested(delegate) | |
| sut.aFunctionCall() | |
| verify(delegate) | |
| .callMadeTo(functionOnDelegate) | |
| .withParameter("1234") |
This file contains hidden or 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
| delegate = ADelegate() | |
| sut = UnitBeingTested(delegate) | |
| sut.aFunctionCall() | |
| verify(delegate) | |
| .callMadeTo(onSuccess) |
This file contains hidden or 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
| delegate = ADelegate() | |
| sut = UnitBeingTested(delegate) | |
| sut.aFunctionCall() | |
| verify(delegate) | |
| .callMadeTo(onSuccess) | |
| verify(delegate) | |
| .callNOTMadeTo(onError) |
This file contains hidden or 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
| sut = UnitBeingTested("a value") | |
| verify(sut.value) | |
| .is("a value") |
This file contains hidden or 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
| mockedDependency = mock(DependencyOfUnitBeingTested) | |
| sut = UnitBeingTested("a value", mockedDependency) | |
| verify(sut.value) | |
| .is("a value") | |
| verify(mockedDependency) | |
| .callMadeTo(functionCalledByUnitBeingTested) | |
| .withParameter("a value") |