From f0bdee28c3c36ef36555511791f55b9e837204fa Mon Sep 17 00:00:00 2001 From: Richard Reiber Date: Sat, 5 Jun 2021 20:44:15 +0200 Subject: [PATCH] test: added PacketTest --- .../server/lobby/pipelining/PacketTest.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Server/src/test/java/uulm/teamname/marvelous/server/lobby/pipelining/PacketTest.java 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