From 9a459196a4a211953b17bc18a6bcb023050e163e Mon Sep 17 00:00:00 2001 From: github actions Date: Mon, 13 May 2024 17:17:14 +0000 Subject: [PATCH] . d updated markdown snippets --- .../docs/how_to/LoadersAndSavers.md | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/approvaltests-util/docs/how_to/LoadersAndSavers.md b/approvaltests-util/docs/how_to/LoadersAndSavers.md index 8d82cf1e4..079258347 100644 --- a/approvaltests-util/docs/how_to/LoadersAndSavers.md +++ b/approvaltests-util/docs/how_to/LoadersAndSavers.md @@ -41,16 +41,18 @@ We want to test the following method: ```java -public void sendOutSeniorDiscounts(DataBase database, MailServer mailServer) { - List seniorCustomers = database.getSeniorCustomers(); - for (Customer customer : seniorCustomers) { - Discount seniorDiscount = getSeniorDiscount(); - String message = generateDiscountMessage(customer, seniorDiscount); - mailServer.sendMessage(customer, message); - } +public void sendOutSeniorDiscounts(DataBase database, MailServer mailServer) +{ + List seniorCustomers = database.getSeniorCustomers(); + for (Customer customer : seniorCustomers) + { + Discount seniorDiscount = getSeniorDiscount(); + String message = generateDiscountMessage(customer, seniorDiscount); + mailServer.sendMessage(customer, message); + } } ``` -snippet source | anchor +snippet source | anchor In this case, we want to replace the functions that use the DataBase object with Loaders : @@ -62,14 +64,15 @@ We start with the test: ```java @Test -public void senior_customer_list_includes_only_those_over_age_65() { - DataBase database = initializeDatabase(); - MailServer mailServer = initializeMailServer(); - sendOutSeniorDiscounts(database, mailServer); - Approvals.verifyAll("", mailServer.getRecipients()); +public void senior_customer_list_includes_only_those_over_age_65() +{ + DataBase database = initializeDatabase(); + MailServer mailServer = initializeMailServer(); + sendOutSeniorDiscounts(database, mailServer); + Approvals.verifyAll("", mailServer.getRecipients()); } ``` -snippet source | anchor +snippet source | anchor This test works against a live database with a live mail server. @@ -91,7 +94,7 @@ Now we dump the data resulting from a successful query so that we can create a f List seniorCustomers = database.getSeniorCustomers(); seniorCustomers.stream().forEach(System.out::println); ``` -snippet source | anchor +snippet source | anchor generates @@ -110,11 +113,10 @@ Step 3: Create a result object populated with these values (or at least enough o ```java -List.of( -new Customer( "Bob, Jones, 123 Elm St., Tempe, AZ, 14-MAR-1958"), -new Customer("Mary, Smith, 345 Oak St., Mason, VA, 04-MAY-1944")); +List.of(new Customer("Bob, Jones, 123 Elm St., Tempe, AZ, 14-MAR-1958"), + new Customer("Mary, Smith, 345 Oak St., Mason, VA, 04-MAY-1944")); ``` -snippet source | anchor +snippet source | anchor ### Step 4: In the original method, replace the function call with a Loader