Skip to content

Commit

Permalink
MessageFraming is default package manager, Delete Package.cs and Pack…
Browse files Browse the repository at this point in the history
…ageTest.cs. Implement MessageFramingTest
  • Loading branch information
alec1o committed Aug 30, 2023
1 parent f31fc92 commit 8ec511d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 91 deletions.
84 changes: 0 additions & 84 deletions src/Core/Package.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Netly.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
<PackageReleaseNotes>
+ Update default MAX_SIZE 8kb to 8MB (Package.MAX_SIZE -> MesssageFraming encode/decode)
+ Update default MAX_SIZE 8kb to 8MB (Package.MAX_SIZE -&gt; MesssageFraming encode/decode)
</PackageReleaseNotes>
<Description>
Netly is a socket library for c# (C-Sharp). It facilitates the use of socket (UDP and TCP, Client and Server).
Expand Down
24 changes: 18 additions & 6 deletions test/PackageTest.cs → test/MessageFramingTest.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
using Netly.Abstract;
using Netly.Core;
using Xunit.Abstractions;

namespace test;

public class PackageTest
public class MessageFramingTest
{
private readonly ITestOutputHelper _testOutputHelper;
public MessageFramingTest(ITestOutputHelper testOutputHelper)
{
_testOutputHelper = testOutputHelper;
}

[Fact]
public void EndToEnd()
{
Expand All @@ -20,11 +27,11 @@ public void EndToEnd()

bool isLast = false;

byte[] buffer = new List<byte[]> { size1, value1, size2 }.SelectMany(x => x).ToArray();
byte[] buffer = new List<byte[]> { MessageFraming.PREFIX, size1, value1, MessageFraming.PREFIX, size2 }.SelectMany(x => x).ToArray();

Package package = new Package();
MessageFraming package = new MessageFraming();

package.Output((data) =>
package.OnData((data) =>
{
if (isLast is false)
{
Expand All @@ -39,9 +46,14 @@ public void EndToEnd()

isLast = !isLast;
});

package.OnError((error) =>
{
_testOutputHelper.WriteLine($"OnError: {error}");
});

package.Input(buffer);
package.Input(value2);
package.Add(buffer);
package.Add(value2);

Assert.Equal(value1, result1);
Assert.Equal(value2, result2);
Expand Down

0 comments on commit 8ec511d

Please sign in to comment.