Raizekas

Untitled

May 11th, 2021
476
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package unit;
  2.  
  3. import data.DataReading;
  4. import entity.ExchangeRequest;
  5. import org.junit.jupiter.api.BeforeEach;
  6. import org.junit.jupiter.api.DisplayName;
  7. import org.junit.jupiter.api.Test;
  8.  
  9. import java.io.ByteArrayInputStream;
  10. import java.io.InputStream;
  11.  
  12. import static org.junit.jupiter.api.Assertions.assertEquals;
  13.  
  14. public class DataReadingUnitTest
  15. {
  16.     private DataReading dReadingObject;
  17.  
  18.     @BeforeEach
  19.     public void setup()
  20.     {
  21.         dReadingObject = new DataReading();
  22.     }
  23.  
  24.     @Test
  25.     @DisplayName("Bandant įvesti 1.527 ir dollar į konsolę ir pažiūrėti ar nuskaito")
  26.     public void shouldReadData()
  27.     {
  28.         String inputString = "1.27\ndollar";
  29.         InputStream systemInBackup = System.in;
  30.         InputStream currentInput = new ByteArrayInputStream(inputString.getBytes());
  31.  
  32.         System.setIn(currentInput);
  33.  
  34.         ExchangeRequest exchange = DataReading.readData();
  35.  
  36.         assertEquals(1.27, exchange.getAmount(), "Neteisingai nuskaito pinigų kiekį");
  37.  
  38.         assertEquals("dollar", exchange.getCurrencyToExchange(), "Neteisingai nuskaito valiutos pavadinimą");
  39.     }
  40.  
  41. }
  42.  
RAW Paste Data