~ruther/NosSmooth

ref: 81f3ff10ecbad76de2f562a75b71ee95743cdaac NosSmooth/Tests/NosSmooth.Packets.Tests/Converters/Packets/PtctlPacketConverterTests.cs -rw-r--r-- 2.0 KiB
81f3ff10 — Rutherther chore: update versions 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//
//  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;

/// <summary>
/// Tests PtctlPacketConverter.
/// </summary>
public class PtctlPacketConverterTests
{
    private readonly IPacketSerializer _packetSerializer;

    /// <summary>
    /// Initializes a new instance of the <see cref="PtctlPacketConverterTests"/> class.
    /// </summary>
    public PtctlPacketConverterTests()
    {
        var provider = new ServiceCollection()
            .AddPacketSerialization()
            .BuildServiceProvider();

        _packetSerializer = provider.GetRequiredService<IPacketSerializer>();
        provider.GetRequiredService<IPacketTypesRepository>().AddDefaultPackets();
    }

    /// <summary>
    /// Tests that deserialization of raid packet of list members.
    /// </summary>
    [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<PtctlSubPacket>
                (
                    new[]
                    {
                        new PtctlSubPacket(123, 26, 21)
                    }
                )
            )
        );
    }
}
Do not follow this link