test: added PacketTest
This commit is contained in:
parent
552bab8d93
commit
f0bdee28c3
@ -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();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user