From d3361a76794a3dc0df3a7db1df54359beb51fc9a Mon Sep 17 00:00:00 2001 From: Maximilien LEDOUX Date: Sat, 26 Feb 2022 15:20:05 +0100 Subject: [PATCH] =?UTF-8?q?SignoutRule=20test=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lightcontainer/protocol/ProtocolWriter.java | 2 +- .../protocol/rules/writer/SignoutRuleTest.java | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/lightcontainer/protocol/ProtocolWriter.java b/app/src/main/java/lightcontainer/protocol/ProtocolWriter.java index 051794a..4605a30 100644 --- a/app/src/main/java/lightcontainer/protocol/ProtocolWriter.java +++ b/app/src/main/java/lightcontainer/protocol/ProtocolWriter.java @@ -31,7 +31,7 @@ public abstract class ProtocolWriter { public String execute(String... datas) { // Concatatène le nom de la commande avec les données (trim), avec un espace entre chaque String command = null; - StringJoiner builder = new StringJoiner(" ", this.cmdName, ""); + StringJoiner builder = new StringJoiner(" ", this.cmdName, "\r\n"); for (String data : datas) builder.add(data); diff --git a/app/src/test/java/lightcontainer/protocol/rules/writer/SignoutRuleTest.java b/app/src/test/java/lightcontainer/protocol/rules/writer/SignoutRuleTest.java index ab427ff..31bf799 100644 --- a/app/src/test/java/lightcontainer/protocol/rules/writer/SignoutRuleTest.java +++ b/app/src/test/java/lightcontainer/protocol/rules/writer/SignoutRuleTest.java @@ -1,7 +1,21 @@ package lightcontainer.protocol.rules.writer; +import lightcontainer.protocol.ProtocolWriter; +import org.junit.jupiter.api.Test; + import static org.junit.jupiter.api.Assertions.*; class SignoutRuleTest { + @Test + public void whenRuleIsRightThenReturnCommand() { + //GIVEN + ProtocolWriter protocolWriter = new SignoutRule(); + String[] datas = {}; + + //EXPECT + assertNotNull(protocolWriter.execute(datas)); + assertEquals("SIGNOUT\r\n", protocolWriter.execute(datas)); + } + } \ No newline at end of file