/
kellervi
/
JavaOOP2
Обзор
Документация
Войти
/
kellervi
/
JavaOOP2
Код
Запросы
1
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
src/test/java/RadioTest.java
163 строки
3 KB
Виктория
Edited commit
17 май 2026, 21:57
17 май 2026, 21:57
9a1677f
Код
Авторство
О чём код?
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; public class RadioTest { // по станции @Test public void nextStationFromLastToFirst() { Radio radio = new Radio(); radio.setCurrentStation(9); radio.next(); int expected = 0; int actual = radio.getCurrentStation(); Assertions.assertEquals(expected, actual); } @Test public void nextStationFromMiddle() { Radio radio = new Radio(); radio.setCurrentStation(5); radio.next(); int expected = 6; int actual = radio.getCurrentStation(); Assertions.assertEquals(expected, actual); } @Test public void prevStationFromMiddle() { Radio radio = new Radio(); radio.setCurrentStation(5); radio.prev(); int expected = 4; int actual = radio.getCurrentStation(); Assertions.assertEquals(expected, actual); } @Test public void prevStationFromFirstToLast() { Radio radio = new Radio(); radio.setCurrentStation(0); radio.prev(); int expected = 9; int actual = radio.getCurrentStation(); Assertions.assertEquals(expected, actual); } @Test public void setValidStation() { Radio radio = new Radio(); radio.setCurrentStation(7); int expected = 7; int actual = radio.getCurrentStation(); Assertions.assertEquals(expected, actual); } @Test public void setInvalidStationBelowZero() { Radio radio = new Radio(); radio.setCurrentStation(-1); int expected = 0; int actual = radio.getCurrentStation(); Assertions.assertEquals(expected, actual); } @Test public void setInvalidStationAboveNine() { Radio radio = new Radio(); radio.setCurrentStation(10); int expected = 0; int actual = radio.getCurrentStation(); Assertions.assertEquals(expected, actual); } //по звуку @Test public void shouldIncreaseVolume() { Radio radio = new Radio(); radio.increaseVolume(); radio.increaseVolume(); int expected = 2; int actual = radio.getCurrentVolume(); Assertions.assertEquals(expected, actual); } @Test public void setInvalidVolumeBelowZero() { Radio radio = new Radio(); radio.increaseVolume(); radio.decreaseVolume(); int expected = 0; int actual = radio.getCurrentVolume(); Assertions.assertEquals(expected, actual); } @Test public void setInvalidVolumeAboveHundred() { Radio radio = new Radio(); for (int i = 0; i < 101; i++) { radio.increaseVolume(); } int expected = 100; int actual = radio.getCurrentVolume(); Assertions.assertEquals(expected, actual); } @Test public void shouldDecreaseVolumeWhenAboveZero() { Radio radio = new Radio(); radio.increaseVolume(); radio.decreaseVolume(); int expected = 0; int actual = radio.getCurrentVolume(); Assertions.assertEquals(expected, actual); } @Test public void shouldNotDecreaseVolumeWhenAtZero() { Radio radio = new Radio(); radio.decreaseVolume(); int expected = 0; int actual = radio.getCurrentVolume(); Assertions.assertEquals(expected, actual); } }