-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2942e2f
commit 628abe9
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Add player | ||
|
||
This chapter shows how to add a text to a game. | ||
|
||
## First test: an `App` has no text | ||
|
||
```rust | ||
fn test_empty_app_has_text() { | ||
let mut app = App::new(); | ||
assert_eq!(count_n_texts(&mut app), 0); | ||
} | ||
``` | ||
|
||
## Second test: can create an `App` with text | ||
|
||
```rust | ||
fn test_can_create_app_from_str() { | ||
create_app(String::from("irrelevant")); | ||
} | ||
``` | ||
|
||
## Third test: an `App` has text | ||
|
||
```rust | ||
fn test_app_has_text() { | ||
let mut app = create_app(String::from("irrelevant")); | ||
app.update(); | ||
assert_eq!(count_n_texts(&mut app), 1); | ||
} | ||
``` | ||
|
||
## Fourth test: an `App` has the correct text | ||
|
||
```rust | ||
fn test_app_uses_text() { | ||
let text = String::from("some random text"); | ||
let mut app = create_app(text.clone()); | ||
app.update(); | ||
assert_eq!(get_text(&mut app), text); | ||
} | ||
``` | ||
|
||
## Conclusion | ||
|
||
We can now create an `App` with a text. | ||
We have tested everything that the App does! | ||
|
||
Full code can be found at [https://github.com/richelbilderbeek/bevy_tdd_book_add_text](https://github.com/richelbilderbeek/bevy_tdd_book_add_text). |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.