From 61ab9e34e08ff5a924b212eda573aeceb0dfac22 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Tue, 10 Jan 2023 23:14:20 +0100 Subject: [PATCH] tests: add game friends tests --- .../Modules/FriendsTests.cs | 53 ++++++++++++++++++- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/Tests/NosSmooth.Game.Tests/Modules/FriendsTests.cs b/Tests/NosSmooth.Game.Tests/Modules/FriendsTests.cs index 4b3bdb1..7c13e84 100644 --- a/Tests/NosSmooth.Game.Tests/Modules/FriendsTests.cs +++ b/Tests/NosSmooth.Game.Tests/Modules/FriendsTests.cs @@ -4,6 +4,9 @@ // 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; /// @@ -11,6 +14,52 @@ namespace NosSmooth.Game.Tests.Modules; /// public class FriendsTests { - // friends initialized - // friends updated + private readonly ITestOutputHelper _testOutputHelper; + + /// + /// Initializes a new instance of the class. + /// + /// The test output helper. + public FriendsTests(ITestOutputHelper testOutputHelper) + { + _testOutputHelper = testOutputHelper; + } + + /// + /// Tests friends initialization, friend logout, friend login. + /// + /// A representing the asynchronous operation. + [Fact] + public async Task Test_Init_On_Off() + { + var data = PacketFileClient.CreateFor("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(); + } } \ No newline at end of file -- 2.48.1