View Javadoc
1   package de.aikiit.game.kaiser;
2   
3   import lombok.SneakyThrows;
4   import org.junit.jupiter.api.Test;
5   import uk.org.webcompere.systemstubs.SystemStubs;
6   
7   import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
8   import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
9   
10  class KaiserActionsTest {
11  
12      @SneakyThrows
13      @Test
14      void buyWithPositiveInput() {
15          SystemStubs.withTextFromSystemIn("11")
16                  .execute(() -> {
17                      assertThat(KaiserActions.buy(new KaiserEngine()))
18                              .isTrue();
19                  });
20      }
21  
22      @SneakyThrows
23      @Test
24      void buyWithZeroInputWillTriggerSell() {
25          SystemStubs.withTextFromSystemIn("0")
26                  .execute(() -> {
27                      assertThat(KaiserActions.buy(new KaiserEngine()))
28                              .isFalse();
29                  });
30      }
31  
32  
33      @SneakyThrows
34      @Test
35      void sell() {
36          SystemStubs.withTextFromSystemIn("0")
37                  .execute(() -> assertDoesNotThrow(() -> KaiserActions.sell(new KaiserEngine())));
38      }
39  
40      @Test
41      @SneakyThrows
42      void feed() {
43          SystemStubs.withTextFromSystemIn("0")
44                  .execute(() -> assertDoesNotThrow(() -> KaiserActions.feed(new KaiserEngine())));
45      }
46  
47      @Test
48      @SneakyThrows
49      void cultivate() {
50          SystemStubs.withTextFromSystemIn("0")
51                  .execute(() -> assertDoesNotThrow(() -> KaiserActions.cultivate(new KaiserEngine())));
52  
53      }
54  }