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
| public interface LogInListener { | |
| void logInSuccess(String email, String password); | |
| void logInFailure(Exception exception, String email, String password); | |
| } |
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
| class LogInModelTest : LogInListener { | |
| private lateinit var successTask: Task<AuthResult> | |
| private lateinit var failureTask: Task<AuthResult> | |
| @Mock | |
| private lateinit val mAuth: FirebaseAuth | |
| private lateinit var logInModel: LogInModel | |
| private var logInResult = UNDEF | |
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
| @Before | |
| fun setUp() { | |
| MockitoAnnotations.initMocks(this) | |
| successTask = object : Task<AuthResult>() { | |
| override fun isComplete(): Boolean = true | |
| override fun isSuccessful(): Boolean = true | |
| // ... | |
| override fun addOnCompleteListener(executor: Executor, | |
| onCompleteListener: OnCompleteListener<AuthResult>): Task<AuthResult> { |
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
| @Test | |
| fun logInSuccess_test() { | |
| val email = "cool@cool.com" | |
| val password = "123456" | |
| Mockito.`when`(mAuth!!.signInWithEmailAndPassword(email, password)) | |
| .thenReturn(successTask) | |
| logInModel!!.logIn(email, password) | |
| assert(logInResult == SUCCESS) | |
| } |
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
| override fun logInSuccess(email: String, password: String) { | |
| logInResult = SUCCESS | |
| } | |
| override fun logInFailure(exception: Exception, email: String, password: String) { | |
| logInResult = FAILURE | |
| } | |
| } |
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
| class LogInModelTest : LogInListener { | |
| private lateinit var successTask: Task<AuthResult> | |
| private lateinit var failureTask: Task<AuthResult> | |
| @Mock | |
| private lateinit val mAuth: FirebaseAuth | |
| private lateinit var logInModel: LogInModel | |
| private var logInResult = UNDEF | |
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
| @Test | |
| fun logInFailure_test() { | |
| val email = "cool@cool.com" | |
| val password = "123_456" | |
| Mockito.`when`(mAuth!!.signInWithEmailAndPassword(email, password)) | |
| .thenReturn(failureTask) | |
| accountModel!!.logIn(email, password) | |
| assert(logInResult == FAILURE) | |
| } |
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
| from enum import Enum | |
| class State(Enum): | |
| AIR = 0 | |
| LAND = 1 | |
| SEA = 2 | |
| myState = State.AIR | |
| # Prints 0 |
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
| # In order formatting | |
| # Hi, my name is Brett and I am writing on my Medium blog. | |
| a = "Hi, my name is {} and I am writing on my {} blog.".format('Brett', 'Medium') | |
| # Index formatting | |
| # I'm going to a birthday party because it is Paul's birthday. | |
| a = "I'm going to a {0} party because it is {1}'s {0}".format('birthday', 'Paul') |
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
| from dataclasses import dataclass | |
| # Define dataclass | |
| @dataclass | |
| class Vector3D: | |
| x: int | |
| y: int | |
| z: int | |
| # Create a vector |