Skip to content

Commit

Permalink
Improve
Browse files Browse the repository at this point in the history
  • Loading branch information
richelbilderbeek committed Jul 8, 2024
1 parent 2942e2f commit 628abe9
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions add_text.md
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).
Binary file added add_text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 628abe9

Please sign in to comment.