~ruther/NosSmooth

ref: 61ab9e34e08ff5a924b212eda573aeceb0dfac22 NosSmooth/Tests/NosSmooth.Game.Tests/Modules/FriendsTests.cs -rw-r--r-- 2.3 KiB
61ab9e34 — Rutherther tests: add game friends tests 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
//
//  FriendsTests.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;
using Xunit.Sdk;

namespace NosSmooth.Game.Tests.Modules;

/// <summary>
/// Test for Game.Friends.
/// </summary>
public class FriendsTests
{
    private readonly ITestOutputHelper _testOutputHelper;

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

    /// <summary>
    /// Tests friends initialization, friend logout, friend login.
    /// </summary>
    /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
    [Fact]
    public async Task Test_Init_On_Off()
    {
        var data = PacketFileClient.CreateFor<FriendsTests>("init_off_on", _testOutputHelper);

        data.Game.Friends.ShouldBeNull();

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

        data.Game.Friends.ShouldNotBeNull();
        data.Game.Friends.ShouldNotBeEmpty();
        data.Game.Friends.Count.ShouldBe(3);
        data.Game.Friends.ShouldContain(p => p.CharacterName == "ffff");
        data.Game.Friends.ShouldContain(p => p.CharacterName == "fluke");
        data.Game.Friends.ShouldContain(p => p.CharacterName == "like");

        data.Game.Friends.ShouldAllBe(x => x.CharacterName == "fluke" || !x.IsConnected);
        data.Game.Friends.First(x => x.CharacterName == "fluke").IsConnected.ShouldBeTrue();

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

        data.Game.Friends.ShouldNotBeNull();
        data.Game.Friends.ShouldNotBeEmpty();
        data.Game.Friends.Count.ShouldBe(3);
        data.Game.Friends.ShouldAllBe(x => !x.IsConnected);

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

        data.Game.Friends.ShouldNotBeNull();
        data.Game.Friends.ShouldNotBeEmpty();
        data.Game.Friends.Count.ShouldBe(3);
        data.Game.Friends.First(x => x.CharacterName == "like").IsConnected.ShouldBeTrue();
    }
}
Do not follow this link