Skip to content

Commit

Permalink
Added another game reset function, TODO: one function for instanceNr …
Browse files Browse the repository at this point in the history
…resets
  • Loading branch information
gergobuzas committed May 21, 2024
1 parent a296664 commit 4bfbfd8
Show file tree
Hide file tree
Showing 3 changed files with 284 additions and 281 deletions.
141 changes: 71 additions & 70 deletions HwProject/tests/DrainTest.java
Original file line number Diff line number Diff line change
@@ -1,70 +1,71 @@
package tests;

import org.junit.jupiter.api.*;

import static org.junit.jupiter.api.Assertions.*;

import src.*;
import tests.HelperClasses.*;

public class DrainTest {

private Game game;

@BeforeEach
public void setUp() {
game = new Game(System.out);
Drain.SetGame(game);

}

@Test
public void testGetInstanceNr() {
int initialInstanceNr = Drain.GetInstanceNr();
Drain drain1 = new Drain();
assertEquals(initialInstanceNr + 1, Drain.GetInstanceNr());
}

@Test
public void testPullWater() {
Source source = new Source();
TestPipe pipe = new TestPipe();
Drain drain = new Drain();

source.ConnectPipe(pipe);
drain.ConnectPipe(pipe);

source.Step();
pipe.Step();
drain.Step();

assertNotEquals(0, game.GetMechanicPoint());
}

@Test
public void testPickUpPump() {
// Create a Drain instance
Drain drain = new Drain();
// Pick up a pump
Pump pump = drain.PickUpPump();
// Verify that a pump is picked up
assertNotNull(pump);
}

@Test
public void testPickUpPipe() {
// Create a Drain instance
Drain drain = new Drain();
// Pick up a pipe
Pipe pipe = drain.PickUpPipe();
// Verify that a pipe is picked up
assertNotNull(pipe);
}

@AfterEach
public void cleanUp() {
TestPump.setInstanceNr(0);
TestPipe.setInstanceNr(0);
TestSource.setInstanceNr(0);
}
}
package tests;

import org.junit.jupiter.api.*;

import static org.junit.jupiter.api.Assertions.*;

import src.*;
import tests.HelperClasses.*;

public class DrainTest {

private Game game;

@BeforeEach
public void setUp() {
game = new Game(System.out);
Drain.SetGame(game);

}

@Test
public void testGetInstanceNr() {
int initialInstanceNr = Drain.GetInstanceNr();
Drain drain1 = new Drain();
assertEquals(initialInstanceNr + 1, Drain.GetInstanceNr());
}

@Test
public void testPullWater() {
Source source = new Source();
TestPipe pipe = new TestPipe();
Drain drain = new Drain();

source.ConnectPipe(pipe);
drain.ConnectPipe(pipe);

source.Step();
pipe.Step();
drain.Step();

assertNotEquals(0, game.GetMechanicPoint());
}

@Test
public void testPickUpPump() {
// Create a Drain instance
Drain drain = new Drain();
// Pick up a pump
Pump pump = drain.PickUpPump();
// Verify that a pump is picked up
assertNotNull(pump);
}

@Test
public void testPickUpPipe() {
// Create a Drain instance
Drain drain = new Drain();
// Pick up a pipe
Pipe pipe = drain.PickUpPipe();
// Verify that a pipe is picked up
assertNotNull(pipe);
}

@AfterEach
public void cleanUp() {
TestPump.setInstanceNr(0);
TestPipe.setInstanceNr(0);
TestSource.setInstanceNr(0);
TestDrain.setInstanceNr(0);
}
}
Loading

0 comments on commit 4bfbfd8

Please sign in to comment.