From 0a4a7ee6a38982ab29478a90356793b8b7adf31b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matt=C3=A9o=20Delucchi?= Date: Thu, 30 May 2024 23:01:31 +0200 Subject: [PATCH] =?UTF-8?q?test(resp):=20ajoute=20un=20test=20pour=20le=20?= =?UTF-8?q?d=C3=A9codage=20de=20strings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/Shared.UnitTests/Resp.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/Shared.UnitTests/Resp.cs diff --git a/tests/Shared.UnitTests/Resp.cs b/tests/Shared.UnitTests/Resp.cs new file mode 100644 index 0000000..56abae3 --- /dev/null +++ b/tests/Shared.UnitTests/Resp.cs @@ -0,0 +1,23 @@ +using System.Text; +using Shared.Resp; + +namespace Shared.unitTests; + +public class RespTests +{ + [Theory] + [InlineData("+OK\r\n", "OK")] + [InlineData("-NOT OK\r\n", "NOT OK")] + [InlineData("$5\r\nHELLO\r\n", "HELLO")] + [InlineData("$6\r\n\nWORLD\r\n", "\nWORLD")] + [InlineData("$0\r\n\r\n", "")] + public void StringDecode(string input, string expected) + { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(input)); + using var reader = new StreamReader(stream); + + var result = Item.Decode(reader); + + Assert.Equal(expected, result.ToString()); + } +} \ No newline at end of file