diff --git a/Server/src/test/java/uulm/teamname/marvelous/server/lobby/pipelining/PacketTest.java b/Server/src/test/java/uulm/teamname/marvelous/server/lobby/pipelining/PacketTest.java new file mode 100644 index 0000000..e3ea747 --- /dev/null +++ b/Server/src/test/java/uulm/teamname/marvelous/server/lobby/pipelining/PacketTest.java @@ -0,0 +1,43 @@ +package uulm.teamname.marvelous.server.lobby.pipelining; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import uulm.teamname.marvelous.gamelibrary.requests.Request; +import uulm.teamname.marvelous.gamelibrary.requests.RequestBuilder; +import uulm.teamname.marvelous.gamelibrary.requests.RequestType; + +import static org.junit.jupiter.api.Assertions.*; +import static org.assertj.core.api.Assertions.*; + +class PacketTest { + Packet packet; + + @BeforeEach + void beforeEach(){ + var requests = new Request[] { + new RequestBuilder(RequestType.Req).buildGameRequest(), + new RequestBuilder(RequestType.MoveRequest).buildGameRequest() + }; + packet = new Packet(requests, null); + } + + @Test + void containsRequestTest(){ + assertThat(packet.containsRequestOfType(RequestType.Req)).isTrue(); + assertThat(packet.containsRequestOfType(RequestType.DisconnectRequest)).isFalse(); + } + + @Test + void removeRequestsOfTypesTest(){ + packet.removeRequestsOfTypes(RequestType.Req); + assertThat(packet).containsOnly(new RequestBuilder(RequestType.MoveRequest).buildGameRequest()); + } + + @Test + void removeRequestsNotOfTypesTest(){ + packet.removeRequestsNotOfTypes(RequestType.Req); + assertThat(packet).containsOnly(new RequestBuilder(RequestType.Req).buildGameRequest()); + } + + //TODO: test getOrigin(); +} \ No newline at end of file