From 628abe9ec064f705bd829d567c6b7b9bbb1812ee Mon Sep 17 00:00:00 2001 From: richelbilderbeek Date: Mon, 8 Jul 2024 16:37:35 +0200 Subject: [PATCH] Improve --- add_text.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ add_text.png | Bin 0 -> 16203 bytes 2 files changed, 48 insertions(+) create mode 100644 add_text.md create mode 100644 add_text.png diff --git a/add_text.md b/add_text.md new file mode 100644 index 0000000..a63c051 --- /dev/null +++ b/add_text.md @@ -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). diff --git a/add_text.png b/add_text.png new file mode 100644 index 0000000000000000000000000000000000000000..64091b458adc87458215f820adfe14abe8e3a405 GIT binary patch literal 16203 zcmeHuXQ(awCy^~fShnyjhgAm)(r<|g4S!0-t+@(1B0+qumuW34~dG>qP zv_rdGc6eV^djLTjc=^2CSx?p>7U`7t&4mOHi+T#fC;OnGv%~jbZY6=iV^1~ivE5mP z5#Dk?A9}s-UH@m<$KRvnQd6JZz8%zLW+t|Jakq8+{?;kJ@Ap zIA-B>J?#~mD#lDqtphb^dRC0zwsrWR*yCn_wR-oM-$?u37$iO0j@Qh!Up8EAv9ZD9 zdNM`X_Vz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