mirror of
https://codeberg.org/info-bw-wiki/bluej-birdwatching.git
synced 2025-12-10 15:28:34 +01:00
Erster Commit, Aufgaben und Tests
This commit is contained in:
commit
2cff7468ce
5 changed files with 204 additions and 0 deletions
100
BirdwatchingTest.java
Normal file
100
BirdwatchingTest.java
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
|
||||
/**
|
||||
* Die Test-Klasse BirdwatchingTest.
|
||||
*
|
||||
* @author (Ihr Name)
|
||||
* @version (eine Versionsnummer oder ein Datum)
|
||||
*/
|
||||
public class BirdwatchingTest
|
||||
{
|
||||
|
||||
/**
|
||||
* Konstruktor fuer die Test-Klasse BirdwatchingTest
|
||||
*/
|
||||
public BirdwatchingTest()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Setzt das Testgerüst fuer den Test.
|
||||
*
|
||||
* Wird vor jeder Testfall-Methode aufgerufen.
|
||||
*/
|
||||
@BeforeEach
|
||||
public void setUp()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt das Testgerüst wieder frei.
|
||||
*
|
||||
* Wird nach jeder Testfall-Methode aufgerufen.
|
||||
*/
|
||||
@AfterEach
|
||||
public void tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testNumbersOfLast7Days()
|
||||
{
|
||||
Birdwatching bw = new Birdwatching();
|
||||
int[] numbers = bw.getNumbersOfLast7Days();
|
||||
assertEquals(numbers[0], 12);
|
||||
assertEquals(numbers[1], 7);
|
||||
assertEquals(numbers[2], 0);
|
||||
assertEquals(numbers[3], 6);
|
||||
assertEquals(numbers[4], 15);
|
||||
assertEquals(numbers[5], 8);
|
||||
assertEquals(numbers[6], 7);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToday()
|
||||
{
|
||||
Birdwatching bw = new Birdwatching();
|
||||
assertEquals(bw.getToday(), 7);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncrementTodaysCount()
|
||||
{
|
||||
Birdwatching bw = new Birdwatching();
|
||||
bw.incrementTodaysCount();
|
||||
assertEquals(bw.getToday(),8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCountForFirstDays()
|
||||
{
|
||||
Birdwatching bw = new Birdwatching();
|
||||
int[] sums = {0, 12, 19, 19, 25, 40, 48, 55};
|
||||
for(int i=0; i<7; i++ ) {
|
||||
assertEquals(bw.getCountForFirstDays(i),sums[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCountForMoreDaysThanTheArraySize() {
|
||||
Birdwatching bw = new Birdwatching();
|
||||
assertEquals(bw.getCountForFirstDays(10),55);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBusyDays() {
|
||||
Birdwatching bw = new Birdwatching();
|
||||
assertEquals(bw.getBusyDays(),3);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue