Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing KeepAlive props + unit test #49

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/PFire.Core/Protocol/Messages/Inbound/KeepAlive.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
using System.Threading.Tasks;
using PFire.Core.Session;
using PFire.Core.Protocol.Messages;
using System.Collections.Generic;
using System.Threading.Tasks;
using PFire.Core.Protocol.Messages.Outbound;
using PFire.Core.Session;

namespace PFire.Core.Protocol.Messages.Inbound
{
internal sealed class KeepAlive : XFireMessage
{
public KeepAlive() : base(XFireMessageType.KeepAlive) {}
public KeepAlive() : base(XFireMessageType.KeepAlive) { }

[XMessageField("value")]
public int? Value { get; set; }

[XMessageField("stats")]
public List<object> Stats { get; set; }

public async override Task Process(IXFireClient client)
{
Expand Down
24 changes: 24 additions & 0 deletions tests/PFire.Tests/PFire.Core/Protocol/MessageSerializerTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using PFire.Core.Protocol;
using PFire.Core.Protocol.Messages;
using PFire.Core.Protocol.Messages.Inbound;
using Xunit;

namespace PFire.Tests.PFire.Core.Protocol
{
public class MessageSerializerTests
{
[Theory]
[InlineData(new byte[] { 0x0D, 0x00, 0x02, 0x05, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x02, 0x00, 0x00, 0x00, 0x00, 0x05, 0x73, 0x74, 0x61, 0x74, 0x73, 0x04, 0x02, 0x00, 0x00 })]
public void Deserialize_KeepAlive_ReturnsMessage(byte[] bytes)
{
var message = MessageSerializer.Deserialize(bytes);

Assert.True(message.MessageTypeId == XFireMessageType.KeepAlive);
Assert.True(typeof(KeepAlive) == message.GetType());

var keepAlive = message as KeepAlive;
Assert.True(keepAlive.Value == 0);
Assert.True(keepAlive.Stats.Count == 0);
}
}
}
Loading