public void Setup() { PacketFactory.Initialize <NoS0575Packet>(); var contextBuilder = new DbContextOptionsBuilder <NosCoreContext>().UseInMemoryDatabase( databaseName: Guid.NewGuid().ToString()); DataAccessHelper.Instance.InitializeForTest(contextBuilder.Options); var _acc = new AccountDto { Name = "AccountTest", Password = EncryptionHelper.Sha512("test") }; _chara = new CharacterDto { CharacterId = 1, Name = "TestExistingCharacter", Slot = 1, AccountId = _acc.AccountId, MapId = 1, State = CharacterState.Active }; _session.InitializeAccount(_acc); var items = new List <Item> { new Item { Type = PocketType.Main, VNum = 1012, IsDroppable = true }, new Item { Type = PocketType.Main, VNum = 1013 }, new Item { Type = PocketType.Equipment, VNum = 1, ItemType = ItemType.Weapon }, new Item { Type = PocketType.Equipment, VNum = 912, ItemType = ItemType.Specialist }, new Item { Type = PocketType.Equipment, VNum = 924, ItemType = ItemType.Fashion } }; var conf = new WorldConfiguration { BackpackSize = 1, MaxItemAmount = 999 }; _itemBuilder = new ItemBuilderService(items); _handler = new InventoryPacketController(conf); _handler.RegisterSession(_session); _session.SetCharacter(_chara.Adapt <Character>()); _session.Character.MapInstance = _map; _session.Character.Inventory = new InventoryService(items, conf); }
public void Setup() { SystemTime.Freeze(); PacketFactory.Initialize <NoS0575Packet>(); var contextBuilder = new DbContextOptionsBuilder <NosCoreContext>().UseInMemoryDatabase( databaseName: Guid.NewGuid().ToString()); DataAccessHelper.Instance.InitializeForTest(contextBuilder.Options); var _acc = new AccountDto { Name = "AccountTest", Password = "******".ToSha512() }; _chara = new CharacterDto { CharacterId = 1, Name = "TestExistingCharacter", Slot = 1, AccountId = _acc.AccountId, MapId = 1, State = CharacterState.Active }; _session.InitializeAccount(_acc); var items = new List <Item> { new Item { Type = PocketType.Main, VNum = 1012, IsDroppable = true }, new Item { Type = PocketType.Main, VNum = 1013 }, new Item { Type = PocketType.Equipment, VNum = 1, ItemType = ItemType.Weapon }, new Item { Type = PocketType.Equipment, VNum = 2, EquipmentSlot = EquipmentType.Fairy, Element = 2 }, new Item { Type = PocketType.Equipment, VNum = 912, ItemType = ItemType.Specialist, ReputationMinimum = 2, Element = 1 }, new Item { Type = PocketType.Equipment, VNum = 924, ItemType = ItemType.Fashion } }; var conf = new WorldConfiguration { BackpackSize = 2, MaxItemAmount = 999 }; _itemBuilder = new ItemBuilderService(items, new List <IHandler <Item, Tuple <IItemInstance, UseItemPacket> > >()); _handler = new InventoryPacketController(conf); _mapItemBuilderService = new MapItemBuilderService(new List <IHandler <MapItem, Tuple <MapItem, GetPacket> > > { new DropHandler(), new SpChargerHandler(), new GoldDropHandler() }); _map = new MapInstance(new Map { Name = "testMap", Data = new byte[] { 8, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } , Guid.NewGuid(), false, MapInstanceType.BaseMapInstance, new List <NpcMonsterDto>(), _mapItemBuilderService, new MapNpcBuilderService(_itemBuilder, new List <ShopDto>(), new List <ShopItemDto>(), new List <NpcMonsterDto>(), new List <MapNpcDto>()), new MapMonsterBuilderService(new List <Item>(), new List <ShopDto>(), new List <ShopItemDto>(), new List <NpcMonsterDto>(), new List <MapMonsterDto>())); _handler.RegisterSession(_session); _session.SetCharacter(_chara.Adapt <Character>()); _session.Character.MapInstance = _map; _session.Character.Account = _acc; _session.Character.Inventory = new InventoryService(items, conf); _session.Character.ExchangeService = new ExchangeService(null, null); }