public async Task Test_Distant_BlacklistAsync() { var targetSession = await TestHelpers.Instance.GenerateSessionAsync().ConfigureAwait(false); var blPacket = new BlPacket { CharacterName = targetSession.Character.Name }; TestHelpers.Instance.ConnectedAccountHttpClient .Setup(s => s.GetCharacterAsync(targetSession.Character.CharacterId, null)) .ReturnsAsync(new Tuple <ServerConfiguration?, ConnectedAccount?>(new ServerConfiguration(), new ConnectedAccount { ChannelId = 1, ConnectedCharacter = new Character { Id = targetSession.Character.CharacterId } })); using var blacklist = new BlacklistController(TestHelpers.Instance.ConnectedAccountHttpClient.Object, _characterRelationDao !, TestHelpers.Instance.CharacterDao); TestHelpers.Instance.BlacklistHttpClient.Setup(s => s.AddToBlacklistAsync(It.IsAny <BlacklistRequest>())) .Returns(blacklist.AddBlacklistAsync(new BlacklistRequest { CharacterId = _session !.Character.CharacterId, BlInsPacket = new BlInsPacket { CharacterId = targetSession.Character.VisualId } }));
public async Task Test_Distant_BlacklistAsync() { var targetSession = await TestHelpers.Instance.GenerateSessionAsync().ConfigureAwait(false); var blPacket = new BlPacket { CharacterName = targetSession.Character.Name }; TestHelpers.Instance.ConnectedAccountHttpClient .Setup(s => s.GetCharacterAsync(targetSession.Character.CharacterId, null)) .ReturnsAsync(new Tuple <ServerConfiguration?, ConnectedAccount?>(new ServerConfiguration(), new ConnectedAccount { ChannelId = 1, ConnectedCharacter = new Character { Id = targetSession.Character.CharacterId } })); var blacklist = new BlacklistService(TestHelpers.Instance.ConnectedAccountHttpClient.Object, _characterRelationDao !, TestHelpers.Instance.CharacterDao); TestHelpers.Instance.BlacklistHttpClient.Setup(s => s.AddToBlacklistAsync(It.IsAny <BlacklistRequest>())) .Returns(blacklist.BlacklistPlayerAsync(_session !.Character.CharacterId, targetSession.Character.VisualId)); await _blPacketHandler !.ExecuteAsync(blPacket, _session).ConfigureAwait(false); Assert.IsTrue(await _characterRelationDao !.FirstOrDefaultAsync(s => (s.CharacterId == _session.Character.CharacterId) && (s.RelatedCharacterId == targetSession.Character.CharacterId) && (s.RelationType == CharacterRelationType.Blocked)).ConfigureAwait(false) != null); }
public void Test_Distant_Blacklist() { var targetSession = TestHelpers.Instance.GenerateSession(); var blPacket = new BlPacket { CharacterName = targetSession.Character.Name }; TestHelpers.Instance.ConnectedAccountHttpClient .Setup(s => s.GetCharacter(targetSession.Character.CharacterId, null)) .Returns((new ServerConfiguration(), new ConnectedAccount { ChannelId = 1, ConnectedCharacter = new Character { Id = targetSession.Character.CharacterId } })); using var blacklist = new BlacklistController(TestHelpers.Instance.ConnectedAccountHttpClient.Object, _characterRelationDao, TestHelpers.Instance.CharacterDao); TestHelpers.Instance.BlacklistHttpClient.Setup(s => s.AddToBlacklist(It.IsAny <BlacklistRequest>())) .Returns(blacklist.AddBlacklist(new BlacklistRequest { CharacterId = _session.Character.CharacterId, BlInsPacket = new BlInsPacket { CharacterId = targetSession.Character.VisualId } })); _blPacketHandler.Execute(blPacket, _session); Assert.IsTrue(_characterRelationDao.FirstOrDefault(s => (s.CharacterId == _session.Character.CharacterId) && (s.RelatedCharacterId == targetSession.Character.CharacterId) && (s.RelationType == CharacterRelationType.Blocked)) != null); }
public void Test_Distant_Blacklist() { var blPacket = new BlPacket { CharacterName = _targetSession.Character.Name }; _handler.DistantBlackList(blPacket); Assert.IsTrue(_session.Character.CharacterRelations.Any(s => s.Value.RelatedCharacterId == _targetSession.Character.CharacterId && s.Value.RelationType == CharacterRelationType.Blocked)); }
/// <summary> /// blPacket packet /// </summary> /// <param name="blPacket"></param> public void DistantBlackList(BlPacket blPacket) { ClientSession target = ServerManager.Instance.Sessions.Values.FirstOrDefault(s => s.Character.Name == blPacket.CharacterName); if (target == null) { Session.SendPacket(new InfoPacket { Message = Language.Instance.GetMessageFromKey(LanguageKey.CANT_FIND_CHARACTER, Session.Account.Language) }); return; } var blinsPacket = new BlInsPacket { CharacterId = target.Character.CharacterId }; BlackListAdd(blinsPacket); }
/// <summary> /// blPacket packet /// </summary> /// <param name="blPacket"></param> public void DistantBlackList(BlPacket blPacket) { var target = Broadcaster.Instance.GetCharacter(s => s.Name == blPacket.CharacterName); if (target == null) { Session.SendPacket(new InfoPacket { Message = Language.Instance.GetMessageFromKey(LanguageKey.CANT_FIND_CHARACTER, Session.Account.Language) }); return; } var blinsPacket = new BlInsPacket { CharacterId = target.VisualId }; BlackListAdd(blinsPacket); }