Exemple #1
0
        public void Setup()
        {
            PacketFactory.Initialize <NoS0575Packet>();
            Broadcaster.Instance.Reset();
            var contextBuilder =
                new DbContextOptionsBuilder <NosCoreContext>().UseInMemoryDatabase(Guid.NewGuid().ToString());

            DataAccessHelper.Instance.InitializeForTest(contextBuilder.Options);

            GroupAccess.Instance.Groups = new ConcurrentDictionary <long, Group>();
            for (byte i = 0; i < (byte)(GroupType.Group + 1); i++)
            {
                var handler = new GroupPacketController();
                var session = new ClientSession(null, new List <PacketController> {
                    handler
                }, null);
                session.SessionId = i;

                Broadcaster.Instance.RegisterSession(session);
                var acc = new AccountDto {
                    Name = $"AccountTest{i}", Password = EncryptionHelper.Sha512("test")
                };
                var charaDto = new CharacterDto
                {
                    CharacterId = i,
                    Name        = $"TestExistingCharacter{i}",
                    Slot        = 1,
                    AccountId   = acc.AccountId,
                    MapId       = 1,
                    State       = CharacterState.Active
                };

                session.InitializeAccount(acc);
                _handlers.Add(handler);
                handler.RegisterSession(session);

                var chara = charaDto.Adapt <Character>();
                chara.Session = session;
                _characters.Add(i, chara);
                chara.Group.JoinGroup(chara);
                session.SetCharacter(chara);
                session.Character.MapInstance = new MapInstance(new Map(), Guid.NewGuid(), true, MapInstanceType.BaseMapInstance, null);
            }
        }
        public void Setup()
        {
            PacketFactory.Initialize <NoS0575Packet>();
            Broadcaster.Reset();
            GroupAccess.Instance.Groups = new ConcurrentDictionary <long, Group>();
            for (byte i = 0; i < (byte)(GroupType.Group + 1); i++)
            {
                var handler = new GroupPacketController();
                var session = new ClientSession(null, new List <PacketController> {
                    handler
                }, null, null, _logger)
                {
                    SessionId = i
                };

                Broadcaster.Instance.RegisterSession(session);
                var acc = new AccountDto {
                    Name = $"AccountTest{i}", Password = "******".ToSha512()
                };
                var charaDto = new Character(null, null, null, null, null, null, null, _logger)
                {
                    CharacterId = i,
                    Name        = $"TestExistingCharacter{i}",
                    Slot        = 1,
                    AccountId   = acc.AccountId,
                    MapId       = 1,
                    State       = CharacterState.Active
                };

                session.InitializeAccount(acc);
                _handlers.Add(handler);
                handler.RegisterSession(session);

                var chara = charaDto;
                chara.Session = session;
                _characters.Add(i, chara);
                chara.Group.JoinGroup(chara);
                session.SetCharacter(chara);
                session.Character.MapInstance = new MapInstance(new Map(), Guid.NewGuid(), true,
                                                                MapInstanceType.BaseMapInstance,
                                                                new MapItemProvider(new List <IHandler <MapItem, Tuple <MapItem, GetPacket> > >()),
                                                                null, _logger);
            }
        }