コード例 #1
0
        public void Test_Blacklist_Character()
        {
            var targetSession = TestHelpers.Instance.GenerateSession();

            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
                }
            }));
            var blinsPacket = new BlInsPacket
            {
                CharacterId = targetSession.Character.CharacterId
            };

            _blInsPacketHandler.Execute(blinsPacket, _session);
            Assert.IsNotNull(
                _characterRelationDao.FirstOrDefault(s => (_session.Character.CharacterId == s.CharacterId) &&
                                                     (targetSession.Character.CharacterId == s.RelatedCharacterId) &&
                                                     (s.RelationType == CharacterRelationType.Blocked)));
        }
コード例 #2
0
 public void Setup()
 {
     _characterRelationDao = new GenericDao <CharacterRelation, CharacterRelationDto, long>(_logger);
     Broadcaster.Reset();
     TestHelpers.Reset();
     _session = TestHelpers.Instance.GenerateSession();
     _connectedAccountHttpClient = TestHelpers.Instance.ConnectedAccountHttpClient;
     _blackListHttpClient        = TestHelpers.Instance.BlacklistHttpClient;
     _BlDelPacketHandler         = new BlDelPacketHandler(_blackListHttpClient.Object);
     _characterDao        = new Mock <IGenericDao <CharacterDto> >();
     _blackListController = new BlacklistController(_connectedAccountHttpClient.Object, _characterRelationDao,
                                                    _characterDao.Object);
     _blackListHttpClient.Setup(s => s.GetBlackLists(It.IsAny <long>()))
     .Returns((long id) => _blackListController.GetBlacklisted(id));
     _blackListHttpClient.Setup(s => s.DeleteFromBlacklist(It.IsAny <Guid>()))
     .Callback((Guid id) => _blackListController.Delete(id));
 }
コード例 #3
0
        public async Task Test_Blacklist_Character()
        {
            var targetSession = TestHelpers.Instance.GenerateSession();

            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.AddBlacklist(new BlacklistRequest
            {
                CharacterId = _session !.Character.CharacterId,
                BlInsPacket = new BlInsPacket
                {
                    CharacterId = targetSession.Character.VisualId
                }
            }));
コード例 #4
0
 public static void SetUpClass()
 {
     controller = GetClient().Blacklist;
 }