//
// PtctlPacketConverterTests.cs
//
// Copyright (c) František Boháček. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;
using NosSmooth.Packets.Client.Mates;
using NosSmooth.PacketSerializer;
using NosSmooth.PacketSerializer.Abstractions.Attributes;
using NosSmooth.PacketSerializer.Extensions;
using NosSmooth.PacketSerializer.Packets;
using Shouldly;
using Xunit;
namespace NosSmooth.Packets.Tests.Converters.Packets;
///
/// Tests PtctlPacketConverter.
///
public class PtctlPacketConverterTests
{
private readonly IPacketSerializer _packetSerializer;
///
/// Initializes a new instance of the class.
///
public PtctlPacketConverterTests()
{
var provider = new ServiceCollection()
.AddPacketSerialization()
.BuildServiceProvider();
_packetSerializer = provider.GetRequiredService();
provider.GetRequiredService().AddDefaultPackets();
}
///
/// Tests that deserialization of raid packet of list members.
///
[Fact]
public void Converter_Deserialization_Succeeds()
{
var packetResult = _packetSerializer.Deserialize
(
"ptctl 1 1 123 26 21 123 13",
PacketSource.Server
);
packetResult.IsSuccess.ShouldBeTrue();
var packet = (PtctlPacket)packetResult.Entity;
packet.ShouldBeEquivalentTo
(
new PtctlPacket
(
1,
1,
new List
(
new[]
{
new PtctlSubPacket(123, 26, 21)
}
)
)
);
}
}