~ruther/NosSmooth

ref: 3e52548e23c46738ce2194dd02c79fdce85959c3 NosSmooth/Tests/NosSmooth.Game.Tests/Modules/GroupsTests.cs -rw-r--r-- 2.7 KiB
3e52548e — František Boháček feat(core): split raw client and managed client as well as packet handlers 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
69
70
71
72
73
74
75
76
//
//  GroupsTests.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 Xunit.Abstractions;

namespace NosSmooth.Game.Tests.Modules;

/// <summary>
/// Tests for Game.Group.
/// </summary>
public class GroupsTests
{
    private readonly ITestOutputHelper _testOutputHelper;

    /// <summary>
    /// Initializes a new instance of the <see cref="GroupsTests"/> class.
    /// </summary>
    /// <param name="testOutputHelper">The test output helper.</param>
    public GroupsTests(ITestOutputHelper testOutputHelper)
    {
        _testOutputHelper = testOutputHelper;
    }

    /// <summary>
    /// Tests packets from init_morph_use.log.
    /// </summary>
    /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
    [Fact]
    public async Task Init_Join_HpChanges()
    {
        var data = PacketFileClient.CreateFor<GroupsTests>("init_join_hp_changes", _testOutputHelper);

        data.Game.Group.ShouldBeNull();

        await data.Client.ExecuteUntilLabelAsync("AFTER_GROUP_JOINED");

        data.Game.Group.ShouldNotBeNull();
        data.Game.Group.Members.ShouldNotBeNull();
        data.Game.Group.Members.ShouldNotBeEmpty();
        data.Game.Group.Members.Count.ShouldBe(2);
        data.Game.Group.Members.First().Name.ShouldBe("Kekr");

        await data.Client.ExecuteUntilLabelAsync("AFTER_GROUP_FULL");

        data.Game.Group.ShouldNotBeNull();
        data.Game.Group.Members.ShouldNotBeNull();
        data.Game.Group.Members.Count.ShouldBe(3);
        data.Game.Group.Members.First().Name.ShouldBe("Kekr");
        data.Game.Group.Members.Any(x => x.Name == "fluke").ShouldBeTrue();

        await data.Client.ExecuteUntilLabelAsync("AFTER_GROUP_ONE_LEFT");

        data.Game.Group.ShouldNotBeNull();
        data.Game.Group.Members.ShouldNotBeNull();
        data.Game.Group.Members.ShouldNotBeEmpty();
        data.Game.Group.Members.Count.ShouldBe(2);
        data.Game.Group.Members.Last().Name.ShouldBe("fluke");

        await data.Client.ExecuteUntilLabelAsync("AFTER_HEALTH_LOWER");

        data.Game.Group.ShouldNotBeNull();
        data.Game.Group.Members.ShouldNotBeNull();
        data.Game.Group.Members.ShouldNotBeEmpty();
        data.Game.Group.Members.Where(x => x.Name != "dfrfgh").ShouldAllBe(x => x.Hp != null && x.Hp.Percentage < 100);

        await data.Client.ExecuteUntilLabelAsync("AFTER_HEALTH_BELOW_50");

        data.Game.Group.ShouldNotBeNull();
        data.Game.Group.Members.ShouldNotBeNull();
        data.Game.Group.Members.ShouldNotBeEmpty();
        data.Game.Group.Members.Where(x => x.Name != "dfrfgh").ShouldAllBe(x => x.Hp != null && x.Hp.Percentage < 50);
    }
}
Do not follow this link